generator-lazy-backend
v1.1.0
Published
A simple generator to create a backend using NodeJS, Express.js and Mongoose
Downloads
1
Maintainers
Readme
generator-lazy-backend
A simple generator to create a backend using NodeJS, Express.js and Mongoose
This generator is highly inspired by JHipster
There is an entity generator available as well
Video exemple
About the project
Database
The project is using MongoDB as its database
HTTP Request Handling
The project is using ExpressJS as its Request Handling
Where the project can be used
The focus is to use for small objectives
Prerequisites
Yeoman
- You need to have yeoman installed. If you don't have it, type the following command:
npm i -g yo
Database
- You need to have MongoDB running to be able to start the project after creation, but IT'S NOT REQUIRED WHEN CREATING THE PROJECT
- If you have Docker installed you can download a mongo image, just type the following command
docker run --name mongodb -p 27017:2017 -d -t mongo
Installation
You can install the package from npm
npm i -g generator-lazy-backend
Usage
run the generator
yo lazy-backend
After the project creation
Just type the following command
npm start
Remember to have MongoDB started
The MongoDB port by default is 27017, if you use a diferent port you can change it on .env file
Entity Generator
This generator creates only the base project. There is an entity generator available for you.
You can install the package from npm
npm i -g generator-lazy-backend-entity
You can access it's GitHub to learn how to use it
Project struct
[+] indicates that it is a folder
|-- Project-Name[+]
|-- src[+]
|-- app[+]
|-- controllers[+]
|-- middlewares[+]
|-- models[+]
|-- validators[+]
|-- config[+]
|-- index.js
|-- routes.js
|-- server.js
|-- package.json
|-- package-lock.json
|-- .editorconfig
|-- .env
|-- .eslintrc.json
|-- .gitignore
If you want to check how the genereted project is, you can check this github
Project Dependencies
- bcrypt
- Responsible for encrypting the user's password
- Only added if you add JWT validations
- npm
- jsonwebtoken
- Makes possible to create a JWT Token
- Only added if you add JWT validations
- npm
- dotenv
- Permit the posibilite to use environment variables
- npm
- express
- Handles HTTP requests
- npm
- express-async-handler
- As described by the developers:
Simple middleware for handling exceptions inside of async express routes and passing them to your express error handlers
- express-validation
- Use the joi validations, if the validation fails a response with error is returned
- npm
- joi
- Responsible to validate the fields
- npm
- mongoose
- MongoDB ODM for NodeJS
- npm
- mongoose-paginate
- Do the pagination
- npm
- require-dir
- Reduce the amount of require() you will make
- npm
- youch
- Makes NodeJS' error more readable
- npm
Dev-Dependencies
- eslint
- Lint the code
- Use the standard configuration
- npm
- nodemon
- Restarts the application when a file change occurs
- npm
Author
Mateus Gomems da Silva Cardoso | [email protected]