DEV Community

Petar Stevovski
Petar Stevovski

Posted on • Updated on

Generate NodeJS / Express project

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.

Alt Text

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
Enter fullscreen mode Exit fullscreen mode

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.

Top comments (3)

Collapse
 
sroehrl profile image
neoan

Nice project! I gladly give it a try

Some comments may only be visible to logged-in visitors. Sign in to view all comments.