starter-backendkit
v1.3.2
Published
Scaffold a production-ready Node.js backend — choose Express + MongoDB or Express + PostgreSQL (raw SQL)
Maintainers
Readme
starter-backendkit
Scaffold a production-ready Node.js backend in seconds.
Usage
npx starter-backendkit my-appor install globally:
npm i -g starter-backendkit
backendkit my-appPick a tech stack, and you get a ready-to-run project.
Stacks
Pick from four starter options:
- Node.js + Express + MongoDB + React — Fullstack monorepo combining Express + MongoDB API with a Vite + React SPA styled with custom Vanilla CSS.
- Node.js + Express + MongoDB — Backend only: REST API with Mongoose, JWT auth, Zod validation, and error middleware.
- Node.js + Express + PostgreSQL + React — Fullstack monorepo combining Express + PostgreSQL API (raw SQL) with a Vite + React SPA styled with custom Vanilla CSS.
- Node.js + Express + PostgreSQL — Backend only: REST API with raw pg client queries, JWT auth, Zod validation, and database init scripts.
What's inside the templates
Fullstack Stacks (+React)
my-app/
├── backend/ # Express REST API
├── frontend/ # Vite + React SPA (AuthContext, page router, Lucide icons, custom CSS)
├── package.json # Root package coordinating installation and concurrent execution
└── README.mdBackend-Only Stacks
src/
├── app.js # Express app entry
├── middleware/ # Auth, validation, and error handlers
├── utils/ # JWT tokens, connection layers
└── modules/ # Module folders containing auth, users, and posts routes/logicAfter scaffolding
Backend-Only Stacks:
cd my-app
cp .env.example .env # fill in your database & jwt secrets
npm install
npm run db:init # PostgreSQL stack only — creates tables
npm run devFullstack Stacks:
cd my-app
npm install # installs root dependencies, frontend, and backend packages
cp backend/.env.example backend/.env # fill in secrets
npm run db:init --prefix backend # PostgreSQL stack only — creates tables
npm run dev # launches both client and server concurrently🛠️ Developer Guide (Contributing)
If you are developing this CLI tool or want to add/edit the tech stack templates, here is what you need to know:
1. Project Folder Structure
bin/cli.js: The CLI script entry point. It uses@clack/promptsto guide the user, resolves output paths, copies the selected template, and updates the generated project'spackage.json.templates/: Contains the project boilerplates:node-mongo/: Express + MongoDB boilerplate template.node-postgres/: Express + PostgreSQL boilerplate template.
2. Important: .gitignore Renaming Caveat
NPM automatically ignores and removes any files named .gitignore during the publishing process.
- Rule: Always rename
.gitignoretogitignore(no leading dot) inside your template folders undertemplates/. - The CLI script (
bin/cli.js) automatically renames it back to.gitignorewhen scaffolding the user's project.
3. Local Development & Testing
To test your changes locally:
- Navigate to the
starter-backendkitfolder. - Link the package globally on your system:
npm link - Now, you can test the CLI command anywhere on your machine:
backendkit my-test-app - Once you are done testing, unlink the package:
npm unlink -g starter-backendkit
4. Adding a New Tech Stack Template
- Place your new boilerplate template in the
templates/folder (e.g.templates/node-mysql). Ensure any.gitignorefile inside is namedgitignore. - Open
bin/cli.jsand add your new stack to theSTACKSarray:const STACKS = [ { value: 'node-mongo', label: 'Node.js + Express + MongoDB' }, { value: 'node-postgres', label: 'Node.js + Express + PostgreSQL (raw SQL)' }, { value: 'node-mysql', label: 'Node.js + Express + MySQL' }, // Example ]; - Add the next steps/commands for your new stack in the
NEXT_STEPSobject inbin/cli.jsso they print properly at the end.
5. Publishing Changes to NPM
- Make sure your local tests pass.
- Increment the version number in
package.json(e.g., from1.2.1to1.2.2or1.3.0). - Publish the package:
npm login npm publish
License
MIT
