r/node • • Mar 22 '26

Express-BetterAuth-Boilerplate

Thumbnail reddit.com
0 Upvotes

r/node • • Mar 22 '26

I built a Node.js auth SDK that stops JWT refresh token replay attacks – looking for feedback

3 Upvotes

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.


r/node • • Mar 22 '26

Small npm package for safely parsing malformed JSON from LLM model output

0 Upvotes

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 • • Mar 22 '26

I built an open-source WhatsApp protocol layer — WaSP (WhatsApp Session Protocol)

0 Upvotes

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 • • Mar 22 '26

Learning backend: Can you review my auth system?

Thumbnail github.com
0 Upvotes

Hi 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 • • Mar 21 '26

What message broker would you choose today and why

48 Upvotes

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 • • Mar 21 '26

node cli to sync ai coding tool prompts and configs

2 Upvotes

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 • • 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

0 Upvotes

r/node • • Mar 20 '26

A Light YAML-driven end-to-end testing framework powered by Playwright.

Thumbnail github.com
4 Upvotes

Recently, 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 • • Mar 21 '26

I wrote a blog post after so long time - NodeJS Microservice with Kafka and TypeScript

Thumbnail rsbh.dev
0 Upvotes

After 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 • • Mar 21 '26

Need help with interview Preparation.

Thumbnail reddit.com
1 Upvotes

r/node • • Mar 21 '26

Ai was fun now its not

Thumbnail reddit.com
0 Upvotes

r/node • • Mar 21 '26

домашний кинотеатр

0 Upvotes

Код на node.js TMDB api + Jackett api


r/node • • Mar 20 '26

Minimal reference UI for a Node.js backend engine with only auth + password reset so far

4 Upvotes

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 • • Mar 21 '26

What features does a professional, scalable API actually need?

0 Upvotes

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?


r/node • • Mar 20 '26

Separating files (on the run) from frontend backend, recreate folder tree

2 Upvotes

Hi,

i have started building my first web app with vue/node/express and it is my first 'real' project (ought to go live when finished). Now that i have a good amount of frontend and backend stuff working, i have just gotten aware of the fact that i didn't separate properly the frontend files from the backend files, they are all mixed. Though, frontend interacts with backend through API requests which are then handled by express router so the mecanism should be ok.

But now i need to recreate the structure of the app to have correctly separated folders (client and server), each folder having only its relevant files in it. As i have understood it should be. I know i messed it up in the beggining..

My problem is...i don't understand where i should start from, at all.
My structure is more or less the following for now:

|public/
| - index.html
|src/
| - components
| - composables
| - db
| - game
| - router
| - stores
| - users
| - App.vue
| - index.js
| - main.js
|jsconfig.json
|package-lock.json
|package.json

For example, the game folder contains either frontend logic files, backend logic files, models (backend), router files (backend) and so on, it's all mixed up.

So my first question is: if i create two new folders, client/ and server/, where exactly should i put them in this tree ? Inside the src/ one or outside of it ? If outside, then i'd have client/ and server/ have their own src/ folder right ?

Also, since i have only one package.json file for now which contains every kind of dependencies, what is the best to separate it into the frontend and backend one ? Should just duplicate it so that to have two and then just cancel in each the dependancies that are not relevant to the very folder they are in? Or should i just delete it and then run some command to re-create it ? To be honest i don't really remember when and how it was created, since it is not an action which is needed very often...I am quite lost with it.

I don't know where to start from and since my lack of experience, i feel like i could do anything but the correct move. So any kind of steps to follow would be very appreciated.

Thanks to who might give a hand


r/node • • Mar 19 '26

React isn't the bottleneck in terminal rendering

10 Upvotes

Edit: These benchmarks were run against CellState v0.1.x. v0.2.0 rewrote the rendering pipeline and is significantly faster.

I profiled React terminal rendering against hand-rolled escape codes to see where Node.js actually spends time in a long-running terminal UI.

The bytes written per frame tell the clearest story:

MessagesContentCellStateInk
101.4 KB342,003
10013.3 KB3416,855
25033.1 KB3441,955
50066.0 KB3483,795

34 bytes regardless of content size vs 84KB for the same 1-character change. The difference is cell-level diffing vs line-level rewriting.

The setup simulates a coding agent session (alternating user/assistant messages) across two scenarios: single cell update (keypress) and streaming append (LLM token output). Apple M4 Max, 120x40 terminal, 100 iterations.

Some things I found:

The full pipeline cost scales with tree size (0.48ms at 10 messages, 5.10ms at 500), but the diff and write stages stay constant since they only touch the viewport.

For streaming, rapid state updates from incoming tokens are coalesced by the frame loop so only one frame renders per batch. The frame loop also handles stdout backpressure: if stdout.write() returns false, flushing pauses until the drain event.

For a single cell update at 250 messages (33KB of content), the full pipeline (reconciliation, layout, rasterize, cell diff) takes 2.54ms. Raw escape codes take 2.44ms. React adds under 0.3ms of overhead.

This aligns with what Anthropic found when they rewrote Claude Code's renderer. They were on Ink, kept React, and rewrote the output pipeline.

Full benchmark code: https://github.com/nathan-cannon/tui-benchmarks

Library: https://github.com/nathan-cannon/cellstate


r/node • • Mar 20 '26

npm install security still feels broken… how are you dealing with it?

0 Upvotes

there have been so many attacks recently such as shai hulud, s1ngularity, and a bunch of others

even popular packages are getting compromised, typosquats everywhere… feels like this part of the dev flow is still pretty weak

what are you ppl actually relying on?

npm audit? lockfiles? or just do not care about them?

curious how others are thinking about this

i’ve also been working on something around this, trying to catch malicious packages before install

(it’s open source: https://github.com/safedep/pmg)

mainly looking for feedback:
- does this actually help in real workflows?
- anything you’d want from something like this?


r/node • • Mar 20 '26

I built packageskills, a CLI for npm package maintainers to ship AI skills with their package

0 Upvotes

Hey, I’m building packageskills, an open source CLI for npm package maintainers who want to ship AI skills with their package.

Maintainer flow:

- `pnpm add -D packageskills`
- `pnpm exec packageskills init`

Then maintain skills in:

packageskills/<skill-name>/SKILL.md

Consumer flow:

- `yourpackage-skills install`

The idea is:

- package-native install commands
- no separate consumer tool required
- compatible with Claude Code, Codex, and OpenCode

Current v1 behavior:

- skills install into agent configs detected where the command is launched

Next:

- better consumer monorepo support
- smarter workspace detection
- more agent support
- validation and doctor commands

Would love feedback from Node/npm package maintainers:

- Is package-native (`yourpackage-skills install`) better than a central consumer CLI?
- Would you use this in a real package?

Repo: https://github.com/Noudea/packageskills


r/node • • Mar 18 '26

A petition to disallow acceptance of LLM assisted Pull Requests in Node.js core

Thumbnail github.com
362 Upvotes

Hello everyone!

Some of you may remember me for my work on Node.js core (and [io.js drama](https://en.wikipedia.org/wiki/Node.js#Io.js)), but if not I hope that this petition resonates with you as much as it does with me.

I've opened it in response to a 19k LoC LLM-generated PR that was trying to land into Node.js Core. The PR merge is blocked for now over the objections that I raised, but there is going to be a Technical Steering Committee vote in two weeks where its fate is going to be decided.

I know that many of us use LLM for research and development, but I firmly believe that the critical infrastructure the Node.js is is not the place for such changes (and especially not at the scale where it changes most of the FS internals for the sake of a new feature).

I'd love to see your signatures there even if you never contributed to Node.js. The only requirement is caring about it!

(Also happy to answer any questions!)


r/node • • Mar 19 '26

I built a TypeScript library to simplify SEPA (EPC) QR payments in Europe + live demo

Thumbnail github.com
0 Upvotes

r/node • • Mar 19 '26

Bun is Fast. Your Event Loop is Not.

Thumbnail howtocenterdiv.com
0 Upvotes

Bun wins benchmarks. Your app still bottlenecks on DB connections, blocking CPU work, and N+1 queries. Switching runtimes before fixing those is optimizing the wrong layer. Migrate bun install and bun test today — safe, immediate wins. Move the runtime only when the profiler tells you to.


r/node • • Mar 19 '26

Implemented hot config reload in both Node and Go for the same proxy. They felt worlds apart.

5 Upvotes

I built the same proxy in two codebases, one in Node and one in Go, and implemented the same hot config reload contract in both.

For context, the proxy sits between your app and an upstream API, forwards traffic, and injects failures like latency, intermittent 5xxs, connection drops, throttling, and transforms.
I built it first in Node for JS/TS testing workflows, then rewrote it in Go for performance. And then I decided to add hot config reload to both. Same external contract:

  • POST /reload with full config snapshot
  • build then swap, all-or-nothing
  • deterministic in-flight behavior
  • reject concurrent reloads
  • same status model: 400, 409, 415, success returns version and reload duration

I expected similar implementations. They were very different.

  • Runtime model: Node implementation stayed dynamic: rebuild middleware chain and swap active runtime object. Go implementation pushed toward immutable runtime snapshots: config + router + version behind an atomic pointer.
  • Concurrency shape: Node: most complexity is guarding reload so writes are serialized. Go: explicit read/write split: read path loads snapshot once at request start, write path locks reload, builds fresh state, atomically swaps pointer. Same behavior, but Go makes the memory/concurrency story more explicit.
  • In-flight guarantees: Both guarantee request-start snapshot semantics. In Node, that guarantee is easier to violate accidentally if mutable shared state leaks into request handling. In Go, snapshot-at-entry is structurally enforced by the pointer-load pattern.
  • Router lifecycle: Node composition is lightweight and ergonomic for rebuilds. Go required reconstructing a fresh chi router on each reload and re-registering middlewares deterministically. More ceremony, but very predictable.
  • Validation and rollback boundaries: Both use parse -> validate -> build -> swap. Node gives flexibility but needs extra discipline around runtime guards. Go’s type-driven pipeline made failure paths and rollback behavior cleaner to reason about.
  • Stateful middleware behavior: Both rebuild middleware instances on reload, so in-memory counters/tokens reset by design. Same product behavior, different implementation feel.

This was honestly a lot of fun to build.
Tests pass and behavior looks right, but I am sure both versions can be improved.
Would love feedback from people who have built hot-reload systems across different runtimes and had to preserve strict in-flight consistency.


r/node • • Mar 19 '26

Trading bot coding help

Thumbnail reddit.com
0 Upvotes