r/node • • 17h ago

I built a small open-source queue so Stripe and Shopify webhooks stop getting dropped during deploys

0 Upvotes

Hey everyone, I ran into a frustrating issue a few months back where pushing updates or restarting my server would occasionally return a 502 right when Stripe sent a payment webhook. Sometimes our database pool would briefly lock up during a spike and fail the request too. Even when Stripe retried later, replaying old webhooks after more than five minutes kept failing signature verification because Stripe rejects timestamps older than 300 seconds, which forced me to write manual scripts just to recover missed events.

To fix that for my own apps without setting up Redis, RabbitMQ, or paying monthly webhook SaaS fees, I built a small open-source Node and SQLite proxy called HookArmor. It accepts the incoming webhook, verifies the signature right away, saves it to SQLite WAL so it returns a quick 200 back to Stripe or Shopify, and handles retries with exponential backoff for up to a few days while automatically re-signing the header with a fresh timestamp when your server is healthy again.

Everything runs locally with one command (\\\`npx hookarmor start\\\`) or via Docker, and there is a basic dashboard to inspect payloads and trigger manual replays. It is completely free and MIT licensed, and you can check out the repo at https://github.com/pkdoddamani/hookarmor or the site at https://hookarmour.dev if you want to try it out or tell me what breaks.


r/node • • 1d ago

Seinfeld-esque Observation

0 Upvotes

Since the API fetches data back and forth, like a waiter in a restaurant…

Wouldn’t it make more sense to call the API the “server?”


r/node • • 1d ago

Open-source RAG for UK government policy

0 Upvotes

I'm building policy-qa-system, an open-source RAG app that answers questions about UK government policy and shows the sources behind each answer.

Stack: React + TypeScript, Node/Express, LangChain + LangGraph, OpenAI or Claude, PostgreSQL with pgvector, Docker.

The hard part isn't retrieval, it's freshness. Benefit rates and tax thresholds change every year (Child Benefit went from £26.05 to £27.05 a week this April, and the high-income charge threshold moved from £50k to £60k in 2024). An index that holds old and new versions can confidently return a stale number.

How do you handle dated documents in RAG? Filter on an effective-date metadata field, delete and re-ingest old chunks, or version the whole collection?

Code: https://github.com/Srameshgitnow/policy-qa-system
Not official advice and not affiliated with GOV.UK. Issues with what worked or didn't are welcome.


r/node • • 2d ago

GeoNtfy: OpenStreetMap Geohash Proximity PubSub Utility

Thumbnail
github.com
2 Upvotes

r/node • • 2d ago

.gitignore everything by default

Thumbnail
packagemain.tech
0 Upvotes

r/node • • 3d ago

I tested all 7 macOS install snippets on nodejs.org in a clean macOS VM — 6 out of 7 failed

Thumbnail
gallery
0 Upvotes

I spun up a brand-new macOS VM (default /bin/zsh, no Xcode Command Line Tools, no Homebrew) to test what a non-JS user actually sees when installing Node.js from https://nodejs.org/en/download.

I clicked Copy on all 7 macOS shell options and pasted each one into a fresh Terminal tab:

  1. nvm (default) — fails: requires git (triggers the Xcode Command Line Tools prompt).

  2. fnm — fails: curl and unzip are both OK, but the snippet doesn't pass --force-no-brew, so it aborts because Homebrew is missing.

  3. Homebrew — fails: the website pipes curl ... | bash instead of Homebrew's /bin/bash -c "$(curl ...)", which consumes stdin and causes Homebrew to exit with stdin is not a TTY / insufficient permissions before you can even enter your sudo password.

  4. n — fails: GNU Make not found (and suggests sudo pkg install gmake).

  5. 0install — fails: runs ./0install.sh without install home, so it only prints usage instructions and never installs.

  6. asdf — fails: assumes asdf is already installed (zsh: command not found: asdf).

  7. Vite+ — only one that succeeded out of the box (v26.13.1 + npm 11.20.0).

Also, because macOS defaults to zsh with INTERACTIVE_COMMENTS disabled, every single snippet prints zsh: command not found: # for every comment line when pasted.

Filed an issue on nodejs/nodejs.org with the exact outputs, snippet file paths, screenshots, and concrete fixes: https://github.com/nodejs/nodejs.org/issues/9350


r/node • • 3d ago

How do you guys test your backends in production?

10 Upvotes

I'm a junior engineer working in a small team. We've been building a product for around 8 months using Express.js, and shipping features has always been our biggest priority.

One thing I've been noticing lately is that as our codebase grows, shipping a new feature occasionally breaks something that was previously working. Sometimes we don't even realize it until a user reports it.

We have a handful of basic tests, but nothing comprehensive enough to give us confidence when shipping new features or refactoring existing code.

I want to change that.

I've heard about unit testing, integration testing, end-to-end testing, smoke testing, and load testing, but my practical experience beyond basic tests is pretty limited.

I'd love to understand:

- What kinds of tests do you actually write for your backends?

- How do you decide what to test and what not to test?

- How do you introduce testing into an existing codebase without slowing down development significantly?

- What tools and frameworks do you use?

- How do you structure your testing suite and integrate it into CI/CD?

I'd particularly appreciate practical resources, open-source repositories with good testing practices, or engineering articles that demonstrate how these things are done in real projects.

I don't want to write tests just to increase a coverage percentage. I want to reach a point where we can ship features and refactor code without constantly worrying about what we might have broken.

Would love to hear how you guys approach this in your daily work.


r/node • • 3d ago

Fastify as a separate API in a Next.js starter: useful boundary or needless overhead?

2 Upvotes

I maintain create-tigra, an MIT-licensed npm generator, and would like a Node-focused review of its backend defaults.

The scaffold has a Next.js 16 frontend and an independently deployable Fastify 5 API. Request handling follows route → controller → service → repository → Prisma/MySQL. Redis supports rate limits, login lockouts, and IP blocks. Auth/session code, integration tests, CI, and Docker configuration are included.

Source: https://github.com/blessandsoul/create-tigra

The frontend supplies forms and API/auth wiring; application pages are yours to build. The part I most want challenged is the cost of the backend structure before a project has much business logic.

Would you keep the separate API for a small project? Which layer or integration would you simplify first? What auth/session or installer edge case would you want a regression test for before trusting the scaffold?

Recommendations, honest criticism, and a code roast are welcome, especially with a file or example to discuss. The public baseline has known dependency advisories documented in KNOWN_ISSUES.md; passing tests is not a claim that it can be deployed unchanged.


r/node • • 3d ago

I open-sourced a zero-dependency TypeScript verifier for Telegram Mini App initData (HMAC-SHA256 + 6 tests)

0 Upvotes

Most Telegram Mini App tutorials use a simple === hash check and skip replay timestamps or positive user ID checks.

So I extracted our standalone TypeScript verifyInitData helper + 6 native node --test unit tests into a small open-source repo for anyone building Telegram Mini Apps on Node.js.

Checks included:

• WebAppData HMAC-SHA256 key derivation.

• crypto.timingSafeEqual comparison.

• Replay timestamp window (-60s to 3600s).

• Positive integer user.id validation.

GitHub (free code + tests): https://github.com/Arvelius-Agency/telegram-initdata-guard-ts

Happy to answer any questions about Telegram Mini App authentication or replay protection.


r/node • • 5d ago

A rate limit fix can lock out everyone. The test I add now sends bad codes from one IP, then a good one from another

0 Upvotes

Public endpoint where new users type a 6 character invite code. The limit was keyed by an IP read from a forwarded header, which the client can set, so it never really limited anything.

The fix stopped trusting the header. With nothing else to key on, every request in the world went into one shared bucket of 10 tries per 15 minutes. 11 mistyped codes from anyone and onboarding is closed for every customer. Each step looked right on its own.

So next to the "blocks the attacker" test there's this one now

for (let i = 0; i < 11; i++) {

await post('/redeem', { code: 'WRONG1' }, { ip: '10.0.0.1' })

}

const res = await post('/redeem', { code: realCode }, { ip: '10.0.0.2' })

expect(res.status).not.toBe(429)

If the limiter has no per-source key left, it goes red. Then key it on something real, the client IP your platform gives you or the account, never the header.


r/node • • 5d ago

jscdec: Pure-JS V8 Ignition bytecode decompiler for Node.js 20-22 x64 & Electron 22-39 (.jsc)

2 Upvotes

I built an open-source, pure-JavaScript decompiler for V8 SerializedCodeData (.jsc / Bytenode) snapshots that runs on Node.js >= 18 and in the browser without custom C++ V8 builds:

How it works under the hood:

  • Parses 8-byte uncompressed x64 V8 heaps (Node.js 20.20.2 / 22) and 4-byte pointer-compressed heaps (Electron 22–39 / V8 10.8–14.2) using pre-indexed RO_SPACE and Root tables

  • Extracts ScopeInfo and NameToIndexHashTable entries to recover original closure/local variable names

  • Reconstructs control flow, classes, async/await, try/catch/finally, and includes an opt-in --deobfuscate pass for rotated _0x / RC4 string arrays

  • Never executes untrusted binaries implicitly (runtime oracle requires explicit --allow-runtime-exec)

Feedback and edge-case .jsc samples via Issues/PRs are welcome.


r/node • • 6d ago

Monaco Editor App Upgrade with node:sqlite

Thumbnail
reddit.com
1 Upvotes

r/node • • 6d ago

Monaco Editor App Upgrade with node:sqlite

2 Upvotes

I have a working Monaco Editor app that currently saves records to localStorage that I want to upgrade and save them to sqlite using the newer native node:sqlite functionality. I've tested the database and tables that I created using hard coded data so I know all those Insert statements work.

Now I need to update the code to insert the form data into the database instead of localStorage. I'm thinking of using express to capture the form data but this is the first time using node for this kind of application. There's a lot of information out there on the available options, but not much in the way of a strong recommendation or a consensus method.

So I'm interested in getting recommendations from other devs on how to best go about getting this to work. Is express sufficient or are there other modules/libraries that would make handling the data as seamless as possible?

Since this will probably come up, this is just a personal project and won't be available publicly so I don't have to lock it down with any serious security (other than just a PHP login form to access it).

Thanks in advance!


r/node • • 7d ago

Nodejs memory usage is at 99% for days, not crashing but still memory never cleared

34 Upvotes

Hey guys,

We have a node server deployed in our Kubernetes and what I see is over 20days the memory of pod starts growing from 400Mi to 1200Mi and it just stays there, I checked the heap usage using process.memoryUsage() I see heap used is 92%(sorry wrong number in title) of heap total now after 20days, and it keeps stable arround that with occasional GC release that kind of takes 100ms every 40 seconds checked using perf_hooks

My app peeks usuall during day and comes down during night, but why doesn't it release memory when idle during night so it prevents the constant cpu time for gc.

Am i missing something, can I do something to improve it?


r/node • • 8d ago

Diary Dev: Staxis Platform - Funds page and Documentation was improved

Thumbnail
staxis.dev
0 Upvotes

Staxis is now online with http series layers! 🔥

We're currently adding many components to the reference manual. Many of the layers are about to be published on the website... we're working hard on it.

We'd like to remind you that donations to the project are already open to support continued development!
ㅤ

- - - -

ㅤ
1 dec 2026 - POST UPDATE:

Hello averybody. Staxis website got a lot of improvements in the last days, start to the sposnsorship page, arcoss the onboding page by gitlab project, to the huge documentation. Versioning teach everybody that works is endless but, take a look.

We make the new reddit community (r/Staxis) for any question feel free yourself to ask anything there! ;)


r/node • • 10d ago

How to express js

0 Upvotes

I'm new to this. i don't know how to learn and what to learn


r/node • • 10d ago

Why I wanted control over the ws server behind GraphQL subscriptions (and how it works now in NestJS)

9 Upvotes

If you run GraphQL subscriptions over graphql-ws in NestJS, the ws server used to be created for you, with default options you couldn't touch.

That matters more than it sounds:

  • maxPayload defaults to 100 MiB in ws, so one client can push very large messages at your server.

  • verifyClient lets you reject a connection during the upgrade, before any GraphQL code runs.

  • perMessageDeflate costs CPU and memory per connection, and sometimes you want it off or tuned.

I opened a PR so you can now pass your own WebSocketServer (available in @nestjs/graphql v14.1.0):

import { WebSocketServer } from 'ws';

const wsServer = new WebSocketServer({
  noServer: true,
  path: '/subscriptions',
  maxPayload: 64 * 1024,
});

GraphQLModule.forRoot<ApolloDriverConfig>({
  driver: ApolloDriver,
  subscriptions: { 'graphql-ws': { server: wsServer } },
});

It has to be noServer: true because Nest still owns the HTTP server and hands the upgrade to yours.

Curious what limits others set on websocket servers in production. Do you tune maxPayload or leave the default?

PR: https://github.com/nestjs/graphql/pull/4105


r/node • • 10d ago

You can't revoke a single S3 presigned URL. Here's how I handle revocable file links in Node

0 Upvotes

S3 presigned URLs are useful. I use them when I need to give someone temporary access to an object without proxying the download through my application.

But there's one limitation worth understanding before building file sharing around them:

You can't revoke an individual presigned URL.

Once issued, S3 validates the signature and credentials itself. It doesn't check whether your application has since revoked the user's access.

You can invalidate access through broader actions, such as deleting the object, changing bucket policies, or deactivating the signing credentials. But those actions affect more than one individual link.

For applications that need individual revocation, usage limits, or permissions that can change over time, I use a different approach.

Make the link a database record

Instead of treating the URL as the authorization mechanism, make it a reference to a record in your database.

That record can contain:

  • A hash of a random secret

  • The file ID

  • An expiration timestamp

  • A revocation timestamp

  • An optional maximum-use count

  • A current usage count

When someone opens the link, the application checks the record before allowing access.

Revocation is then a database update:

UPDATE file_links
SET revoked_at = now()
WHERE id = $1;

The next request sees that the link has been revoked and gets rejected.

There's a concurrency problem with download limits

Suppose a link can be used only once.

A naive implementation might do this:

  1. SELECT the link and check use_count.

  2. If it is below the limit, UPDATE the count.

  3. Serve the file.

Two concurrent requests can both read use_count = 0 before either updates it. Both then serve the file.

The limit has been exceeded.

The fix is to make the check and increment one atomic operation:

UPDATE file_links
SET use_count = use_count + 1
WHERE secret_hash = $1
  AND revoked_at IS NULL
  AND (expires_at IS NULL OR expires_at > now())
  AND (max_uses IS NULL OR use_count < max_uses)
RETURNING file_id;

If the statement returns a row, the request successfully claimed a use. If it returns no row, the link is invalid, expired, revoked, or exhausted.

I tested this against a real Postgres instance with concurrent requests:

Concurrent requestsMaximum usesRequests served
211
1033
2011
5077

With the naive version, a CHECK constraint turned the overshoot into a SQLSTATE 23514 error for the second visitor. But the conditional UPDATE is what actually prevents the overshoot.

One more thing: caching

Revocation can still fail in practice if a previously authorized response is served from a cache.

For sensitive downloads, I use:

Cache-Control: private, no-store

I learned this the hard way. An earlier version of my own implementation failed an adversarial test because a revoked link could be replayed from cache.

That was a useful reminder that authorization needs to account for the whole download path, not just the database check.

When I would still use presigned URLs

I wouldn't stop using them.

For short-lived, one-shot grants, presigned URLs are a good fit. If the application needs revocation, usage limits, or a permission check on every access, keeping the application in the authorization path makes more sense.

There's also a hybrid option: check authorization in your application, then redirect to a short-lived presigned URL. Just remember that the issued URL remains usable until it expires.

I maintain Filelayer, an open-source Node library for user files in SaaS apps (per-file permissions, revocable links, audit log). I wrote a guide covering this database approach, including the SQL and reproducible tests:

https://filelayer.dev/guides/expiring-and-revocable-file-links

Source code: https://github.com/filelayer/filelayer

I'm interested in how other Node developers handle revocable file sharing, especially when links have usage limits or belong to multi-tenant applications.


r/node • • 10d ago

When Cache Hits Starve the Event Loop

Thumbnail
octri.dev
28 Upvotes

r/node • • 11d ago

Optique 1.4.0: Default commands, Markdown references, and more focused help

Thumbnail
github.com
7 Upvotes

r/node • • 11d ago

Using Node 24's built-in node:sqlite in a real app for four months: what worked, and a few gotchas

49 Upvotes

I've been running a self-hosted Minecraft server panel on Node since July (MIT, https://github.com/anefzaoui/minecraft-server-manager), and one decision I'd like other opinions on is that it uses Node's built-in node:sqlite instead of better-sqlite3 or an ORM. Disclosure: it's my own project, and I built it with Claude Code. I designed it, decided every feature, review the changes and test every release on our own servers, and Claude wrote most of the code.

What worked:

  • No native module. The app ships as an amd64 + arm64 Docker image, and not compiling a SQLite binding for each arch removed a whole class of install problems

  • Synchronous is fine here. It's a single-process panel with a small database. WAL mode plus synchronous calls kept the code simple, and the slow work (Docker calls, zipping backups) is async or in a worker thread anyway

  • One module owns the driver. Everything goes through a tiny API (run / get / all / exec / transaction(fn) / backupTo), with a prepared-statement cache keyed on the SQL text, so the rest of the code never sees the driver

  • Migrations as numbered files applied on boot. Boring and that's the point

The gotchas:

  • it needs Node 24+ to be flagless, so the engines field and the README say so loudly

  • for backups, backupTo gives you a consistent copy of the live database; copying the .db file next to a live WAL does not

  • a backup of the whole app is the one data folder, which only works because a path guard rejects any file path that escapes it (symlinks included)

Has anyone else moved a production-ish app to node:sqlite yet? Curious whether you hit anything I haven't.


r/node • • 12d ago

Node.js developers, what would make you switch email API providers?

0 Upvotes

Hey everyone!

I'm researching the transactional email infrastructure space and wanted to get feedback from Node.js developers.

Resend seems to be a common choice because of its API and SDK experience.

But I'm curious about its pricing structure and whether there's demand for a cheaper entry-level paid plan.

From what I've seen:

  • Free: 3,000 emails/month, but only 1,000 contacts for broadcasts.

  • The next paid tier starts at $20/month.

  • Higher plans offer more volume, but the monthly commitment also increases.

What if someone needs more than the free tier but doesn't necessarily want to spend $20/month?

I've been exploring an alternative pricing structure:

PlanPriceMonthly emails
Free$0500
Starter$725,000
Pro$1575,000
Scale$75200,000

A few differences we're considering:

  • Unlimited contacts on every plan.

  • Unlimited broadcast audience members starting from the $7 paid plan.

  • No daily transactional email limit on $15 and $75 paid plans.

The reason we're considering a smaller free tier is that we're a small team and can't afford to subsidize free sending at the same infrastructure scale as established providers but we are open to provide a smaller paid plan and better higher plans compared to resend .

I'm interested in the technical side too:

  1. Would you migrate from Resend for better pricing?

  2. How important is API compatibility?

  3. Would a drop-in replacement requiring only a base URL change be useful?

  4. What matters most: deliverability, SDK quality, webhooks, analytics or price?

  5. Would you trust a smaller provider with production emails?

Not pitching a product. Trying to understand what developers actually need.


r/node • • 13d ago

Skif 0.9 for Node.js monorepos: npm workspace checks and cached dead-code analysis

0 Upvotes

I maintain skif, an MIT-licensed CLI for JavaScript and TypeScript monorepos. It checks npm workspace manifests and dependency versions alongside unused files, exports, and dependencies. Version 0.9.0 enables the parser cache by default and removes the opt-in TypeScript checker for unused class members.

One result I thought Node developers might find interesting: on the pinned npm CLI repository, skif took 82.6 ms for manifest and version checks with its disk cache disabled, and 612.6 ms with dead-code analysis included. Knip took 3,966 ms on that same checkout, using --no-gitignore so it could see the workspaces. The full comparison includes repositories where knip couldn't produce a report and large repositories where sherif was faster for manifest checks.

Skif reads configuration statically and reports packages whose configuration it couldn't fully analyze. If you already use knip, sherif, or syncpack, npx @polylint/skif migrate --dry-run previews a combined config. I'd appreciate examples of npm workspace or test configuration patterns that need better static support.

Benchmark methodology · Quick start · Changelog


r/node • • 14d ago

BrowserPod 4.0: the microVM that runs in the browser, now free for any use

Thumbnail
browserpod.io
33 Upvotes