express-genie
v2.1.4
Published
This library was made for automating repetitive express routines. Made by Syed Abrar Ali and Jawad Shaikh
Downloads
9
Readme
This is a Node.js module available through the npm registry.
If this is a brand new project, make sure to create a package.json first with the npm init command.
Installation is done using the npm install command:
npm install express-genie --save-dev
After installing, run:
npm run setup
After running this command you should see the following files created in root directory:
- server.js //entry point for project
- app.js
- .env
- .env.development
- .env.staging
and folders:
- config
- middleware
- constants
also your package.json file will also be updated to include scripts and dependencies and will look like:
"scripts": {
"setup": "node ./node_modules/express-genie/index.js",
"dev": "set NODE_ENV=development&& nodemon server.js",
"stage": "set NODE_ENV=staging&& nodemon server.js",
"deploy": "node server.js"
},
"dependencies": {
"joi": "^17.9.1",
"express": "^4.18.2",
"cors": "^2.8.5",
"dotenv": "^16.0.3",
"mysql2": "^3.1.2"
},
"devDependencies": {
"express-genie": "^1.3.0",
"nodemon": "^2.0.22"
}
npm run setup will only work once, meaning if you have run it once, it will not have any effect the next time you run this command. Run npm install to install the dependencies
npm install
Now you are good to go and have a basic express structure ready.
Run npm run setup auth to create auth routes and all its folders.
Five new folders will be created,
- routes //for route handling
- controllers //for handling response
- services //for business logic
- validations //incoming request validations
- helpers //helping functions
and app.js file will be updated to include the new created route. Remember to install the new dependencies added in package.json file by running npm i
Auth will have four routes
- sign-up
- login
- forgot-password
- reset-password
To create a new entity route and all its respective folders run npm run setup [entityName] without square brackets
npm run setup [your entity name here]
Every entity route will have five routes
- get-all
- get-single
- create
- update
- delete
For every new entity route just run the previous command with replacing the entity name. Enjoy!
Authors
Contributing
Contributions are always welcome! Feel free to contact us if you find any bugs or have any suggestions