A boilerplate Node.js application using TypeScript, Express, Sequelize, and PostgreSQL. This repository provides a robust starting point for building scalable and maintainable RESTful APIs with TypeScript, leveraging Sequelize as an ORM for database operations.
This project aims to provide a solid foundation for developers to quickly set up and start developing server-side applications using Node.js and TypeScript. It includes essential features and configurations like environment management, database migrations, and seeders, making it ideal for production-ready applications.
- TypeScript: Strongly typed language support for better code quality and maintainability.
- Express: Lightweight and flexible web framework for building robust APIs.
- Sequelize: Powerful ORM for managing database operations with support for PostgreSQL.
- dotenv: Environment variable management to keep sensitive data secure.
- Migrations and Seeders: Built-in scripts for managing database schema and populating initial data.
- Modular Structure: Clear separation of concerns with services, controllers, and routes for easy scalability.
- ESLint and Prettier: Code quality and formatting tools to maintain a consistent codebase.
- Jest: Integrated testing framework for unit and integration tests.
```bash /node-typescript-sequelize |-- /src | |-- app.ts # Main application entry point | |-- /controllers # API controllers | |-- /routes # API routes | |-- /services # Business logic and service layer |-- /models # Sequelize models |-- /config # Configuration files |-- /migrations # Database migration files |-- /seeders # Database seeder files |-- /dist # Compiled JavaScript output |-- .env # Environment variables |-- .gitignore # Git ignore file |-- .sequelizerc # Sequelize CLI configuration |-- package.json # Node.js dependencies and scripts |-- tsconfig.json # TypeScript compiler options |-- yarn.lock # Yarn lockfile ```
- Node.js (>= 14.x)
- Yarn (Package manager)
- PostgreSQL (Database)
Clone the repository:
```bash git clone https://github.com/BilalSaeedAlam/node-typescript-sequelize.git cd node-typescript-sequelize ```
Install dependencies:
```bash yarn install ```
Create a .env
file in the root directory and configure your environment variables as shown in the .env.example
file.
Compile TypeScript files to JavaScript:
```bash yarn build ```
Set up your database schema with Sequelize migrations:
```bash yarn migrate ```
Populate the database with initial data:
```bash yarn seed ```
Start the application server:
```bash yarn start ```
Alternatively, run the application in development mode with auto-reloading:
```bash yarn dev ```
The application is set up with a basic REST API structure for user management. You can expand the API by adding new routes, controllers, and services as needed.
Feel free to contribute by submitting issues, suggesting features, or creating pull requests. All contributions are welcome!
This project is licensed under the MIT License. See the LICENSE file for more details.