Overview
Node.js & Express Code Snippets supercharges backend development in Visual Studio Code. Packed with battle-tested snippets for modern JavaScript, TypeScript, ES Modules (ESM), CommonJS (CJS), database ORMs, security middleware, and Clean Architecture patterns—with precision tab stops and exit cursor positions ($0).
Highlights
TypeScript & Modern ESM First
Write typed Express handlers (Request, Response, NextFunction, ErrorRequestHandler), type-safe middleware, and choose seamlessly between ES Modules (import) and CommonJS (require()).
Production Security & Middleware
Instant boilerplates for JWT authentication, Zod & Joi schema validation, Helmet security headers, CORS configuration, Rate Limiting, and Morgan logging.
Databases & ORMs
Pre-built snippets for Prisma Client & queries, Mongoose schemas & aggregation pipelines, Sequelize models, PostgreSQL connection pools (pg.Pool), and Redis clients.
Modern Node.js APIs
Native node:test runner, native fetch with AbortController timeout handling, node:fs/promises, worker threads, crypto UUIDs, and clustering.
Snippets Cheatsheet
Express Server & Routers
| Prefix |
Description |
Syntax |
exp-server-ts |
Express server setup with TypeScript types |
TypeScript |
exp-server-esm |
Express server setup with ES Modules |
ESM |
exp-server-cjs |
Express server setup with CommonJS |
CommonJS |
exp-router-ts |
Typed Express Router instance |
TypeScript |
exp-router-esm |
Express Router instance with ES Modules |
ESM |
exp-router-cjs |
Express Router instance with CommonJS |
CommonJS |
Routes & Handlers
| Prefix |
Description |
Method / Pattern |
exp-get-ts |
Typed GET route handler |
TypeScript |
exp-get-async |
Async GET route with try-catch & next(error) |
Async |
exp-post-ts |
Typed POST route handler |
TypeScript |
exp-post-async |
Async POST route with try-catch & next(error) |
Async |
exp-put-async |
Async PUT route handler with :id param |
Async |
exp-patch |
Async PATCH route handler |
Async |
exp-delete-async |
Async DELETE route handler |
Async |
exp-route-chain |
Chained route handlers on a single URI path |
app.route() |
exp-res-success |
Standardized JSON success response helper |
res.status(200).json() |
exp-res-error |
Standardized JSON error response helper |
res.status(400).json() |
Middleware, Security & Validation
| Prefix |
Description |
Category |
exp-auth-jwt-ts |
Typed Bearer JWT verification with custom AuthRequest |
Authentication |
exp-auth-jwt |
Bearer JWT verification middleware |
Authentication |
exp-validate-zod |
Request schema validation middleware using Zod |
Validation |
exp-validate-joi |
Request schema validation middleware using Joi |
Validation |
exp-middleware-ts |
Typed Express middleware (Request, Response, NextFunction) |
Middleware |
exp-error-middleware-ts |
Typed 4-argument global error handling middleware |
Error Handling |
exp-helmet |
Security HTTP headers configuration |
Security |
exp-cors |
Cross-Origin Resource Sharing setup with options |
Security |
exp-rate-limit |
IP-based request rate limiting middleware |
Rate Limiter |
exp-multer |
File upload middleware with disk storage |
File Handling |
Database & ORMs
| Prefix |
Description |
Driver / ORM |
exp-prisma-client |
Singleton Prisma Client setup |
Prisma |
exp-prisma-crud |
Prisma findMany query with where, include, and orderBy |
Prisma |
exp-mongoose-connect |
MongoDB connection with async error handling |
Mongoose |
exp-mongoose-model-ts |
Mongoose Schema & Model with TypeScript interface |
Mongoose |
exp-mongoose-aggregate |
Mongoose aggregation pipeline ($match, $group, $sort) |
Mongoose |
exp-sequelize-model |
Sequelize Model class definition |
Sequelize |
exp-pg-pool |
PostgreSQL connection pool with query helper |
PostgreSQL (pg) |
exp-redis-client |
Redis v4+ client connection and error listeners |
Redis |
Clean Architecture
| Prefix |
Description |
Layer |
exp-arch-controller |
Express controller class with dependency injection |
Controller |
exp-arch-service |
Service class encapsulating business logic |
Service |
exp-arch-repository |
Repository interface and implementation pattern |
Data Access |
Modern Node.js APIs & Utilities
| Prefix |
Description |
API / Module |
node-test |
Native test suite with describe, it, and node:assert/strict |
node:test |
node-fetch-timeout |
Native fetch with AbortController timeout handling |
Global fetch |
fs-readfile-async |
Asynchronous file read |
node:fs/promises |
fs-writefile-async |
Asynchronous file write |
node:fs/promises |
stream-pipeline |
Stream pipeline helper |
node:stream/promises |
crypto-uuid |
Fast UUID (v4) generation |
node:crypto |
bcrypt-hash |
Password hashing with salt rounds |
bcrypt |
process-shutdown |
Graceful shutdown handler (SIGINT / SIGTERM) |
Process |
sleep |
Async delay helper |
await sleep(ms) |
Supported Languages
- JavaScript (
.js)
- TypeScript (
.ts)
- React JavaScript (
.jsx)
- React TypeScript (
.tsx)
Feedback & Contributions
- Report issues and suggest new snippets on GitHub Issues.
- If you find this extension helpful, please leave a review on the Marketplace.
A product from bluebuff.in • Released under the MIT License