1.9.0 • Published 9 months ago

generator-expressjs-rest v1.9.0

Weekly downloads
11
License
ISC
Repository
github
Last release
9 months ago

Generator Expressjs Rest

Build Status

Features

  • User Registration
  • Basic Authentication with username and password
  • Admin use react-admin
  • Oauth 2.0 Authentication
    • Facebook
    • Google
  • 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/
│  │  ├─ index.js
│  │  ├─ auth.service.js
│  │  ├─ auth.validation.js
│  │  ├─ auth.controller.js
│  │  └─ auth.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

1.9.0

9 months ago

1.8.1

10 months ago

1.8.0

10 months ago

1.7.5

11 months ago

1.7.3

2 years ago

1.7.2

2 years ago

1.7.1

2 years ago

1.7.0

2 years ago

1.6.4

2 years ago

1.6.3

2 years ago

1.6.2

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

1.5.8

2 years ago

1.6.5

2 years ago

1.5.7

2 years ago

1.5.5

3 years ago

1.5.6

3 years ago

1.5.3

3 years ago

1.5.2

3 years ago

1.5.1

4 years ago

1.5.0

4 years ago

1.4.2

4 years ago

1.4.1

4 years ago

1.4.0

4 years ago

1.3.3

4 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.5

5 years ago

1.2.4

5 years ago

1.2.3

5 years ago

1.2.2

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago