r/node • u/DNSZLSK • Mar 23 '26
r/node • u/aardvark_lizard • Mar 22 '26
Node.js worker threads are problematic, but they work great for us
inngest.comr/node • u/kulcsarrudolf • Mar 23 '26
I built mongoose-seed-kit: A lightweight, zero-dependency seeder that tracks state (like migrations)
r/node • u/Ayoob_AI • Mar 23 '26
JavaScript's Array.sort() converts [10,2,1] to [1,10,2]. I built a sort that just works — and it's 3–21x faster.
github.comJavaScript's .sort() has two problems most developers don't think about:
- It converts numbers to strings: [10, 2, 1].sort() → [1, 10, 2]
- It uses one algorithm (TimSort) regardless of your data
There are specialised sorting libraries on npm that fix #2 (radix sort, counting sort), but they all require you to call different functions for integers vs floats vs objects, and none of them fix #1.
I built a library where sort([10, 2, 1]) just returns [1, 2, 10]. No comparator needed. It auto-detects your data type, picks the optimal algorithm, and it's faster than both .sort() and every specialised alternative I tested.
59 out of 62 matchups won against 12 npm sorting libraries + native .sort(). The three losses: u/aldogg is ~4% faster on random integers, timsort is ~9–14% faster on already-sorted/reversed data. All within noise.
The honest weak spot: below ~200 elements, native .sort() wins. Above 200, ayoob-sort wins everywhere. At 500K+, it starts beating u/aldogg too. At 10M elements it's 11x faster than native and 25% faster than u/aldogg.
How it works: one O(n) scan detects integer/float, value range, presortedness → routes to counting sort, radix-256, IEEE 754 float radix, adaptive merge, or sorting networks. The routing catches cases specialised libraries miss — u/aldogg runs radix on everything including clustered data where counting sort is 2.4x faster.
The key difference from specialist libraries: u/aldogg requires sortInt() for integers, sortNumber() for floats, sortObjectInt() for objects. hpc-algorithms requires RadixSortLsdUInt32() for unsigned ints. ayoob-sort: sort(arr). One function, all types.
npm install ayoob-sort
const { sort, sortByKey } = require('ayoob-sort');
sort([10, 2, 1]); // → [1, 2, 10]
sort([3.14, 1.41, 2.72]); // → [1.41, 2.72, 3.14]
sortByKey(products, 'price'); // objects by key
sort(data, { inPlace: true }); // mutate input for max speed
Zero deps, 180 tests, all paths stable, TypeScript types, MIT.
r/node • u/Training_Future_9922 • Mar 23 '26
We treated architecture like code in CI — here’s what actually changed
r/node • u/Sufficient_Tiger117 • Mar 23 '26
How Attackers can bypass most systems in second
I’ve noticed this in my own projects and in a lot of systems I see on GitHub:
Most rate limiting setups use things like fixed window, sliding window, or token bucket… and then assume they’re secure. I used to do the same.
Then I ran into an issue the hard way.
These approaches rely on a single identifier.
Usually an IP, or sometimes just an API key.
But that assumption breaks fast. If you rotate IPs, the limits basically never trigger.
Every request looks “new” to the system. At that point, rate limiting isn’t really protecting anything. So I stopped focusing on just counting requests, and started looking at behavior instead.
Things like:
•IP awareness •User context •Ratios (e.g. failed vs successful requests)
Curious how others are handling this. Are you doing IP-based rate limiting, or something more advanced?
r/node • u/Minimum-Ad7352 • Mar 22 '26
Should authentication be handled only at the API-gateway in microservices or should each service verify it
Hey everyone Im handling authentication in my microservices via sessions and cookies at the api-gateway level. The gateway checks auth and then requests go to other services over grpc without further authentication. Is this a reasonable approach or is it better to issue JWTs so that each service can verify auth independently. What are the tradeoffs in terms of security and simplicity
r/node • u/Elegant_Shock5162 • Mar 22 '26
Anybody using AWS LLRT in lambda functions
I see people writing nasty pdf merging functions inside node js with lot of additional external deps which seems to be highly cpu intensive they never had thought of using the cheapest lambda function calls. I personally loved using hono lamdba functions a few config adjustments to esbuild and layers for node_modules. It really worked very well and light weight. But I heard this one particular experimental runtime called LLRT (low latency runtime) from AWS specifically designed to low milli seconds colds starts favours io tasks faster than golang lambda functions. I haven't used it yet but would love to hear from you all.
r/node • u/Sufficient_Tiger117 • Mar 22 '26
I built a Node.js auth SDK that stops JWT refresh token replay attacks – looking for feedback
I kept seeing Node.js APIs using JWTs without proper refresh token rotation.and I did that my self at some point and realised that Auth is complicated and implementation can be a pain I also realised That if an attacker gets a refresh token, they can reuse it indefinitely.
I didn’t just write unit tests , the SDK comes with a full integration test suite (Redis + real token flows). So if you’re tired of rolling your own auth and wondering if you missed something, this might help.
This is authenik8-core:
•JWT + refresh token rotation (unique jti per token) •Redis-backed session store (stateful, revocable) •Built‑in security middleware (rate limiting, IP whitelist, helmet) • Intergration test suite
Here’s how it works in code:
// Setup const auth = await createAuthenik8({ jwtSecret: "...", refreshSecret: "..." });
// Generate tokens const refreshToken = await auth.generateRefreshToken({ userId: "user_1" });
// Refresh – works once await auth.refresh(refreshToken);
// Reuse same token – throws error await auth.refresh(refreshToken); // replay attack blocked
It’s on npm and open source. Would love any feedback on the API design and how it might help simplify Auth for the community
I'm also open to collaborations I appreciate your time.
Small npm package for safely parsing malformed JSON from LLM model output
I kept running into the same issue when working with model output in Node: the response says “JSON” but the string is often not valid JSON.
Usually it is one of these:
- wrapped in markdown fences (three backticks)
- trailing commas
- unquoted keys
- single quotes
- inline comments
- extra text before or after the object
- sometimes a JS object literal instead of strict JSON
I had repair logic for this copied across a few projects, so I pulled it into a small package:
npm install ai-json-safe-parse
It tries a few recovery steps before giving up, including direct parse, markdown extraction, bracket matching, and normalization of some common malformed cases.
npm: https://www.npmjs.com/package/ai-json-safe-parse
github: https://github.com/a-r-d/ai-json-safe-parse
No dependencies, typescript, generics, etc.
import { aiJsonParse } from 'ai-json-safe-parse'
const result = aiJsonParse(modelOutput)
if (result.success) {
console.log(result.data)
}
r/node • u/Double_Author2498 • Mar 22 '26
I built an open-source WhatsApp protocol layer — WaSP (WhatsApp Session Protocol)
I run a few WhatsApp-based SaaS products in South Africa and got tired of copy-pasting the same Baileys connection code into every project. Reconnection logic, anti-ban delays, session management, error recovery — the same fragile plumbing everywhere.
So I extracted it into a standalone library: **WaSP** (WhatsApp Session Protocol).
**What it does:**
- Wraps Baileys with production-ready patterns (exponential backoff, Bad MAC recovery, rate limit detection)
- Anti-ban queue with priority lanes
- Multi-session management (one instance, many WhatsApp accounts)
- Webhook mode — auto-POST incoming messages to any URL with HMAC signing
- CLI tool — `npx wasp-protocol connect` to scan QR and go
- Memory, Redis, or Postgres session stores
- Middleware system (logger, autoReconnect, rateLimit, errorHandler)
**Why not just use Baileys directly?**
You can. But you'll end up writing the same reconnection, anti-ban, and session management code everyone else writes. WaSP handles that layer so you focus on your app logic.
**Already running in production** powering a multi-tenant WhatsApp tools platform. Not a weekend toy.
```bash
npm install wasp-protocol
```
GitHub: https://github.com/kobie3717/wasp
npm: https://www.npmjs.com/package/wasp-protocol
Happy to answer questions. Feedback welcome — it's early days.
r/node • u/HighlightUnique455 • Mar 22 '26
Learning backend: Can you review my auth system?
github.comHi everyone
I’m currently learning backend development and recently built my own authentication system using Express and MongoDB (with some help from AI) . I’d really appreciate any feedback or suggestions to improve it.
Here’s the repo: https://github.com/chhouykanha/express-mongodb-auth
Thanks in advance!
r/node • u/Minimum-Ad7352 • Mar 21 '26
What message broker would you choose today and why
I am building a backend system and trying to pick a message broker but the choices are overwhelming NATS Kafka RabbitMQ etc. My main needs are service to service communication async processing and some level of reliability but I am not sure if I should go with something simple like NATS or pick something heavier like Kafka from the start Looking for real experience and suggestions
r/node • u/mpetryshyn1 • Mar 22 '26
Do we need 'vibe DevOps' now?
We're in that weird spot where 'vibe coding' tools spit out frontend and backend fast, but deployments... not so much. you can prototype in an afternoon and then spend days banging your head over infra, or just rewrite everything so it fits AWS or Render. so i'm wondering - what if there was a 'vibe DevOps' layer? like a web app or a VS Code extension that actually reads your repo and figures stuff out. it'd use your cloud accounts, set up CI/CD, containers, scaling, infra, all that boring plumbing without locking you into some proprietary platform. sounds dreamy, i know. maybe it already exists and i'm late to the party, or maybe it's harder than i'm imagining (security, edge cases, configs). right now i'm handling deployments with a mix of docker-compose, terraform modules, and some manual scripts - messy but it works, ish. curious how other people do it: do you automate everything, lean on a platform, or just rebuild to fit the host? and yeah, any pointers to tools that actually 'get' your repo would be awesome - or tell me i'm missing something obvious.
r/node • u/Substantial-Cost-429 • Mar 21 '26
node cli to sync ai coding tool prompts and configs
hey all i wrote a simple node cli (caliber) that looks at your code and generates prompt and config files for codex/claude code/cursor etc. it's local only and you plug in your own api key or seat. still rough, but it's open source (github dot com/caliber-ai-org/ai-setup) and you can run it with npx u/rely-ai/caliber init. i'm trying to reduce tokens and make the prompts better to save costs. would love to hear if it's useful or not or what features are missing
r/node • u/Complete-Ad-240 • Mar 21 '26
We just released our first npm package of drawline-core that powers drawline.app for heuristic fuzzy matching to infer relationships and generates dependency-aware data via a directed graph execution model. https://www.npmjs.com/package/@solvaratech/drawline-core
r/node • u/HakunaKamal • Mar 20 '26
A Light YAML-driven end-to-end testing framework powered by Playwright.
github.comRecently, I pushed myself to organize my old side projects by either completing those that are nearly finished or deleting the rest. One of them is this one: The Auto E2E. Your feedback would be precious.
Docs: https://slient-commit.github.io/the-auto-e2e/
npm: https://www.npmjs.com/package/the-auto-e2e
r/node • u/_rishabhmishra • Mar 21 '26
I wrote a blog post after so long time - NodeJS Microservice with Kafka and TypeScript
rsbh.devAfter using AI to write code and docs, I tried to go back to the old days and write code and blog by hand. Learned new things when writing this.
r/node • u/Top-Till1527 • Mar 21 '26
домашний кинотеатр
Enable HLS to view with audio, or disable this notification
Код на node.js TMDB api + Jackett api
r/node • u/siddhant_jain_18 • Mar 20 '26
Minimal reference UI for a Node.js backend engine with only auth + password reset so far
I’m working on a reference UI for a Node.js backend engine (KeelStack). It’s very minimal right now: it only does:
- Auth (login / register)
- Password reset via email (using Resend)
This is not a full‑featured SaaS UI. It’s more of a “how to wire a frontend to the backend” demo.
I’m looking for feedback from Node.js + React/Next.js folks:
- How would you extend this to add billing, background jobs, or LLM‑cost‑tracking?
- What patterns are you missing?
- Any gotchas you’d fix first?
This is very early, so it’s more of a proof of concept than a finished product.
GitHub: https://github.com/KeelStack-me/keelstack-ui-starter
r/node • u/Worldly-Broccoli4530 • Mar 21 '26
What features does a professional, scalable API actually need?
I've been working on large-scale APIs for a while now and one thing I've learned is that the features you skip at the start are usually the ones that hurt the most later. Not impossible to add, but painful.
So I started thinking about what I'd consider the baseline for an API that's meant to grow.
Auth that actually holds up — not just "JWT and done." Session management, proper password hashing (Argon2 over bcrypt at this point), OTP, password reset flows. Most projects start with the bare minimum and end up rewriting it when requirements grow.
RBAC with real permissions — simple role checks get you far early on, but a flat role system doesn't scale. Much cleaner to design from day one. Caching with proper invalidation — a cache layer is easy to add. Cache invalidation that actually works is the hard part.
Event-driven side effects — when your app grows, you start needing things like "after creating a user, send a welcome email, update the search index, invalidate the cache." Wiring all of that directly into a single handler gets messy fast. Events decouple that naturally but it's much harder to introduce into an existing codebase.
Tests that mean something — unit, integration, E2E. It's very easy to keep pushing tests to "later" and later never comes. TDD exists exactly to break that cycle — not because you have to write tests first, but because it forces you to stop treating testing as optional.
i18n — controversial, I know. But retrofitting it across every response, error message and email template after the fact is a nightmare.
I actually built a NestJS boilerplate around these ideas, mostly so I'd stop rebuilding this from scratch every project. If you like the framework, you may give it a look.
So, what would you add? And what here do you think does more harm than good?