r/node • u/SkShoyebDev • Oct 23 '23
Roast my server.ts code of express and what to improve
Roast my server.ts code of express and what to improve
50
u/buffer_flush Oct 23 '23 edited Oct 23 '23
I’d use a route group for /api it’d make things easier to apply middlewares specific to API related routes.
express.static(__dirname) scares me a bit as you’d need to be pretty careful not to put anything secret on that path or it’d be exposed publicly.
-3
Oct 24 '23
It looks like it is for school so exposing the server source was done probably so he can be graded.
And even if it isn’t, I think you should always give opportunities to make money to the smart students while they are attending high school, so I’d still approve it cause worst case scenario you effectively stimulate the school economy.
The benefits are numerous.
The stupid drug dealers pay their hacker classmate to change their grades and now they have good enough grades to go to college. The fat kid has to spend his lunch money on buying a grade change and loses weight. The small business type students selling candy or walking dogs or washing cars now have a very practical thing to spend their money on, instead of brain rotting video games. The other nerdy students now have a god to worship, and if he’s REALLY smart he’ll implement a tithing system along with moral guidelines. Etc etc
All it takes is to get the money flowing and all of a sudden you’ve influenced the lives of the entire student body.
All with one line of bad code
1
u/Mammoth_Marsupial622 Oct 25 '23
you are acting like compromising a whole school’s academic integrity is no big deal. yeah this is a great movie plot but people compete for scholarships and real money based off grades. they must follow the CIA triad
86
u/vainstar23 Oct 23 '23
*IQ distribution meme
Left side: Looks ok, merge to main
Center: Nooooo!!! You have to add authentication! Helmet!! Yon can't just use DEFAULT IMPORTS!!
Right side: Looks ok, merge to main
31
Oct 23 '23
3 YOE Engineer: "I read on a blog that best practices for <x> state that...."
10 YOE Engineer: "I can read it. I know what its doing. Code isn't atrocious. SHIP IT."
-8
u/lifeofhobbies Oct 23 '23
Nothing to do with YOE. It's a developer who is aware of the business value of their contributions vs a developer who doesn't.
10
u/MatthewMob Oct 23 '23
And that awareness typically comes from YOE in a real business environment.
-3
u/lifeofhobbies Oct 23 '23
Not really, it's more about the individual's ability to learn. If one needs 10 years to understand how their company makes profit and how their contribution relates to that, one is slow at learning. People who are good at learning, they know those info even before working in a company.
1
u/MatthewMob Oct 23 '23 edited Oct 23 '23
Sure, maybe not years, but for most I would say it is necessary to have some amount of actual work experience before they are able to see past their own nose in relation to where a developer and their code actually fit in to how a project is completed in the real world.
When learning most (are made to) only focus on themselves and what they are doing - code quality, best practices and using the latest tech. In a real world environment you have real deadlines, real requirements and real people to answer to that force you to compromise and realize that your technology and code is just a means to an end for a business goal.
I'd say most people aren't born with that and also aren't adequately taught it in bootcamps, university or online courses.
1
u/lifeofhobbies Oct 23 '23
Yeah so it's about how an individual learns in such environment, and not much about the number of years of being in that environment. The main point is still about the individual, not how long the time is spent.
6
0
Oct 23 '23
[deleted]
1
u/vainstar23 Oct 24 '23
I've worked for companies that called it "base" or "production"..
This one time during the period during the BLM movement when companies were renaming master to main, GitHub was still configured to use master as the default branch so we basically had to ignore it until we could switch the default branch back to main.
There were also some issues because a lot of stuff like CD was configured to follow master. It was quite messy but at least now everything is resolved. I even got used to saying main now instead of master.
23
144
u/Acktung Oct 23 '23
No api versioning, no rate-limit, no helmet, no auth, no open-api...
73
u/r0ck0 Oct 23 '23
No motherfucking Hootie & The Blowfish
3
3
u/IanMacDooglas Oct 23 '23
Don't think I've EVER seen a Soulfly reference on Reddit, thanks for the throwback
2
u/r0ck0 Oct 24 '23
Surprised I got this many upvotes, haha.
Not sure how many knew it from Soulfly, or just found it funny otherwise or something?
6
u/xxxdarrenxxx Oct 23 '23
I mean technically you can even add 20 more things to make any part better.
OP's question is so un-pragmatic without a context. The smart answer is if u need a base set of these features from the start, just start with a full framework like nest.js or laravel or django and not even bias towards a language for true architectural decision making and/or robustness
2
3
2
Oct 23 '23
What do you mean by open-api?
12
Oct 23 '23 edited Oct 23 '23
OpenAPI is a spec for typing and documenting your endpoints. You can use tooling that implements the OpenAPI spec to generate types, clients, and servers in multiple languages.
Imagine you had 100+ endpoints and you needed to delve into code to know what HTTP codes they returned, their types, their params, etc.
5
4
1
u/ChinoSenpai Oct 23 '23
How to add a rate limit in this case?
-2
u/Bright_Bonus9823 Oct 23 '23
Redis bro
3
u/PrestigiousZombie531 Oct 24 '23
add rate limiters to nginx, keep rate limiting logic outside express and node
2
1
u/Careful_Whole2294 Oct 23 '23
Im new to node, what is helmet (a helmet)? Is that a node thing? Or a broader concept?
1
Oct 26 '23
Have to scroll down a bit but it’s essentially to protect against the most common server vulnerabilities so your stuff is secure. Hints a helmet for your server 🪖
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Express_Nodejs/deployment
0
u/fordon_greeman_ Oct 23 '23
had to look it up myself. when in doubt, search it up on NPM's website:
1
29
Oct 23 '23
Why oh why is there a tab there.
7
u/r0ck0 Oct 23 '23
Might have got thirsty, and ordered a tab?
2
12
95
u/xroalx Oct 23 '23
Do not split imports.
Do not use default exports.
Redundant type declaration for
app.Unnecessary comments (
middlewares,all routes, ...).Unnecessary indentation (
app.use(express.json())).express.json()andbodyParser.json()? Why?Endpoints are typically pluralized in REST.
users,students,questions...Unclear naming. What's
connectfromutils/connection?
Not much else to say about this, there's not a lot happening just here.
45
u/Cyberphoenix90 Oct 23 '23
Surprised someone agrees with my "don't use default exports" preference. Default exports only lead to issues and give no benefit in my opinion. Can't even auto import them because the thing you want to import has no name
13
11
2
u/EvilPencil Oct 23 '23
100% this. Default exports are hot garbage, why the eff are they in the Airbnb eslint rules?
12
u/Chronox Oct 23 '23
Split imports, but not like that. Split third party libraries apart.
-7
u/xroalx Oct 23 '23
I don't see a reason to do that.
12
u/Chronox Oct 23 '23
What's the reason to do any stylizing, then? Just cleaner to group similar and separate the groups with a space.
-3
u/xroalx Oct 23 '23
Most of the time, your imports are automatically inserted by the editor and you generally skip imports when reading code, so manually managing them and moving them around just sounds like a lot of manual work that might end up being inconsistent anyway and the imports end up taking more vertical space.
If you have it automated via an editor/prettier plugin, I still find it unnecessary but it's fine. That doesn't seem to be the case here, though, because of the manual comment.
→ More replies (1)4
u/rkd6789 Oct 23 '23
Can you explain, do not split imports
-2
u/xroalx Oct 23 '23
Grouping import statements and separating them with empty lines.
VSCode already sorts the imports quite sensibly, it auto-imports stuff you reference, there's no added benefit in manually managing which import goes where and moving them around.
If you have a prettier plugin to do it, fine, but I don't really see the point anyways.
1
1
3
u/RubbelDieKatz94 Oct 23 '23
All of this formatting stuff can be easily standardized by adding a husky hook on commit with pretty-quick.
1
u/Tjq866 Oct 23 '23
Would you say that his routes could be imported from an index.js from routes?(one liner)?
8
u/xroalx Oct 23 '23
Unless the code gets too long to have it all in one place, I actually prefer the approach OP chose.
If the code got too long, I'd probably create a
routes/routes.tsfile and put the route setup there.Either way, neither one is inherently good or bad in my opinion.
What I do consider bad though is using the
indexname and relying on the resolution algorithm, as that is not part of the JavaScript standard, it's just something Node supports, and I believe it doesn't even work if you're running Node in ESM mode.2
Oct 23 '23
Use a single file until it grows "large enough" to split it up into distinct modules. Keep them all in the same folder and don't try to abstract too early, even if you think it'll make sense later to do so.
One thing I've learned as an engineer is that your file architecture should be as simple as possible in the beginning and not to fuck with it until you actually need it be more complex.
My biggest mistakes as a new engineer was 1) using index files out of the gate and 2) splitting and colocating type files.
I learned a very important lesson at 4PM one day about circular imports.
1
u/Tjq866 Oct 23 '23
A few projects ago I think I started to over abstract. I was making helper functions to handle dispatches in the front end, I think with all the advice I heard about keeping things modular I just went overboard, but sometimes it is hard not to. I like your advice about keeping things simple at first.
2
Oct 23 '23
I would also advise to keep meta-work distinct from feature-work.
Ship the feature first using whatever is in place. Then, if you have to reorg, cut a different commit for that. This way you can keep your changes separate and you don't have to roll back a feature for some borked internal bug.
1
u/Tjq866 Oct 23 '23
Thanks. I never considered that. The bootcamp I went to used an index file and just exported the router from that from a routes/index.js. They also used babel (to allow esm), which is not even recommended for production.
1
u/Anchorman_1970 Oct 23 '23
Why not expressjson snd bodyparder at the time? What if be passes verfiy funxrion. But did not want all body to be verified, only for webhooks
1
u/xroalx Oct 23 '23
Because they both do the same thing.
I'm not sure what verify function you're talking about, what does it have to do with webhooks, or where you see any of that in this code.
0
1
0
23
Oct 23 '23
[removed] — view removed comment
57
u/xroalx Oct 23 '23
A default export inherently has no name, it doesn't tell you what it is, and it's up to the importer to give it a name.
It can be imported as
Fooin one file, and asBarin the other, orfoo, orfooh, or anything else. This makes the code inconsistent or it forces you to refer back to previous imports to know what it was called.Furthermore, if the import name does not match the file name, tooling might not even be able to autocomplete the import, whereas when you try to import something named
usersRouter, the editor can look for named exports that match the name.Let's put it the other way around, default exports have downsides and no benefits over named exports. Why use them in the first place?
There's one valid case - when the file is to be consumed by a tool - such as configuration files. They'd either have to enforce a name, or just roll with default and not care, but such a file is never imported in your own code.
16
u/MrNutty Oct 23 '23
I don’t think default imports are bad. Here are the reasons why
forces one not to pollute a file. When used, makes the purpose of the function and file clear. I always export a default named variable that also matches the file name though. Resolves any auto import issues.
less chance someone does “import * as Foo”. This pattern I’ve found lead to tools such as ts-prune not pruning a function that’s really unused.
less curly braces
Obv all are nit picky but wanted to highlight a positive view. Doesn’t mean Im saying one or the other way is better
5
u/Bullroarer_Took Oct 23 '23
yeah its really a matter of opinion that has been asserted as a law
4
u/MrNutty Oct 23 '23
Yea all of these discussions are usually a matter of opinion using our experience to best create some guidelines.
1
0
1
u/lifeofhobbies Oct 23 '23
Default export is fine as long as you have a naming convention, like in everything else.
3
u/Chazgatian Oct 24 '23
See the reasoning in all other threads. This is terrible advice
0
u/lifeofhobbies Oct 24 '23 edited Oct 24 '23
Terrible only for you maybe.
Function exported is named foo, file name is named foo, why the hell would anyone importing it name the variable something else. If you do, that's not a default export problem.
2
u/tarwn Oct 24 '23
Now your team decides to rename it to legacyFoo to differentiate it from a new foo that is being built (naming is hard). In the named export version the build (if you're bundling, transpiling, etc) or editor produces errors for any instances you missed and prevents you from continuing until you clean them up. In the default export you missed 2 imports and renamed one of the new imports to legacyFoo without realizing it, and in 3 months some interesting bugs are going to occur when someone makes a change assuming the naming is correct.
1
u/lifeofhobbies Oct 24 '23
It would produce similar errors in the default export version as the code wouldn't run with the import path to a missing file that you renamed. Just like the code wouldn't run with an import variable to a missing named export that you renamed.
1
u/tarwn Oct 25 '23
Sorry, I should have been clearer with "rename it to legacyFoo". Your example fits in that description but isn't what I was trying to describe. If you've never worked on a codebase where the thing being default exported had one name in the file and a variety of different names throughout the codebase, then I'm happy for you. You're correct that if the filename is changed it would cause an error if the import path is not updated too, but there are cases where the filename is already unique enough and not changed, where folks change the filename and the editor automatically updates the path/filename portion of all their imports leaving the and the old module name isn't touched, where folks add local index files to re-export it modules and the names morph along the way, and probably more cases I'm not remembering.
The point is that named exports get extra guardrails that can be automatically updated or throw build errors immediately while you're still making the initial change, whereas default exports do not and in many cases will never give you the extra nudge that there's 3 places still using the old flavor of the name.
→ More replies (5)1
u/Chazgatian Oct 24 '23
Because they can, and I've seen it happen. That's why it's called an anti pattern
1
u/lifeofhobbies Oct 24 '23
Who called it an anti pattern tho? Why is it the default pattern with React components If thats an antipattern?
6
u/bmcle071 Oct 23 '23
I don’t like them because they aren’t refactorable. If you do a rename then the modules that import the thing you are renaming continue to use the name defined in their import statement.
0
Oct 23 '23
[deleted]
1
u/bmcle071 Oct 23 '23
What if you want to change the name of the thing? It’s goona happen eventually.
0
Oct 24 '23
[deleted]
1
u/bmcle071 Oct 24 '23
That’s just the thing, they don’t for default exports. Well at least VSCode doesn’t.
8
u/bongobret Oct 23 '23
Wrote servers like this for years but then I saw the light and switched to fastify. It has built in json schema validation at the framework layer since it’s so important not to screw that part up when processing untrusted user input. Guessing you are hand rolling your validation as one tends to do with express. It’s probably not too late to switch and stop shipping unvalidated api endpoints!
2
u/ArnUpNorth Oct 23 '23
A good programmer will write good code no matter the framework. If OP switches to fastify he ll just lose time refactoring without learning anything useful.
3
u/bongobret Oct 23 '23
You are right, you can write reliable services with express, or even learn a lot rolling your own http handler in node. Refactoring a project from express to node, however, there is still a lot to learn, especially on the validation front. The former approaches tend to neglect this extremely important layer in any http endpoint. It's also just an incredible tool to have some experience on, and its a great way to learn tricks and patterns from some of the top people in the node ecosystem.
1
u/ArnUpNorth Oct 24 '23
Ok but you dont need fastify or any other framework to learn that. When learning to code it s a bit aggravating when someone tells you « use another framework » but you didn t learn why and what was wrong in what you were doing previously. Also if i am not mistaken by default fastify doesn t validate anything neither…
so between adding a lib to do it in express or configuring it in fastify there s not much gain.
2
u/HackTVst Oct 24 '23
Express itself has performance bottlenecks that are identified and solved in Fastify. Express is an inefficient framework if you want to maximize your server performance. But that may not matter to simple apps with less traffic.
2
u/bongobret Oct 24 '23
I totally understand. One asks a general question: I took approach x, did I make any errors? And a common response is “use some other tool du jour” by someone who’s barely used either tool. Annoying pattern, easy to spot.
I want to clarify that the advice here is: if you are writing api endpoints, you are accepting untrusted user input. It’s irresponsible to ship anything but toy examples that lack strong request validation. From a security perspective and a maintainability perspective.
Im suggesting in the first comment and in this comment that fastify is the best path available in the node ecosystem at the moment to learn about robust endpoint validation. It’s a great example and implementation of pretty much everything you should be doing when handling http requests in node. The fact that it also adds a significant performance boost and endpoint documentation as a side effect of the validation specification only drives the lesson home when you learn about this approach. Fastify includes built in validation, it’s not a plugin. These things can be added to express as plugins however having worked in the express ecosystem for years, witnessed many newcomers navigate that ecosystem, these concerns are not emphasized or addressed in that plugin ecosystem very effectively.
12
Oct 23 '23
Redundant comments, redundant Application type, redundant body-parser
1
u/polyocto Oct 23 '23
Depending on your team’s philosophy, that Application type may be wanted, to remove any doubt.
6
6
4
4
u/tswaters Oct 23 '23
Split server from app. App includes the definition, most everything here... Server requires app and calls listen with the long-form const server = http.createServer(app) ... You can add signal handlers for SIGINT/SIGTERM and gracefully close server connections instead of the default process.exit (results in ECONNRESET to connected clients when app is cycling/upgrading)
7
u/NoMoreVillains Oct 23 '23
My only real complaints are the unnecessary comments for self explanatory code. I don't care for the "no default imports" debate. 9.5/10 claps
2
u/HackTVst Oct 24 '23
The OP seems like a beginner. Comments are basically so you can remember what tf you wrote one year later. They are for you, not other devs, coz this is a personal project.
3
u/Confident_Force_944 Oct 23 '23
Curious about the connect(). Is that connection to database? When starting a server, I generally want two things to happen: server is listening on port and connecting to database, if either fail, fail loudly.
1
u/polyocto Oct 23 '23
I missed that. If it is for a database, then I’d certainly want the connection to be done before the server is ready to serve. This because I’d rather any preflight be done before the server is accepting http connections, otherwise you’ll either become returning 500 errors all the time (assuming the server doesn’t crash).
Also, the if it is for the database, then the module should probably be called ‘database’, to avoid confusion as to purpose.
3
3
u/ajvg94 Oct 24 '23
Some simple improovements are: rate limit, slow down, cors, helmet, swagger docs
If you already use express.json(), there is no need to use bodyParser
You can add this line to stop the server from returning information about it
app.disable('x-powered-by');
Also you can check this project of mine for some examples. I am still improving but maybe it can help you.
3
3
u/foflexity Oct 24 '23
I use fastify… does express not have an auto load where you define routes by the directory structure and it loads them dynamically?
9
u/MaxUumen Oct 23 '23
What's the point of polishing the front door if the interior might be filled with garbage.
2
u/tech_ai_man Oct 23 '23
You didn't display the line numbers, making it difficult to comment on a line by line basis.
2
2
u/ArnUpNorth Oct 23 '23
Maybe at least format the code and have it linted before asking for a roast ? 🙈
2
2
u/Capable-Lecture2001 Oct 25 '23
Man that app.use("/"..... Is dangerous if put before any other app.use
3
2
u/turshija Oct 23 '23
Mixing single and double quotes, both in imports and routes. Add eslint and prettier to handle those kind of stuff automatically.
0
Oct 23 '23
[deleted]
0
u/LdouceT Oct 23 '23
I'd say that's a reasonably anal thing, it's distracting the same way weird variable names are. Take some pride in your work, this kind of stuff is sloppy.
1
1
1
1
u/alwyn974 Oct 24 '23
Maybe try nestjs it's a powerful framework built on top of expressjs, you can even use fastify if you want.
1
1
1
u/misterjyt Oct 24 '23
try to configure it to automatically auto route based on directory.. like create a route folder or api folder where you set auto routing in it. So that it follows the folder structure.. this way you dont have to edit that file everytime you add a new route.
like this: in your main js/ts file:
const express = require('express');
const app = express();organize your routes:
- routes/
- index.js
- users.js
- products.jssample in user.js:
// In users.js
const express = require('express');
const router = express.Router();
// Define routes for users
router.get('/', (req, res) => {
// Route handling logic
});
module.exports = router;in your main file or server.js file. load the route files dynamically using a loop and require. This allows you to automatically load all route files within the routes folder.
const fs = require('fs');
const path = require('path');
// Get a list of route files
const routeFiles = fs.readdirSync(path.join(__dirname, 'routes'));
// Load each route dynamically
routeFiles.forEach((file) => {
const routePath = path.join(__dirname, 'routes', file);
app.use(require(routePath));
});and try listening:
const port = process.env.PORT || 3000;
app.listen(port, () => {
console.log(`Server is running on port ${port}`);
});
this is just a sample, so you can configure it rourself
1
u/HackTVst Oct 24 '23
Ship it, then modify it as your needs dictate down the road. If you listen to so-called best practices you will end up running Docker, Kubernetes, AWS S3, and God knows what other technologies that are simply overkill. Or you might end up on Serverless or Edge runtime, where you have no clue what is going on with your API.
1
u/goodbalance Oct 24 '23
I'd add graceful shutdown and create a function that "assembles" the app so that later you can insert dependencies with less hassle. E.g. ```const create_app = () => ...```
1
u/RoyVtic Oct 24 '23
Check this will help you a lot
https://github.com/MoathShraim/Nodejs-rest-api-project-structure-Express
1
Oct 24 '23
Seeing app.use(express.json()); tabbed in more than the rest of the code makes me really uncomfortable.
1
1
u/KeyAromatic7101 Oct 24 '23
Graceful shutdown is something already given by express ? If not, it’s a good improvement
1
u/esmagik Oct 24 '23
I DoNt KNoW whAT a HaShMap Is
DiREcToRY IndeXInG Is 4 NeWbS
Your routes could all be exported / imported from the root of ‘routes’. You could also make a hashMap of {‘/path’: importedRoute} and clean up about 20 lines of this.
1
1
Oct 26 '23 edited Nov 19 '23
chief lavish cooperative innocent panicky fade carpenter theory engine attraction this post was mass deleted with www.Redact.dev
1
u/No_Cartographer_6577 Nov 04 '23
Yoooo bro.. See the app.use stuff. Import all that shi form another file. It's just high coupled BS you don't want to transfer in microservices
1
1
u/TheRealNalaLockspur Nov 20 '23
God I can't stand it with I see es modules on a backend.
If you truly understood how esm works vs requires, you would never do this.
Here come the downvotes from all the "Sr's" that were shipping clerks in 2019, got laid off because of covid, took a bootcamp, and now they've been a software engineer for 20 years...
Other than that... use express.Router, create an index, create an array of all your routes, and then loop through them and use router.use()
ie:
//mergeParams incase you have upstream router parameter's, or you'll lose them.
const router = require('express').Router({ mergeParams: true })
const routes = [
{ path: '/admin', router: require('./admin') },
{ path: '/customers', router: require('./customers') },
{ path: '/domains', router: require('./domains') },
{ path: '/billing', router: require('./billing') },
{ path: '/auth', router: require('./auth') },
]
for (let route of routes) {
router.use(route.path, route.router)
}
module.exports = router1
1
1
u/DimensionHot9669 Oct 23 '23
Honestly, for what it is, looks just fine. No worries there! :)
1
u/ArnUpNorth Oct 23 '23
Are you serious? How about serving __dirname 😱 doesnt it raise some alerts for you?
1
u/DimensionHot9669 Oct 23 '23
Depends on the setup, if he's not going with an env file, all connection to db/whatevs is in env but not as an actual file it'll be fine. Sure your code base is leaking but if it's just a little personal project nothing of value is lost. It is also highly dependant on where the entry file is placed. If for example it is app/src/index.ts then it's just the source code being served.
It's clearly a student project and what he has done is more than fine for what it is :)
1
u/ArnUpNorth Oct 24 '23
He s using a configuration file which will be leaking. If you don’t review potential security issues on school projects when someone asks for a review when will OP get the opportunity to learn?
1
0
-2
u/Reaver75x Oct 23 '23
Ts is so stupid.
1
u/prophase25 Oct 23 '23
Lol there’s no difference in this case between TypeScript and JavaScript - Application is inferred from the return type of express()
It may not be necessary here but you can’t tell me TypeScript is useless if you use JSDoc. You wouldn’t happen to use JSDoc would you?
1
u/Reaver75x Oct 23 '23
const app = express() is all you need. If I write that the way he did it would give me an error so it’s definitely not normal JS. I’m not sure why imports is even working on the backend side. I’ve always used require.
1
u/prophase25 Oct 23 '23
I am saying that OP didn’t need to write in the Application type annotation because it is inferred (in TypeScript - yes, you cannot type annotate in JS)
You need to add type: module to your package.json to use import
-3
u/Jyuber Oct 23 '23
you are using express , so keeping your api-docs up to date is impossible / hurcelean task ,
but I see that you didn't bother , so it's most likely not production code .
0
u/fibs7000 Oct 23 '23
What i dont get is why nobody uses classes or at least crate functions...
I would encapsulate the whole server in a class with a run method which first calls an initialize method.
Currently its 1. not very easy testable, 2. no possibility for dependency injection, 3. is statically defined, 4. is impossible to modularize.
I know its a pattern in js to do it like that... but I think only cause you can do it does not mean you should... there are some good oop principles that can be applied here.
0
u/LordFrz Oct 28 '23
Ha, idiot! You used, [language you used], instead of the superior, [language I use]. Fool!
-4
u/RubbelDieKatz94 Oct 23 '23
Maybe use a repo to store your code instead of taking screenshots.
Then again, I used to store my XAMPP directory in zipfiles during my apprenticeship, so ehhhh
-18
-11
-5
u/lucsoft Oct 23 '23 edited Oct 25 '23
Don’t use express it’s one of the worst libs out there in context of baseline performance
Edit: There are great alternatives that also still get actively maintained. Like here: https://github.com/denosaurs/bench
1
1
u/D10S_1 Oct 23 '23
Any benchmarks/references that support your argument? Imo otherwise this comment is rather unhelpful
255
u/ichdochnet Oct 23 '23
You are serving your server side code and quite possibly your configuration and secrets with „express.static(__dirname)“.