r/node • u/Realto619 • 19h ago
r/node • u/Realto619 • 19h ago
Monaco Editor App Upgrade with node:sqlite
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 • u/Aggravating_Yak_1170 • 1d ago
Nodejs memory usage is at 99% for days, not crashing but still memory never cleared
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 • u/theGlitchedSide • 2d ago
Diary Dev: Staxis Platform - Funds page and Documentation was improved
staxis.devStaxis 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!
Take a look: https://staxis.dev/docs/index.html
Do you like it? Feel yourself to text something :)
r/node • u/wasay-inc • 4d ago
Why I wanted control over the ws server behind GraphQL subscriptions (and how it works now in NestJS)
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:
maxPayloaddefaults to 100 MiB inws, so one client can push very large messages at your server.verifyClientlets you reject a connection during the upgrade, before any GraphQL code runs.perMessageDeflatecosts 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 • u/Muted_Cat_5748 • 4d ago
How to express js
I'm new to this. i don't know how to learn and what to learn
r/node • u/jorgeurios • 4d ago
You can't revoke a single S3 presigned URL. Here's how I handle revocable file links in Node
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:
- SELECT the link and check
use_count. - If it is below the limit, UPDATE the count.
- 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 requests | Maximum uses | Requests served |
|---|---|---|
| 2 | 1 | 1 |
| 10 | 3 | 3 |
| 20 | 1 | 1 |
| 50 | 7 | 7 |
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-storeI 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 • u/Nefzaoui • 6d ago
Using Node 24's built-in node:sqlite in a real app for four months: what worked, and a few gotchas
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
enginesfield and the README say so loudly - for backups,
backupTogives 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 • u/hongminhee • 5d ago
Optique 1.4.0: Default commands, Markdown references, and more focused help
github.comr/node • u/Sudhanshub27 • 6d ago
Node.js developers, what would make you switch email API providers?
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:
| Plan | Price | Monthly emails |
|---|---|---|
| Free | $0 | 500 |
| Starter | $7 | 25,000 |
| Pro | $15 | 75,000 |
| Scale | $75 | 200,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:
- Would you migrate from Resend for better pricing?
- How important is API compatibility?
- Would a drop-in replacement requiring only a base URL change be useful?
- What matters most: deliverability, SDK quality, webhooks, analytics or price?
- Would you trust a smaller provider with production emails?
Not pitching a product. Trying to understand what developers actually need.
r/node • u/der_gopher • 9d ago
The future of Software Engineering is boring
packagemain.techr/node • u/Goldziher • 7d ago
Skif 0.9 for Node.js monorepos: npm workspace checks and cached dead-code analysis
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.
r/node • u/vilgefortz91 • 9d ago
BrowserPod 4.0: the microVM that runs in the browser, now free for any use
browserpod.ioBlocking requests to private IPs from inside the DNS lookup in Node
I build an email API where users register webhook URLs and agents can call HTTP tools, so the server makes requests to URLs it doesn't control. Checking the hostname before the request only catches IP literals and names like localhost. A hostname can resolve to a public address when you check it and to 127.0.0.1 or 169.254.169.254 when the socket actually connects.
So outbound requests go through node:https with a custom lookup function. It calls dns.lookup with the options Node passes in, and if any returned address falls in a net.BlockList of private, loopback, link-local, CGNAT or IPv6 unique-local ranges, the connection fails. IPv4-mapped addresses like ::ffff:10.0.0.1 are unwrapped and checked against the IPv4 list too.
https.request doesn't follow redirects, so a 3xx pointing at an internal address is never followed by accident. The HTTP tool follows up to 4 redirects itself, checks each Location again, and drops every header except content-type, accept and user-agent when the redirect changes origin. I used node:https rather than a library so the guard has no extra dependency.
If you've done the same thing with undici, did you put the check in a custom connect function or somewhere else?
r/node • u/theGlitchedSide • 10d ago
Diary Dev - Staxis is coming!
staxis.devStaxis is coming. The first preview of the website is live. Staxis is a modular toolkit for Node.js. Start with the free Core, assemble your stack with Layers Packs, or build your own layers.
We’re getting the first pages of the official documentation ready as we work toward the Kickstarter campaign and the 1.0 release. If you’d like to help us get there, you can already support or sponsor the project.
Take a look → https://staxis.dev
I built a typed router on top of Hono + zod-openapi
Hi all, I love Hono and everything it has to offer. Its type safety, performance, and syntax is beautiful. However, I felt it had some areas that it was lacking as far as how it would fit inside enterprise-level software.
Due to this, our team created `hono-typed-router.` It is a thin layer on top of `hono` \+ `zod-openapi` that focuses on fixing one issue: **inheritance** and **context.**
With \`hono-typed-router\`, everything is based around inheritance and context. You always define child routes off a parent's type definition. The parent's middleware, bindings, etc. are always available in the child. Its syntax and usage also promote directory structures that simulate route structures (*think file-based routing*). It was also created to work as closely as possible to native Hono, so you can still leverage the full power of the web server.
**It’s also built around OpenAPI.** Every route is a `hono`, `zod-openapi` route, so you get a full spec for free, and the library works to keep that spec honest:
* Path params are inferred from the inherited path, so they’re typed, validated, and documented without re-declaring them at each level.
* Shared responses (401/403/422), security, and tags live in `routeDefaults` and merge into every route.
* Error handlers are type-checked against the route’s declared responses. Return a 409 you didn’t document, and it won’t compile.
* Scope checks are driven by each route’s `security` field, so the docs and the enforcement can’t disagree.
It also catches things Hono silently accepts: a `/:id` router shadowing a `/stats` sibling, duplicate routes, or a child mounted somewhere that skips its parent’s auth middleware. All of these throw at startup.
And it’s cheap: we measured about 2% type-checking overhead over plain zod-openapi, enforced by a type budget in CI.
We've had a great time using it over the past year or so and we'd love to share it with you all. Hopefully you find it useful.
Repository: [https://github.com/cristianhg2/hono-typed-router](https://github.com/cristianhg2/hono-typed-router)
Here is an example usage:
import { z } from 'zod';
import { testClient } from 'hono/testing';
import {
createRouter, defineChildContext, defineRootContext, handle,
jsonRequest, jsonResponse, matchErrors, mountRouter,
} from 'hono-typed-router';
import { createScopeMiddleware } from 'hono-typed-router/scopes';
const Project = z.object({ id: z.string(), name: z.string() });
const ErrorBody = z.object({ message: z.string() });
// 1. Root context: every route below gets a typed `c.var.session`
const api = defineRootContext('/api').middleware<{ session: Session }>(async (c, next) => {
c.set('session', await readSession(c.req.header('authorization')));
await next();
});
// 2. Children inherit the path AND the vars. `.bind()` loads the org or 404s.
const org = defineChildContext(api, '/orgs/:orgId').bind('org', 'orgId', (id, c) =>
findOrg(id, c.var.session.userId),
);
const projects = defineChildContext(org, '/projects');
// 3. Shared OpenAPI responses + scope enforcement, declared once for every route
const makeRouter = createRouter({
routeDefaults: {
responses: {
401: jsonResponse(ErrorBody, 'Unauthorized'),
404: jsonResponse(ErrorBody, 'Not found'),
},
},
routeMiddleware: createScopeMiddleware(api, { resolve: (c) => c.var.session.scopes }),
});
const projectsRouter = makeRouter(
projects,
({ app, defineRoute }) => app.openapi(defineRoute('post', {
security: [{ bearer: ['projects:write'] }], // documented AND enforced (403)
request: jsonRequest(z.object({ name: z.string().min(1) }), 'New project'),
responses: {
201: jsonResponse(Project, 'Created'),
409: jsonResponse(ErrorBody, 'Slug taken'), // remove this and the arm below won't compile
},
}), (c) =>
handle(
c,
async ({ param, json }) => {
param.orgId; // string: inferred from '/api/orgs/:orgId/projects', never declared
c.var.session; // inherited from the root
return c.json(await createProject(c.var.org.id, json.name), 201); // c.var.org from .bind()
},
matchErrors([SlugTaken], {
SlugTaken: (_e, c) => c.json({ message: 'Name already taken' }, 409),
}),
),
)
);
const orgRouter = makeRouter(org, () => {}, [projectsRouter]);
const app = mountRouter(api, [orgRouter]);
// 4. End-to-end typed client: path, params, body, and every response status
const client = testClient(app);
await client.api.orgs[':orgId'].projects.$post({
param: { orgId: 'acme' },
json: { name: 'Website' },
});
r/node • u/HotVictory9749 • 12d ago
I built Dakly: A free, zero-setup transactional email engine with multi-Gmail failover so you don't have to pay Resend or SendGrid for side projects
Hey everyone!
Like many developers, I got tired of paying $20+ each month for transactional email providers just to send OTPs and sign-up confirmations for early-stage projects. Raw Gmail SMTP is free, but hitting Google's 500 daily email limit or getting flagged by spam filters is a constant headache.
To fix this, I built Dakly ( https://dakly.cc.cd ).
How it works:
• Failover Pool: Connect multiple Gmail accounts; when one hits its daily quota, Dakly dynamically routes outgoing sends to backup accounts.
• Smart Warm-up & Pacing: Automatically paces email flow to prevent spam flags.
• Live Telemetry: Real-time open & click tracking with webhooks.
• Sender Aliases: Send from your custom domain alias (support@mydomain.com).
• Official SDKs: Ready for Node.js (npm i @ dakly/sdk) and Python.
It's completely free to use. Would love to get your feedback and feature suggestions!
r/node • u/eyobhailu • 13d ago
Stop passing req.user everywhere: I ported Spring Security's architecture to Express
If you have built an Express API, you know the frustration: you authenticate a token, attach data to req.user, and spend the rest of the day passing the req object down through services, repositories, and helper functions.
The usual alternative is migrating to NestJS just to get decent guards and decorators.
I built express-spring-security to bring that clean architecture to Express 5 and TypeScript without the framework bloat:
- Ambient Context: Access the authenticated user anywhere in your backend via Node's AsyncLocalStorage without passing the req object around.
- Single Security Chain: Define all your public, protected, and role-based routes in one central configuration.
- Method-Level Authorization: Lock down controller methods with declarative `@PreAuthorize` role and authority checks.
It is open source on GitHub and npm under `express-spring-security` (link is in the comments below).
Would love to hear your feedback and how you are currently handling auth in your Express apps!
3 years ago I posted my first Node Package, now it's at +1M monthly downloads.
3 years ago I posted this: https://www.reddit.com/r/node/comments/16zrn21/my_first_node_package_efficient_language_detector/
My first Node Package: Efficient Language Detector
ELD is a fast and accurate natural language detector, written 100% in Javascript, no dependencies. I believe it is the fastest non compiled detector, at its level of accuracy.
https://github.com/nitotm/efficient-language-detector-jsI've been programming for years but this is the first time I publish a package, so I would appreciate any feedback you have on the project's structure, code quality, documentation, or any other aspect you feel could be improved.
I learned a bit, I improved it, and now it has surpassed 1 million downloads per month.
The package is called eld: https://www.npmjs.com/package/eld
I know most of the growth is because of AI agents, but I don't see that as a bad thing, they are smart ;). There is still room for improvements but I think it's a decent tool already.
r/node • u/matsnorberg • 14d ago
npm install
Hello, Im a node.js beginner and confused about the npm install mechanism.
Why are we supposed to npm install everything a new for each project we start? Say that I install the Express framework module in any project I start, wouldn't that mean that I end up with hundreds of copies of Express on my computer? Wouldn't that be a huge waste of disk resources? It's like a C++ programmer installed a new copy of the standard library or boost for each project he starts.
I know there is a -g flag that installs "globally". Where is this "global" library located, can I browse it? Is it advisable to use the -g flag everytime I need to use a module to avoid heavy waste of disk space?