oauth2-nodejs-sample
Background
Using the example made by koa2 and oauth2, the project uses mongodb and redis for data management, in which mongodb performs data query, and redis manages the token in oauth2;
Installation
This project uses node and npm. Please make sure you install them locally -Use npm
$ npm i
-Or yarn, of course tyarn is recommended for inland China
$ npm install yarn -g
$ yarn
How to run
Run
$ yarn run start
Pack and run
$ yarn run prod # Need to install pm2
-Access in browser
http://localhost:7001
Project structure
|-- .eslintignore
|-- .eslintrc
|-- .gitignore
|-- app.js
|-- package.json
|-- readme-zh.md
|-- readme.md
|-- bin
| |-- www
|-- public
|-- src
| |-- config
| | |-- index.js
| |-- mongoose
| | |-- index.js
| | |-- models
| | |-- clientModel.js
| | |-- userModel.js
| |-- oauth
| | |-- compatibleTokenError.js
| | |-- errorCode.js
| | |-- index.js
| | |-- model.js
| |-- redis
| | |-- index.js
| |-- routes
| | |-- index.js
| | |-- router.spec.js
| |-- utils
| |-- errorHandle.js
| |-- httpException.js
| |-- log4j.js
| |-- res.js
| |-- tool.js
| |-- tool.spec.js
|-- test
|-- restClient.http
Structure description
- config: configuration file, please refer to ioredis, log4js, mongoosejs
- mongoose: Process all operations of mongoose
- oauth: handle oauth2 authentication, currently supported modes are: password and refresh_token
- redis: Process redis requests
- routes: Process routing
- util: all tools
- test/restClient.http: simple request example
Maintainer
How to contribute
You are very welcome to join! Mention a Issue or submit a Pull Request. The standard Readme follows the Contributor Covenant code of conduct.
License
MIT @yy921010