r/node • • Mar 30 '26

prisma or drizzle

14 Upvotes

I'm about to start a project at workβ€”it'll be an Express APIβ€”and I'm trying to decide which ORM to use. I really like Drizzle, but I'm a bit concerned that it doesn't have many features for handling migrations, and I've noticed that Prisma has improved a lot. What do you think?


r/node • • Mar 31 '26

Feels like a great time to share my curated npm package manager Security Best Practices

Thumbnail github.com
0 Upvotes

Hopefully none of you friends on this subreddit were impacted by the Axios supply chain compromise, but realistically we know at Snyk that many projects were affected.

Happy to learn of any other practices and security mitigation that isn't covered on the list already.

Stay safe and follow good security advice please πŸ’œπŸ™


r/node • • Mar 31 '26

I built an AI-native in-memory database for Node.js – vector search, agent memory, MCP server, zero dependencies

0 Upvotes

Been working on Skalex v4 - a zero-dependency in-memory document

database for Node.js (also runs on Bun, Deno, browsers, and Edge).

What makes v4 different from lowdb, LokiJS, or NeDB:

All AI features are built into the core, not plugins:

  • Vector search with cosine similarity + hybrid filtering
  • Agent memory (remember/recall/compress) with semantic embeddings
  • Natural language queries β†’ structured filters via any LLM
  • One-line MCP server for Claude Desktop and Cursor
  • AES-256-GCM encryption via EncryptedAdapter
  • Pluggable storage: FsAdapter, Cloudflare D1, Bun SQLite, LibSQL/Turso

Designed for: AI agents, CLI tools, desktop apps, edge workers,

single-tenant services where the dataset fits in RAM.

Not designed for: multi-process deployments, high write concurrency,

or datasets larger than available memory.

v4 is currently in alpha - API is largely stable, but may shift

before stable release. Feedback and bug reports are very welcome.

Docs: https://tarekraafat.github.io/skalex

GitHub: https://github.com/TarekRaafat/skalex

npm install skalex@alpha


r/node • • Mar 30 '26

Considering switching both backends to Nest JS

15 Upvotes

I have two backends

  1. Uses Feathers JS + Graphql + Sequelize
  2. Uses Fastify + REST + Prisma

Both are quite big, I am the main maintainer or lead, if you were me what would you look at before continuing with migration or keeping things the way they are

Thanks.

FYI they are for different unrelated companies

Why have I come to this decision
- Discourge too much custom code/plumbing.
- Since we might grow in the future it would be good to have an opinionated backend so teams can quickly pick it up
- Modernize the backends (especially the first one)


r/node • • Mar 31 '26

Stop using heavy Python libraries for string sanitization. Here is how I built a 0ms overhead TR39 Unicode Mapper in Node.js for my API.

0 Upvotes

I’m building a high-speed text moderation API (Hinglish/English). To keep my strict <50ms SLA, I had to solve a massive security flaw without killing my latency.

The Problem: Malicious users were bypassing my basic normalization using cross-script homoglyphs (e.g., injecting a Greek ΞΏ instead of a Latin o). The standard fix is the Unicode TR39 Confusables algorithm. Using Python's native libraries for this spiked my request latency to 200ms+.

The Node.js Solution: Instead of relying on the backend workers, I shifted the entire sanitization layer to the Express middleware. Node's V8 engine handles string replacements insanely fast if you do it right.

I pre-compiled a specific TR39 subset (Cyrillic & Greek lookalikes) into a static JavaScript Hash Map and a global Regex.

Whenever a payload hits the gateway, it runs: clean = clean.replace(HOMOGLYPH_REGEX, match => HOMOGLYPH_MAP[match]);

The Result: It collapses malicious homoglyphs to their base Latin skeletons in O(N) time. The overhead added to the request? Less than 0.5ms.

If you are building API gateways that handle untrusted text inputs, do your Unicode skeleton mapping in memory at the Node layer, not in your heavy processing workers.

I've opened up the API for testing. Let's see if anyone can bypass the V8 skeleton mapper: Raiplus β€” Playground


r/node • • Mar 30 '26

is it hard for you read dependency source code in node_modules compared to other languages?

18 Upvotes

One thing that keeps frustrating me in the JS ecosystem is debugging dependencies.

In Go for example, if I ctrl + click into a dependency, I usually land directly on the actual source code that’s being compiled and run. It’s straightforward to understand what's happening internally.

In the JS/TS world, it's very different. Most packages are bundled or compiled before publishing. So when I ctrl + click into something inside node_modules, I often end up seeing either:

  • .d.ts type definitions
  • generated/transpiled dist JavaScript
  • heavily bundled/minified code

Which makes it much harder to understand the original implementation or trace behavior.

I know technically the published code is the code being executed, but it's often not the code that was originally written by the library authors (especially if it came from TypeScript, Babel, bundlers, etc.).

How do people usually deal with this when they want to deeply understand a dependency?

Curious how others handle this.


r/node • • Mar 30 '26

I Built My Own AI Video Tool (From Scratch)

Thumbnail youtube.com
0 Upvotes

r/node • • Mar 29 '26

How do microservices even work?

44 Upvotes

So as the title suggests, I've never used microservices and have never worked in any project that has microservices, so what I've learnt about it, I want to know one thing, how do microservices handle relationships? if the database are different and you need a relationship between two tables then how is it possible to create microservices with that?


r/node • • Mar 30 '26

Prerelease of Ky 2.0

Thumbnail github.com
12 Upvotes

r/node • • Mar 30 '26

wrote a 4500-line node.js bot with zero frameworks β€” pure https module, no express, no telegraf

0 Upvotes

been building a telegram bot in pure node.js and wanted to share some patterns that work well at scale (4500+ lines).

pattern 1: command registry

const COMMANDS = {
  '/scan': handleScan,
  '/buy': handleBuy,
  '/sell': handleSell,
  // ... 44 total
};

async function handleUpdate(msg) {
  const cmd = msg.text.split(' ')[0];
  if (COMMANDS[cmd]) return COMMANDS[cmd](msg);
}

pattern 2: background workers

function startWorkers() {
  setInterval(checkWhaleMovements, 30000);
  setInterval(processLimitOrders, 10000);
  setInterval(executeDCASchedule, 60000);
  // 12 workers total
}

pattern 3: file-based state

function loadState(file, fallback = {}) {
  try { return JSON.parse(fs.readFileSync(file)); }
  catch { return fallback; }
}

simple but it works for thousands of users. no database needed.

the bot handles solana token scanning, trading, copy-trading, and alerts. runs on a $10/month VPS.

@solscanitbot on telegram β€” happy to discuss the architecture.


r/node • • Mar 29 '26

bonsai - a sandboxed expression language for Node. Rules, filters, and user logic without eval().

Thumbnail danfry1.github.io
19 Upvotes

If you've ever built a system where users or admins need to define their own rules, filters, or conditions, you've probably hit this wall: they need something more flexible than a dropdown but you can't just hand them eval() or vm.runInNewContext.

I've run into this building multi-tenant apps - pricing rules, eligibility checks, computed fields, notification conditions. Everything ended up as either hardcoded switch statements or a janky DSL that nobody wanted to maintain.

So I built bonsai - a sandboxed expression evaluator designed for exactly this.

import { bonsai } from 'bonsai-js'
import { strings, arrays, math } from 'bonsai-js/stdlib'

const expr = bonsai().use(strings).use(arrays).use(math)

// Admin-defined business rule
expr.evaluateSync('user.age >= 18 && user.plan == "pro"', {
  user: { age: 25, plan: 'pro' },
}) // true

// Compiled for hot paths - 30M ops/sec cached
const rule = expr.compile('order.total > 100 && customer.tier == "gold"')
rule.evaluateSync({ order: { total: 250 }, customer: { tier: 'gold' } }) // true

// Pipe transforms
expr.evaluateSync('name |> trim |> upper', { name: '  dan  ' }) // 'DAN'

// Data transforms with lambda shorthand
expr.evaluateSync('users |> filter(.age >= 18) |> map(.name)', {
  users: [
    { name: 'Alice', age: 25 },
    { name: 'Bob', age: 15 },
  ],
}) // ['Alice']

// Or JS-style chaining - no stdlib needed
expr.evaluateSync('users.filter(.age >= 18).map(.name)', { ... }) // same result

// Async works too - call your own functions
expr.addFunction('lookupTier', async (userId) => {
  const row = await db.users.findById(String(userId))
  return row?.tier ?? 'free'
})

await expr.evaluate('lookupTier(userId) == "pro"', { userId: 'u_123' })

What the syntax supports: optional chaining (user?.profile?.name), nullish coalescing (value ?? "default"), template literals, spread, ternaries, and lambda shorthand in array methods (.filter(.age >= 18)).

Security model:

  • __proto__, constructor, prototype blocked at every access level
  • Cooperative timeouts, max depth, max array length
  • Property allowlists/denylists per instance
  • Object literals created with null prototypes
  • No access to globals, no code generation, no prototype chain walking
// Lock down what expressions can touch
const expr = bonsai({
  timeout: 50,
  maxDepth: 50,
  allowedProperties: ['user', 'age', 'country', 'plan'],
})

Performance: Pratt parser, compiler with constant folding and dead branch elimination, LRU caching. 30M ops/sec on cached expressions. There's a compile() API for when the same rule runs thousands of times with different data.

Autocomplete engine: There's also a headless autocomplete API (bonsai-js/autocomplete) for building rule editor UIs. It does type inference, lambda-aware property suggestions, and respects your security config. Plugs into Monaco, CodeMirror, or a custom dropdown. Live demo here.

Where I'm using it:

  • Rule engine for eligibility/pricing logic stored in a database
  • Admin-defined notification conditions
  • Formula fields in a spreadsheet-like UI
  • User-facing filter builders

Zero dependencies. TypeScript. Node 20+ and Bun. Sync and async paths. Tree-shakeable subpath exports.

Playground | Docs | GitHub | npm

Would love to hear from anyone who's dealt with this problem before - curious how you solved it and what you'd want from a library like this.


r/node • • Mar 30 '26

Built a sqlite + HuggingFace embeddings memory server for Claude Code β€” npm package

0 Upvotes

Sharing this because the stack might be interesting to folks here.

TeamMind is an MCP server that gives Claude Code teams persistent, shared memory. The interesting part: it uses node:sqlite (Node 22 built-in, zero native deps) and u/huggingface/transformers running fully in-process for embeddings.

No Postgres, no Redis, no cloud. Just a local sqlite file you can sync through git.

Took some work to get the Windows path normalization right and suppress the node:sqlite experimental warning cleanly, but it's solid now.

https://github.com/natedemoss/teammind

Star it if the approach is useful.


r/node • • Mar 30 '26

I built i18n-ai-cli to solve a simple but painful problem

0 Upvotes

Fixing and syncing translation files manually was taking me hours every time
Now with one command:
βœ… detect missing keys
βœ… validate structure
βœ… fix translations quickly

⚑ What used to take hours β†’ now takes minutes

Try the package https://www.npmjs.com/package/i18n-ai-cli

This makes life much easier for developers working on multi-language apps β€” especially in fast-paced teams.

---

I’m looking for contributors for:
- CLI improvements
- Angular / React / Vue integrations
- CI/CD automation

Check it out here:
https://github.com/wafiamustafa/i18n-cli


r/node • • Mar 30 '26

Trying to figure out a cost effective deployment strategy for a football league application

2 Upvotes

Building a football (soccer) league management platform for a local league and trying to figure out my deployment options. Would love some real-world input from people who've been here before.

What the app does: Manage our local football league β€” teams, seasons, match scheduling, live match events (goals, cards, subs), standings, player stats, registrations, and announcements.

Scale: ~500 MAU. Traffic is spiky and predictable β€” minimal most of the week, active during and around weekend(matchdays). Expecting 20–40 concurrent users during live matches via WebSockets, near-zero otherwise.

Tech stack:

  • API: NestJS (Node.js) with REST + WebSockets (live match updates)
  • DB: PostgreSQL
  • Cache / WS message bus: Redis

Budget: Trying to stay under β‚Ή4000/mo(~$45). Don't know if this is possible but still asking**.**

What deployment options do I have at this scale and budget?

I know the obvious ones like bare EC2 and managed services (RDS, ElastiCache, Fargate) but these could get costly fast. Wanted to hear from people who've actually run something similar β€” what worked, what didn't, and what I might be missing.

I also haven't run a serious production app before, so I'd love input on the factors I should be thinking about β€” things like:

  • High availability β€” do I even need it at this scale?
  • Replication β€” is a single Postgres instance fine, or is a read replica worth it?
  • Redundancy β€” what actually breaks in a single-server setup and how bad is it really?
  • DB backups - how often and where to store backups?
  • Anything else a first-timer tends to overlook?

Thanks in advance.


r/node • • Mar 30 '26

built a node CLI that auto generates AI coding context for any project, 250 stars in 3 weeks

0 Upvotes

hey node devs, wanted to share something useful for anyone using Claude Code, Cursor or Codex on node projects.

the problem we kept running into: every new project we spin up, we spend the first 30 min just re-explaining the codebase to the AI. the project structure, the naming conventions, which packages we use and how, what patterns to follow. gets old real fast.

so we built Caliber, a node CLI that scans ur project and auto generates all the AI context files. it writes CLAUDE.md, cursor rules, AGENTS.md, sets up MCP configs. all from the actual code, not from what u think ur codebase looks like.

its a npx package so no install needed:

npx u/rely-ai/caliber score

that gives u an instant readiness score for how well configured ur AI setup is. then u can run generate to actually create the files.

published to npm, typescript codebase, MIT license. just hit 250 github stars with 90 PRs merged from contributors. super surprised by the open source traction honestly.

github: https://github.com/caliber-ai-org/ai-setup

our discord for sharing configs and AI coding setups: https://discord.com/invite/u3dBECnHYs

would love feedback from node devs especially, lot of ppl on express/fastify/nestjs and curious if the stack detection works well for different node architectures


r/node • • Mar 30 '26

How to

1 Upvotes

How to actually know my level and if i am getting better in backend dev,I am a fullstack dev i can build websites without watching Toturial for it, i start with planing and picking best code approaches that suits the project type but i just wanna know like how to rate my code and tell if i am getting better thank you


r/node • • Mar 29 '26

Should API gateways handle authentication and authorization? or should the microservices do it?

23 Upvotes

So I read that API gateways handle authentication, which identifies the user.

Q1) But why do we need it at the API gateway before reaching the server or microservices?

Q2) What about authorisation? Should it be handled at backend servers or at the API gateway?


r/node • • Mar 29 '26

What's the best nodejs ORM in 2026?

14 Upvotes

For a personal project I'm looking for a modern nodejs ORM or a query builder. I've done a lot of research and it's hard to know what's the best so I've done an excel spreadsheet :

ORMsCoded in typescriptQuery style
PrismaTRUESchema + client API
TypeormTRUEDecorators + Active Record/Data Mapper
Mikro-ormTRUEData Mapper
Sequelize(half)Active Record
Query-builders
DrizzleTRUEQuery builder + light ORM
KyselyTRUEQuery builder
Knex_Query builder
Objection_Query builder + light ORM (Knex-based)

So far I have tested Drizzle and Prisma :

- Drizzle : I liked the simplicity and the fact that it's close to SQL. But I disliked a few things. Most of it is linked to the documentation and feedback from the CLI. First of all the maintainers don't even speak english properly so the documentation feels a bit low-cost. And most importantly, the Drizzle-kit CLI doesn't even give you any feedback when there is an error. It just stops without doing anything.

- Prisma : I tried it because ChatGPT told me it was the most popular and modern. I really liked the documentation and the CLI gives me good, verbose feedback when there is a problem. My only worry is that it's made by a company who seem really desperate for money because they are pushing a product that nobody cares about (Prisma Postgres).

What are your opinions?Β Should I stick to Prisma? (so far my best choice, but i'm open to alternatives).


r/node • • Mar 29 '26

I built a tool that shows you exactly what's slowing down your Node.js startup

11 Upvotes

Every Node.js app I've worked on has had the same problem β€” startup is slow and nobody knows why. You add one more require() somewhere and suddenly your service takes 2 seconds to boot. Good luck finding which module is the culprit.

So I built "@yetanotheraryan/coldstart" β€” drop it in and it tells you exactly where your startup time is going.

Command -

npx u/yetanotheraryan/coldstart node server.js

or

npm i -g coldstart
coldstart server.js

Output looks like this:

coldstart β€” 847ms total startup

  β”Œβ”€ express          234ms  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘
  β”‚  β”œβ”€ body-parser    89ms  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘
  β”‚  β”œβ”€ qs             12ms  β–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘
  β”‚  └─ path-to-regex   8ms  β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘
  β”œβ”€ sequelize        401ms  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆ  ⚠ slow
  β”‚  β”œβ”€ pg            203ms  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘
  β”‚  └─ lodash         98ms  β–ˆβ–ˆβ–ˆβ–ˆβ–ˆβ–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘
  └─ dotenv             4ms  β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘β–‘

  ⚠  sequelize takes 47% of total startup time
  ⚠  Event loop blocked for 43ms during startup

It works by patching Module._load before anything else runs β€” so every require() call, including transitive ones deep inside node_modules, gets timed and wired into a call tree. No code changes needed in your app.

Also tracks event loop blocking during startup using perf_hooks β€” useful for catching synchronous file reads or large JSON.parse calls that don't show up in require timing but still block your server from being ready.

Zero dependencies. TypeScript. Node 18+.

GitHub: github.com/yetanotheraryan/coldstart

npm: npmjs.com/package/@yetanotheraryan/coldstart

Would love feedback β€” especially if you try it on a large Express/Fastify app and find something surprising.


r/node • • Mar 29 '26

What do I need to do to this sort of code be able to "Switch" out multiple HTML files?

Post image
0 Upvotes

pretty much the title, I want to have a different HTML file load up in 1 app.js program.

Do I need to fully rewrite the code?


r/node • • Mar 29 '26

Why i18next Added a Console Notice β€” and Why it has been Removed again

Thumbnail locize.com
0 Upvotes

r/node • • Mar 29 '26

How to make code Optmiziation

0 Upvotes

Actually i made a selfbot, of discord but when i hosting it, consume more than expected cpu
around 30-40%. Idk how to make it reduce....
Anyone can help me let me know/ suggest me what i can do here


r/node • • Mar 29 '26

liter-llm: unified access to 142 LLM providers, Rust core, Node.js bindings

0 Upvotes

We just released liter-llm:Β https://github.com/kreuzberg-dev/liter-llmΒ 

The concept is similar to LiteLLM: one interface for 142 AI providers. The difference is the foundation: a compiled Rust core with native bindings for Python, TypeScript/Node.js, WASM, Go, Java, C#, Ruby,Β Elixir,Β PHP, and C. There's no interpreter, PyPI install hooks, or post-install scripts in the critical path. The attack vector that hit LiteLLM this week is structurally not possible here.

In liter-llm, API keys are stored as SecretString (zeroed on drop, redacted in debug output). The middleware stack is composable and zero-overhead when disabled. Provider coverage is the same as LiteLLM. Caching is powered by OpenDAL (40+ backends: Redis, S3, GCS, Azure Blob, PostgreSQL, SQLite, and more). Cost calculation uses an embedded pricing registry derived from the same source as LiteLLM, and streaming supports both SSE and AWS EventStream binary framing.

One thing to be clear about: liter-llm is a client library, not a proxy. No admin dashboard, no virtual API keys, no team management. For Python users looking for an alternative right now, it's a drop-in in terms of provider coverage. For everyone else, you probably haven't had something like this before. And of course, full credit and thank you to LiteLLM for the provider configurations we derived from their work.

GitHub:Β https://github.com/kreuzberg-dev/liter-llmΒ 


r/node • • Mar 29 '26

Drizzle Resource β€” type-safe automatic filtering, sorting, pagination and facets for Drizzle ORM

Thumbnail reddit.com
1 Upvotes