barnes-node-ts-express-starter
v1.0.3
Published
A modern Node.js TypeScript Express starter template with essential development tooling
Maintainers
Readme
Barnes Node.js TypeScript Express Starter
A modern, production-ready Node.js backend starter template with TypeScript, Express, and essential development tooling. Get up and running in seconds with a well-structured, scalable backend foundation.
🚀 Quick Start
Create a new backend project instantly using npx:
npx barnes-node-ts-express-starterFollow the prompts to:
- Enter your project name
- Navigate to the created directory
- Install dependencies
- Start developing!
cd your-project-name
npm install
npm run devYour server will be running at http://localhost:3001 🎉
✨ Features
- TypeScript: Full TypeScript support with strict configuration
- Express.js: Fast, minimalist web framework
- Hot Reload: Automatic server restart on file changes with nodemon
- Environment Management: Flexible environment configuration
- Modern ES Modules: Uses ES6 import/export syntax
- Health Check: Built-in status endpoint for monitoring
- Production Ready: Includes build scripts and optimized configuration
- Clean Architecture: Well-organized project structure
📁 Project Structure
your-project/
├── src/
│ ├── app.ts # Express app configuration
│ ├── server.ts # Server entry point
│ ├── config/
│ │ └── env.ts # Environment configuration
│ └── routes/
│ ├── index.ts # Main router
│ └── status.ts # Health check endpoint
├── dist/ # Compiled JavaScript (after build)
├── nodemon.json # Nodemon configuration for development
├── nodemon.local.json # Nodemon configuration for local env
├── tsconfig.json # TypeScript configuration
├── package.json # Dependencies and scripts
└── README.md # This file🛠 Available Scripts
npm run dev- Start development server with hot reload (NODE_ENV=development)npm run dev:local- Start development server in local mode (loads .env file)npm run build- Compile TypeScript to JavaScriptnpm start- Start production server from compiled code
🔧 Environment Configuration
The starter supports multiple environment modes:
Development Mode
npm run dev- Uses
NODE_ENV=development - No .env file loading (uses system environment variables)
Local Mode
npm run dev:local- Uses
NODE_ENV=local - Automatically loads
.envfile for local development - Create a
.envfile in your project root:
PORT=3001
APP_MESSAGE=Hello from local development!Production
npm run build
npm start- Runs compiled JavaScript from
dist/folder - Uses production environment variables
📡 API Endpoints
Health Check
- GET
/status- Returns server health information
Example response:
{
"uptime": 123.456,
"message": "OK",
"timestamp": 1674567890123
}🚀 Getting Started with Development
Add new routes: Create new route files in
src/routes/and register them insrc/routes/index.tsEnvironment variables: Add your variables to the
.envfile for local developmentMiddleware: Add Express middleware in
src/app.tsConfiguration: Modify environment loading in
src/config/env.ts
📦 Dependencies
Production Dependencies
- express: Fast, unopinionated web framework
- dotenv: Loads environment variables from .env file
Development Dependencies
- typescript: TypeScript compiler
- @types/express: TypeScript definitions for Express
- nodemon: Monitors file changes and restarts server
- tsx: TypeScript execution engine
- cross-env: Cross-platform environment variable setting
🔄 Customization
Adding Database Support
# Example: Adding MongoDB with Mongoose
npm install mongoose
npm install -D @types/mongooseAdding Authentication
# Example: Adding JWT authentication
npm install jsonwebtoken bcryptjs
npm install -D @types/jsonwebtoken @types/bcryptjsAdding Validation
# Example: Adding request validation
npm install joi
npm install -D @types/joi📋 Best Practices Included
- TypeScript strict mode for better code quality
- ES Modules for modern JavaScript features
- Modular routing for scalable code organization
- Environment-based configuration for different deployment stages
- Health check endpoint for monitoring and load balancers
- Development tooling with hot reload and TypeScript watching
🤝 Contributing
This starter template is designed to be a solid foundation for Node.js backend projects. Feel free to customize it according to your needs!
📝 License
MIT License - feel free to use this starter for your projects!
Happy coding! 🎯
Built with ❤️ for rapid backend development
