Generate NodeJS / Express project
Petar Stevovski
Posted on January 20, 2021
I've made a simple CLI program that helps you generate your NodeJS / Express project structure, based on your selected configuration.
You can check it out here: express-app-cli.
It creates the following project structure:
tests/ - Unit and integration tests
views/ - If using view engines (pug, handlebars etc.)
src/
app.ts - Main entry point of the application
api/
index.js - Main entry point for all defined routes
routes/ - All the routes go in this folder
services/ - Business logic
controllers/ - Route controllers (handlers)
config/ - ENV's and other configuration related stuff
loaders/ - Splitting the start up process (express, database connection, CRON jobs etc.)
models/ - Database models
middlewares/ - All custom middlewares (authentication, authorization etc.)
utils/ - Utility functions (e.g. validations)
jobs/ - CRON jobs
types/ - All the types and interfaces that we'll use
It currently supports a couple of configuration options:
- Languages: Javascript, Typescript
- Databases: MongoDB, MySQL, Postgres, SQLite
- Testing libraries: Jest, Chai, Mocha
- Templating engines: Handlebars, PUG, EJS
- ORMs:
- Mongoose (installed by default with MongoDB)
- Sequelize
- TypeORM
You can install it globally trough:
npm install -g express-app-cli
yarn add global express-app-cli
Then to use it:
express-app < project-directory > [options]
It still has some work to be done (testing, refactoring). If you have any ideas, or find any bugs, feel free to open a PR / Issue.
💖 💪 🙅 🚩
Petar Stevovski
Posted on January 20, 2021
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.