create-node-sequelize-app
v1.0.1
Published
A boilerplate for creating a new node sequelize app
Maintainers
Readme
create-node-sequelize-app
A CLI tool to generate a complete Node.js project boilerplate with Sequelize. Perfect for kickstarting your application with an organized and scalable structure.
Features
- Pre-configured Sequelize integration for MySQL, PostgreSQL, or other supported databases.
- Clean and modular folder structure for scalable applications.
- Includes configurations for environment variables, middlewares, and validations.
- Provides ready-to-use routes, controllers, and models.
- Designed for RESTful API development.
Folder Structure
The generated project includes the following structure:
node-sequelize-app/
├── config/ # Database configuration files
├── controllers/ # Business logic for routes
├── middlewares/ # Custom middleware for request handling
├── migrations/ # Sequelize migrations
├── models/ # Sequelize models
├── routes/ # API routes
├── seeders/ # Database seeders
├── services/ # Service layer for reusable logic
├── utils/ # Utility functions
├── validations/ # Input validation schemas
├── .env.example # Sample environment variables file
├── index.js # Application entry point
├── package.json # Project metadata and dependencies
├── package-lock.json # Dependency lock file
└── README.md # Project documentationInstallation
Install the package globally:
npm install -g create-node-sequelize-appUsage
Generate a new project by running:
npx create-node-sequelize-app my-appThis will create a new directory named my-app with the above folder structure.
Getting Started
Navigate to the project directory:
cd my-appInstall dependencies:
npm installConfigure your database settings:
Copy
.env.exampleto.envand update the values according to your database configuration.Example:
NODE_ENV=development JWT_SECRET=JWT_SECRET JWT_EXPIRE_IN=1h PORT=5000
Adjust the
config.jsonfile in theconfig/folder as needed. Example configuration for the development environment:{ "development": { "username": "newuser", "password": "password", "database": "local_database_test", "host": "127.0.0.1", "dialect": "mysql" } }Run migrations to set up your database schema:
npx sequelize-cli db:migrateStart the development server:
npm start
Commands
npm run dev: Start the application in development mode with live reload.npx sequelize-cli db:migrate: Apply database migrations.npx sequelize-cli db:seed:all: Seed the database with initial data.npm run lint: Check and fix linting issues (if ESLint is set up).
Customization
You can easily extend the project by adding:
- New routes in the
routes/folder. - New controllers for business logic in
controllers/. - Validation schemas for input validation in
validations/. - Utilities for shared functions in
utils/.
Contributing
Contributions are welcome! Feel free to fork the repository, create a branch, and submit a pull request.
License
This project is licensed under the MIT License. See the LICENSE file for details.
