minhuyen / Generator Expressjs Rest
Programming Languages
Projects that are alternatives of or similar to Generator Expressjs Rest
Generator Expressjs Rest
Features
- User Registration
- Basic Authentication with username and password
- Admin use react-admin
- Oauth 2.0 Authentication
- Upload Photo to S3 amazon
- Docker
Prerequisites
Installation
Fist, install Yeoman and generator-expressjs-rest using npm (we assume you have pre-installed node.js).
npm install -g yo
npm install -g generator-expressjs-rest
Generators
Then, you can use yo
to generate your project.
yo expressjs-rest # generate a new project
yo expressjs-rest:api # generate a new api endpoint inside your project
Commands
After you generate your project, these commands.
cd your-project-name
mv .env.example .env
docker-compose build
docker-compose run --rm client yarn build
docker-compose up
Playing locally
Deploy
Directory structure
Overview
src/
โโ api/
โ โโ auth/
โ โ โโ auth.controller.js
โ โ โโ auth.service.js
โ โ โโ auth.validation.js
โ โ โโ index.js
โ โ โโ index.test.js
โ โโ uploads/
โ โ โโ index.js
โ โ โโ upload.controller.js
โ โโ users/
โ โ โโ index.js
โ โ โโ user.controller.js
โ โ โโ user.validation.js
โ โ โโ user.model.js
โ โ โโ user.service.js
โ โ โโ user.test.js
โ โโ index.js
โโ services/
โ โโ index.js
โ โโ jwt.js
โ โโ logger.js
โ โโ mailgun.js
โ โโ mongoose.js
โ โโ passport.js
โ โโ response.js
โ โโ s3.js
โ โโ swagger.js
โ โโ your-service.js
โโ app.js
โโ config.js
โโ index.js
src/api/
Here is where the API endpoints are defined. Each API has its own folder.
src/api/some-endpoint/model.js
It defines the Mongoose schema and model for the API endpoint. Any changes to the data model should be done here.
src/api/some-endpoint/controller.js
This is the API controller file. It defines the main router middlewares which use the API model.
src/api/some-endpoint/index.js
This is the entry file of the API. It defines the routes using, along other middlewares (like session, validation etc.), the middlewares defined in the some-endpoint.controller.js
file.
services/
Here you can put helpers
, libraries
and other types of modules which you want to use in your APIs.
TODO
- Support optional phone authentication
- Support optional email confirmation process
- Support Twitter and other social login methods
- Socket.io support
PRs are welcome.
Credits
@minhuyen and all contributors
License
MIT ยฉ minhuyen