Key Features β’ How To Use β’ Creator β’ Contribute β’ License
https://www.npmjs.com/package/express-booster
- project structure generation with Services ,Models, Controllers and Routers
- auto-required Routes using a user specified endpoint and the Route file name
eg (route : users.js and endpoint: /api this will automount to /api/users)
- fully implemented Authentication using Passport-jwt
- suppports mongodb mongoose
- automatic integration with passport-mongoose
- helmet package for a more secure express app
- cors support
- morgan support for logging
- nodemon support for Dev
Contents
of this documentation.
npm i express-booster -g
- fillout the Configuration at /src/config/config.js:
module.exports = {
db: {
dbHostName: "localhost",
dbPort: 27017,
dbName: "HelloWorld",
},
hostname: "localhost",
port: process.env.PORT || 8081,
secretKey: "_Fill_ME_",
};
));
- Clone this repo to your local machine using
https://github.com/Samielleuch/express-booster.git
- In order to use this CLI package simply:
$ express-booster
specify the project name to the CLI tool this will create the folder for your project
make sure the Folder doesn't already exist
specify included packages with < space > according to the chosen options this will generate your project
-
choosing passport-jwt generates /services/passportService.js
-
choosing mongoose generates /models/user.js
-
choosing mongoose and passport-jwt generates :
- /routers/routes/HelloWorld.js
- /routers/routes/users.js
- /controllers/helloWorldController.js
- /controllers/authController.js
- using passport-jwt and mongoose will autogenerate the following routes:
lets call Main_endpoint the endpoint created when calling the cli app (defaults to /)
- POST Main_endpoint/users/signin
- POST Main_endpoint/users/signUp
these endpoints use the authController and the users route to create jwt authentication login and signup
{
"name" : "test" ,
"phone": 123456789 ,
"password" : "test"
}
{
"success": true,
"status": "Registration Successful!"
}
{
"name" : "test" ,
"phone": 123456789 ,
"password" : "test"
}
{
"success": true,
"token": "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZjAzOGI3YWM4YTYxZTE4YzVlNDlmM2QiLCJpYXQiOjE1OTQwNjgxMjIsImV4cCI6MTU5NDA3MTcyMn0.Ko2GhbRHpS8Q5i9wBDryYNhYdCbZlir-6iOfRsz1GOE",
"user": {
"admin": false,
"_id": "5f038b7ac8a61e18c5e49f3d",
"name": "test",
"phone": 123456789,
"__v": 0
}
}
- GET Main_endpoint/HelloWorld
- GET Main_endpoint/HelloWorld/protected
this endpoint simulates a protected data using jwt tokens you need to specify jwt token in Header to access the protected resource
Key | Value |
---|---|
Authorization | Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJfaWQiOiI1ZjAzOGI3YWM4YTYxZTE4YzVlNDlmM2QiLCJpYXQiOjE1OTQwNjgxMjIsImV4cCI6MTU5NDA3MTcyMn0.Ko2GhbRHpS8Q5i9wBDryYNhYdCbZlir-6iOfRsz1GOE |
{
"msg": "Hello World with jwt :D "
}
This is an opensource project every help would be greatly appreciated To get started...
-
Option 1
- π΄ Fork this repo!
-
Option 2
- π― Clone this repo to your local machine using
https://github.com/Samielleuch/express-booster.git
- π― Clone this repo to your local machine using
- HACK AWAY! π¨π¨π¨
- π Create a new pull request using
https://github.com/Samielleuch/express-booster/compare/
.
- If you want to help, you can contact me at anytime.
Give it a try , Every FeedBack is very appreciated
Reach out to me at one of the following places!
- Email at
[email protected]
- Facebook at
facebook.com/sami.elleuch.2
- MIT license
- Copyright 2020 Β© Sami Elleuch.