Package Exports
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (create-node-backend-ts) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
create-node-backend-ts
A CLI tool to scaffold a complete Node.js + TypeScript backend with modern best practices.
Generate a ready-to-use backend with:
- Express for HTTP server
- TypeScript with strict typing
- MongoDB integration using Mongoose
- Logging via Winston with daily rotated logs
- Global Error Handler for centralized error management
- Async Handler Wrapper to simplify async route handling
- Environment Configuration via
.envfiles - Request Validation using Joi
- Organized Route / Controller / Service structure
Perfect for rapid backend project setup with minimal boilerplate.
🚀 Installation (No global install needed)
Run the generator using npx:
npx create-node-backend-ts my-backendOr using yarn:
yarn create node-backend my-backendOr using pnpm:
pnpm dlx create-node-backend-ts my-backendmy-backend will be the folder name of your new project.
📦 After Generating Project
cd my-backend # Go into your project folder
npm install # Install dependencies
npm run dev # Start the development serverDevelopment mode uses tsx watch (if configured) or ts-node-dev.
Logs will be written to logs/ folder, with console output only in development.
🗂 Project Structure
Example of the generated backend structure:
my-backend/
├─ logs/ # Rotated log files
├─ src/
│ ├─ controllers/ # Route handlers
│ ├─ services/ # Business logic
│ ├─ routes/ # API routes
│ ├─ middlewares/ # Error handler, async wrapper
│ ├─ utils/ # Logger, helpers, etc.
│ └─ server.ts # Entry point
├─ package.json
├─ tsconfig.json
├─ .env # Environment variables
└─ README.md⚙ Features
Global Error Handling
All errors in routes are caught and sent in a structured JSON format.
Async Route Wrapper
Avoid repetitive try-catch blocks in async routes.
Validation with Joi
Request payloads can be validated easily with reusable schemas.
Logging with Winston
Daily rotated log files (logs/)
Console logging only in development mode
Environment Variables
Load .env files automatically with dotenv.
💡 Tips
Add .env for sensitive configs like MONGO_URI, PORT, etc.
In production, use file logs only, console logs are for development.
Extend controllers/services as needed — template is modular.