37
votes
Accepted
How can I prevent a user from editing my code in their browser?
You literally cannot prevent users from accessing and modifying content that you are sending them. You have no control over the browser, or which browser they use, or whether they are in fact ...
23
votes
How can I prevent a user from editing my code in their browser?
You can't. One of the fundamental rules of computing: you can't trust the client. Whatever clever scheme you think of, I can get round it if I am in control of the client.
22
votes
Accepted
Is it bad design to internally call API endpoints from within the API instance?
There is little use of actually doing an HTTP request.
When the underlying application processes the GET request from your example, it probably calls the business layer which does some input checking,...
18
votes
Accepted
Stateful vs non-stateful app
In the context of web applications, we call the server stateful if it maintains transient state in memory, rather than storing any data externally (e.g. in a database).
Stateful applications have a ...
15
votes
Optional dependencies in npm?
If you want simple optional dependencies like plugins, e.g. if you install foo you will run it colorful but if not installed, you don't have any problem and see it in gray, then you could use ...
10
votes
Accepted
Clearing up misconceptions about a Flask backend and client-side rendering
You are incorrect about the need for separate front-end and back-end servers.
You need only one server, which can be your Flask-based server, that
provides one (static) HTML page when users access the ...
9
votes
Accepted
How to name two functions that could be named the same?
Adding a prefix to the function that actually does the work, like doDoStuff
Don't do that. Or you'll end up with doStuff(), doDoStuff(), reallyDoStuff(), reallyReallyDoStuff() and ...
9
votes
Should servers exit with 0 or 1 in case of caught errors?
A service that has caught and handled an error should not exit at all.
Otherwise, an exit code 0 indicates success, which for a service would be appropriate as the result of an orderly shutdown ...
9
votes
Is it a good idea to wrap node.js package functions in a micro-service architecture?
This sounds like the old trick of breaking direct dependence on 3rd party code.
Rather than let mentions of 3rd party code spread through your code base you wrap calls to it. Not everything, just what ...
8
votes
Heavy task exposed via a REST API
The key insight here is to treat job activations as resources that have a significant lifetime.
In a similar situation, I have implemented job creation using a POST method that returns a "202 ...
8
votes
Accepted
Storing unchangeable data in database vs in code
Data being "unchangeable" doesn't necessarily mean it cannot be changed. It just cannot be changed through the application. Set an "unchangeable" flag on each row. When true the application refuses to ...
8
votes
Accepted
What really is a "web server" in relation to popular frameworks like Flask, Node.js, Apache?
In IT in general we're all really bad at using words that are either
Not rigorously defined
The rigorous definition is different than the way the term is commonly used (e.g. strong typing)
In other ...
7
votes
Is it bad design to internally call API endpoints from within the API instance?
Yes its bad(tm).
The extra overhead of making the http call although needless probably wont be much of a factor.
I think The real dangers are:
The accidental introduction of endless loops. ie Post ...
7
votes
Accepted
Node.js script const variables in SCREAMING_SNAKE_CASE or camelCase
You are not really declaring a variable, but what other languages call an alias.
Example in Python:
import numpy as np
Example in C#:
using Project = PC.MyCompany.Project;
For your case, from the ...
7
votes
Accepted
What is the point of rooms in socket.io?
Rooms are a tool in socket.io servers for keeping track of groups of connected users. You can then iterate the sockets in a room or broadcast to all of them. There's really nothing more to them than ...
7
votes
Accepted
Nodejs cluster: are there any downsides?
Several possible downsides or issues you have to code for:
Login sessions must either be stored in a central database (such as redis) that all clusters can access or connections must be made sticky so ...
7
votes
Accepted
Is it bad practice to require the same module in multiple files in Javascript?
Don't worry about that.
A first require involves a bunch of input/output operations in order to find the matching file and read it into memory. “Any performance impact here will be inconsequential ...
7
votes
What would be the reason for using asynchronous programming on a web server?
Asynchronous calls are better when your application is io bound opposed to being cpu bound (in case of web applications, almost always). Talking to the database, receiving and sending packets on the ...
6
votes
How to handle UI updates dependent on slow API responses
You don't have to block the complete UI before the response comes back. You only have to disable the parts of the UI which allow to make another API call before the first one is processed completely (...
6
votes
Accepted
Domain Driven Design - updating part of aggregate
Your fears are perfectly valid, and they are an everyday part of DDD.
You can design your domain in many ways. For one thing, always keep in mind that the aggregate is the boundary of transactional ...
6
votes
Stateful vs non-stateful app
If you are storing state on the server that is needed in order to process an incoming request from the client, then the server is stateful. Said another way, it has state that it stores and needs to ...
6
votes
Accepted
What pattern lets each of multiple "voters" decide on a central status?
What is a pattern?
A pattern is not different from any other code you use in your application. The only difference is that somebody said "this is now called [x] pattern" and then that name has been ...
6
votes
Accepted
Is checking dependencies into source control worth the cost?
It seems there are two problems:
Tracking NPM dependencies in version control is clunky and slow.
Unzipping all of these dependencies is a bit slow.
These are all solvable problems without a major ...
6
votes
How to warn devs after installing or updating npm packages?
Looks like you may have an X-Y problem here.
Your actual problem is that it happens (often? sometimes?) that the build environment isn't cleaned after installing or updating packages.
You think that ...
6
votes
Accepted
Extensive use of global variables in js codebase?
How do you eat an elephant? One bite at a time.
Start with writing regression tests, so you can be confident not to break too much when you refactor.
Find out where and how certain variables are ...
6
votes
Is this too much for a modular monolith system?
The client was very much inspired from microservices so I had to convince him to go for a monolith which then can later be migrated to a microservices. besides to me microservices for a 3-dev team is ...
5
votes
Accepted
Is this Big Data architecture good enough to handle many requests per second?
The architecture is good enough to handle many requests per second, as long as you test it and profile it and it proves to handle the load that it is required to handle.
Let me quote Donald Knuth, ...
5
votes
Accepted
Proper usages of rooms/namespaces when making a News Feed with socket.io
Now that it has been nearly 3 years, and the software in question has been in production with hundreds of thousands of users this entire time, I am going to answer my own question.
I went with option ...
5
votes
Accepted
How do I automate build-publish tasks for my web server?
A Bash script is exactly how it happens in many companies. Avoid steps that you have to perform manually. Automate them so that you only have to kick off the process and can then sit back. Being able ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
node.js × 509javascript × 143
architecture × 50
mongodb × 36
design-patterns × 26
web-development × 24
design × 23
database × 21
api × 19
websockets × 19
php × 18
angularjs × 18
rest × 17
microservices × 17
java × 15
api-design × 12
web-applications × 12
performance × 12
unit-testing × 11
server × 11
dependencies × 11
testing × 10
authentication × 10
typescript × 10
npm × 10