DEV Community

Cover image for Stop Writing Express Boilerplate: Build a Production-Ready REST API in Minutes
Shobhit Kumar
Shobhit Kumar

Posted on

Stop Writing Express Boilerplate: Build a Production-Ready REST API in Minutes

๐Ÿš€ Stop Writing Express Boilerplate: Build a Production-Ready REST API in Minutes

If you've built more than one Express.js backend, you've probably repeated the same setup over and over again.

Every new project usually starts with:

  • Creating the folder structure
  • Installing Express and dependencies
  • Configuring environment variables
  • Connecting MongoDB
  • Setting up JWT authentication
  • Writing middleware
  • Configuring CORS and Helmet
  • Adding request validation
  • Creating Docker files

By the time you write your first API endpoint, you've already spent 30โ€“60 minutes writing code you've written dozens of times before.

Wouldn't it be better if all of that was already done for you?


๐Ÿค” The Problem with Starting from Scratch

A typical Express project often begins like this:

mkdir my-api
cd my-api
npm init -y

npm install express mongoose dotenv cors helmet bcryptjs jsonwebtoken express-rate-limit
Enter fullscreen mode Exit fullscreen mode

Then you manually create folders:

src/
โ”œโ”€โ”€ controllers/
โ”œโ”€โ”€ models/
โ”œโ”€โ”€ routes/
โ”œโ”€โ”€ middlewares/
โ”œโ”€โ”€ config/
โ”œโ”€โ”€ utils/
โ””โ”€โ”€ app.js
Enter fullscreen mode Exit fullscreen mode

After that comes authentication, database configuration, validation, error handling, logging, Docker setup, and dozens of configuration files.

None of this is unique to your application.

It's simply repetitive setup.


๐Ÿ’ก Focus on Building Features

As developers, our time is better spent building productsโ€”not rewriting the same project structure every time.

Instead of spending an hour preparing your backend, imagine jumping straight into your business logic.

That's exactly why I built sk-nodeexpress.


๐Ÿ“ฆ What is sk-nodeexpress?

sk-nodeexpress is an open-source CLI that scaffolds a production-ready Express.js backend in just a few seconds.

With a single command:

npx sk-nodeexpress my-api
Enter fullscreen mode Exit fullscreen mode

you get a fully configured backend ready for development.


โœจ Features Included

  • โšก JavaScript (ES Modules) & TypeScript
  • ๐Ÿ” JWT Authentication
  • ๐Ÿ‘ฅ Role-Based Authorization
  • ๐Ÿƒ MongoDB Integration
  • โœ… Zod Validation
  • ๐Ÿš€ Async Error Handler
  • ๐Ÿ›ก๏ธ Helmet Security
  • ๐ŸŒ CORS Configuration
  • ๐Ÿšฆ Rate Limiting
  • ๐Ÿณ Docker & Docker Compose
  • ๐Ÿ“ Clean Folder Structure
  • โš™๏ธ Environment Configuration

Everything is ready out of the box.


โšก Interactive or Command Line

Interactive mode:

npx sk-nodeexpress
Enter fullscreen mode Exit fullscreen mode

Or use command-line flags:

npx sk-nodeexpress my-api --ts --auth --docker
Enter fullscreen mode Exit fullscreen mode

Need only a minimal Express server?

npx sk-nodeexpress my-api --js --no-auth --db none --no-docker
Enter fullscreen mode Exit fullscreen mode

๐Ÿ“‚ Generated Project Structure

my-api/

src/
โ”œโ”€โ”€ config/
โ”œโ”€โ”€ controllers/
โ”œโ”€โ”€ middlewares/
โ”œโ”€โ”€ models/
โ”œโ”€โ”€ routes/
โ”œโ”€โ”€ utils/
โ”œโ”€โ”€ validations/
โ”œโ”€โ”€ app.ts
โ””โ”€โ”€ server.ts

Dockerfile
docker-compose.yml
package.json
README.md
Enter fullscreen mode Exit fullscreen mode

Generated Project Output

Generated Project

One of my favorite features is dynamic template generation.

If you choose:

  • No Authentication โ†’ Auth files are not generated.
  • No Database โ†’ Database configuration is removed.
  • No Docker โ†’ Docker files are skipped.

The generated project contains only the code you actually need.


๐Ÿ“Š Comparison

Feature sk-nodeexpress express-generator
JavaScript โœ… โœ…
TypeScript โœ… โŒ
JWT Authentication โœ… โŒ
MongoDB โœ… โŒ
Docker โœ… โŒ
Zod Validation โœ… โŒ
Security Middleware โœ… โŒ
Production Folder Structure โœ… โŒ

๐Ÿ› ๏ธ Why I Built It

After creating multiple Express applications, I realised I kept copying the same files into every project:

  • Authentication
  • Middleware
  • Database configuration
  • Folder structure
  • Validation
  • Docker setup

Eventually, I decided to automate the repetitive work.

The goal wasn't to replace Express.

The goal was to help developers spend more time building features instead of writing boilerplate.


๐Ÿš€ Getting Started

Generate a project:

npx sk-nodeexpress my-api
Enter fullscreen mode Exit fullscreen mode

Move into the project:

cd my-api
Enter fullscreen mode Exit fullscreen mode

Install dependencies:

npm install
Enter fullscreen mode Exit fullscreen mode

Start the development server:

npm run dev
Enter fullscreen mode Exit fullscreen mode

That's it.

Your backend is ready.


๐Ÿ”ฎ Roadmap

I'm actively working on more features, including:

  • ๐Ÿ“– Swagger/OpenAPI support
  • ๐Ÿ—„๏ธ Multiple database options
  • ๐Ÿงฉ Plugin system
  • โšก Better CLI experience
  • ๐Ÿค– AI-assisted project generation

Suggestions and contributions are always welcome.


๐Ÿ’ฌ Final Thoughts

Scaffolding isn't the exciting part of backend development.

Building products is.

If a tool can save you from rewriting the same Express setup every time, you can focus on solving real-world problems instead.

If you try sk-nodeexpress, I'd genuinely love to hear your feedback.

Every suggestion helps improve the project.


๐Ÿ”— Links

๐Ÿ“ฆ npm

https://www.npmjs.com/package/sk-nodeexpress

โญ GitHub

https://github.com/kumarshobhit-1/sk-nodeexpress

If you found this article useful, consider giving the repository a โญ on GitHub.

Happy Coding! ๐Ÿš€

Top comments (1)

Collapse
 
sonisuryansh profile image
Suryansh Soni

This is so gud i used it many times it saved my time,
thank you developer.