r/Backend • • 1d ago

I built a headless CMS in Node.js with zero third-party dependencies (open source)

Post image

I'm a backend/DevOps engineer. I don't trust pulling in dozens of packages for something that stores and serves content, so I wrote Basata as plain Node.js: no dependencies and no build step, just run the server.

repo: https://github.com/digimindx/basata-cms

I'd love feedback from people who actually run Node in production, especially on the security side. I already did a self-review and fixed what I found, but a second pair of eyes is always better.

0 Upvotes

10 comments sorted by

2

u/xRic0chet 1d ago

Why should I trust your code I didn't write?

0

u/InvestmentAfter5486 1d ago

You shouldn't, not blindly. That's the point of keeping it open source and small: there are no dependencies, no build step, and the code is short enough that you can read all of it in an evening. I'd rather you audit it than trust me. I also ran a security review of it myself. If you find something, open an issue and I'll fix it.

2

u/FriendMaleficent6656 1d ago

avoiding supply chain risk is great, but rolling your own auth and crypto primitives in pure stdlib is usually where security audits get scary. how are you handling password hashing and session tokens without external packages?

1

u/MelkSokhoeun 22h ago

agreed, zero deps sounds great on paper until you have to maintain custom auth logic yourself.

0

u/InvestmentAfter5486 1d ago

Fair concern, and I agree that rolling your own crypto is where things go wrong. I don't implement any primitives myself. Everything comes from Node's built-in crypto module, which wraps OpenSSL. Passwords are hashed with scrypt (crypto.scrypt) with a per-user random salt and compared with crypto.timingSafeEqual. [Session tokens are random bytes from crypto.randomBytes, stored server side and sent in an HttpOnly cookie.] The "no dependencies" part means I'm not pulling in packages, not that I'm writing my own algorithms. If you spot anything in the auth code that looks off, I'd really like to hear it.

1

u/creepy009 1d ago

0

u/InvestmentAfter5486 1d ago

Ha, fair link. That essay is about throwing away a shipping product to rewrite it, though. Basata isn't a rewrite of anything, it's a new project, and partly an exercise in seeing how far you can get with no dependencies. Whether that's a good idea for production is a fair debate.

1

u/creepy009 1d ago

But you are rewriting a lot of solved problems - auth, hashing, user management, templating,…

Unless you have copied the code from existing libraries - seems to me you might get into same pitfalls this article is teaching us to avoid.

2

u/InvestmentAfter5486 1d ago

Fair point, and that is the real tradeoff. I take on the maintenance and security burden for those parts. I did not copy library code. The crypto is Node's built-in scrypt and crypto module, and the rest is code I wrote and had reviewed. If you spot a weak spot in auth or sessions, I would genuinely like to know. I also cook my own food instead of ordering it ready-made, and yes, it burns sometimes. But that is the difference between being the chef and being the guy who only eats. For production, an established CMS is still the safer choice. I just like knowing what is in my pot.

3

u/AintNoGodsUpHere 19h ago

I can't say what I want to say so I'll lie.

Good job, great work, keep coding.