@shuraim_khan/backend-starter
v1.0.3
Published
Backend starter scaffold CLI (Prisma/Mongoose + Mongo/SQL) with auth, upload, security, websocket, and error logging foundations.
Maintainers
Readme
Node Backend Starter (Script-Driven DB Stack)
This starter is reduced to core foundations and uses a setup script to generate the database stack files.
Core foundations included:
- Simple auth APIs
- Minimal Express app structure
- Global error handler with DB logging
- Security middleware stack
- File upload API (local or S3)
- Email service foundation (SendGrid or SMTP)
- Basic WebSocket service foundation
Included APIs
Base path: /api/auth
POST /registerPOST /loginGET /me(Bearer token required)
Base path: /api/file
POST /upload(form-data withfilefield)
Error Logging
All errors are handled globally by the central error middleware and saved in MongoDB using Prisma.
- HTTP request errors are stored with endpoint and method details.
- Process-level errors (
uncaughtException,unhandledRejection) are also stored. - Logs are saved in the
error_logscollection.
Email Service
The project includes a base email service at src/services/email.service.js with two providers:
- SendGrid (
SENDGRID_API_KEY,SENDGRID_FROM_EMAIL) - SMTP (
SMTP_HOST,SMTP_PORT,SMTP_USER,SMTP_PASS)
WebSocket Structure
The project includes a basic Socket.IO structure at src/services/websocket.service.js.
- Initialized on server startup
- Supports user room join via
join:user - Includes
emitToUser(userId, event, payload)helper
Tech Stack
- Express
- Prisma
- MongoDB
- JWT
- bcrypt
Quick Start
Use As NPM Package
After publishing this package, users can scaffold directly in the current folder with one command:
npx @shuraim_khan/backend-starter --name=my-project --stack=prisma-mongoThis command:
- asks/sets project name
- configures selected stack
- creates starter files directly in current folder
- does not install dependencies automatically
Supported stack values:
prisma-mongomongoose-mongoprisma-sql
You can also run interactively:
npx @shuraim_khan/backend-starterRun the interactive DB stack wizard first:
npm run setup:dbOr run one command (interactive setup):
npm run setup:oneOr full non-interactive one command:
npm run setup:db -- --name=my-project --stack=prisma-mongoSupported stack values:
prisma-mongomongoose-mongoprisma-sql
The wizard will:
- ask for your project name (updates
package.jsonname) - ask for DB stack
- generate files directly in the current folder (no new folder is created)
It supports:
- Prisma + MongoDB
- Mongoose + MongoDB
- Prisma + SQL (PostgreSQL)
- Install dependencies
npm install- Create env file
cp .env.example .env- Run app
npm run devEnvironment Variables
PORT=3000
NODE_ENV=development
DATABASE_URL="mongodb://localhost:27017/flowgo"
JWT_SECRET=your_jwt_secret
JWT_EXPIRES_IN=24h
USE_S3=false
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_REGION=us-east-1
AWS_S3_BUCKET=
B2_S3_ENDPOINT=
API_URL=http://localhost:3000Scripts
npm run setup:dbnpm run devnpm start
If you choose a Prisma option in setup, Prisma scripts are added automatically by the setup wizard.
Project Structure
prisma/
schema.prisma
src/
config/
controllers/
middleware/
routes/
services/
utils/
server.js