Skip to main content
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 ...
amon's user avatar
  • 136k
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.
Philip Kendall's user avatar
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,...
Arseni Mourzenko's user avatar
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 ...
amon's user avatar
  • 136k
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 ...
PhoneixS's user avatar
  • 323
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 ...
Bart van Ingen Schenau's user avatar
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 ...
CharonX's user avatar
  • 1,719
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 ...
Michael Borgwardt's user avatar
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 ...
candied_orange's user avatar
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 ...
Hans-Martin Mosner's user avatar
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 ...
Greg Burghardt's user avatar
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 ...
Jared Smith's user avatar
  • 1,935
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 ...
Ewan's user avatar
  • 81.9k
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 ...
Nales0's user avatar
  • 86
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 ...
jfriend00's user avatar
  • 3,597
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 ...
jfriend00's user avatar
  • 3,597
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 ...
Arseni Mourzenko's user avatar
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 ...
hangyas's user avatar
  • 134
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 (...
Doc Brown's user avatar
  • 218k
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 ...
Zoran Horvat's user avatar
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 ...
jfriend00's user avatar
  • 3,597
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 ...
R. Schmitz's user avatar
  • 2,598
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 ...
Greg Burghardt's user avatar
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 ...
Hans-Martin Mosner's user avatar
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 ...
Doc Brown's user avatar
  • 218k
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 ...
candied_orange's user avatar
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, ...
rsp's user avatar
  • 7,868
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 ...
Christian's user avatar
  • 189
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 ...
amon's user avatar
  • 136k

Only top scored, non community-wiki answers of a minimum length are eligible