A professional, modular starter kit for building powerful APIs with Node.js and TypeScript
- Modular Architecture – Clean and scalable code with modules (user, auth, role, product)
- JWT Authentication – Secure login and registration with tokens
- TypeORM Integration – Easy work with relational databases (PostgreSQL/MySQL)
- Auto-generated Documentation – Swagger UI for testing and documenting your API at
/api-docs - Centralized Error Handling – Handle errors in one place with a dedicated middleware
- Auto-create Database – Creates the database on first run if it doesn't exist
- Seed Scripts – Populate the database with initial data (available in commits)
- Environment Variables – Easy configuration with dotenv and
.envfile - TypeScript – Type-safe code with better development experience
- Hot Reload – Use
ts-node-devin development mode
| Area | Technology |
|---|---|
| Language | TypeScript |
| Framework | Express.js |
| ORM | TypeORM |
| Database | PostgreSQL / MySQL |
| Documentation | Swagger (OpenAPI) |
| Authentication | JWT + bcrypt |
| Environment | dotenv |
| Code Formatter | Prettier |
- Node.js (version 16 or higher)
- npm or yarn
- PostgreSQL or MySQL (installed and running)
1️⃣ Clone the repository
git clone https://github.com/Morez-Momeni/nodejs-api-astek.git
cd nodejs-api-astek2️⃣ Install dependencies
npm install
# or
yarn install3️⃣ Set up environment variables
Copy .env.example to .env and fill in your values (port, database credentials, JWT secret):
cp .env.example .env
4️⃣ Run the project
# Development mode
npm run dev
# Build the project
npm run build
# Run production version
npm start
The server will start at http://localhost:3000
Once the project is running, you can view the complete API documentation at:
- http://localhost:3000/api-docs
- This documentation is automatically generated by Swagger and includes all endpoints, request examples, and responses.
| Route | Description |
|---|---|
| /api/auth | Registration, login, token management |
| /api/users | User management |
| /api/roles | TypeORM |
| /api/products | Product management |