├── .autod.conf.js ├── .eslintrc ├── .github └── PULL_REQUEST_TEMPLATE.md ├── .gitignore ├── History.md ├── LICENSE ├── README.md ├── boilerplate ├── .autod.conf.js ├── .eslintignore ├── .eslintrc ├── README.md ├── _.gitignore ├── _package.json ├── app │ ├── controller │ │ └── home.js │ └── router.js ├── assembly │ ├── dubbo-demo-api-1.0-SNAPSHOT-sources.jar │ └── dubbo-demo-api-1.0-SNAPSHOT.jar ├── config │ ├── config.default.js │ ├── plugin.js │ └── proxy.js └── test │ └── app │ └── controller │ └── home.test.js ├── index.js └── package.json /.autod.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | write: true, 5 | prefix: '^', 6 | devprefix: '^', 7 | exclude: [ 8 | 'test/fixtures', 9 | 'boilerplate', 10 | 'dist', 11 | ], 12 | devdep: [ 13 | 'autod', 14 | 'autod-egg', 15 | 'eslint', 16 | 'eslint-config-egg', 17 | 'egg-ci', 18 | 'egg-init', 19 | 'npminstall', 20 | 'webstorm-disable-index', 21 | ], 22 | keep: [], 23 | semver: [], 24 | }; 25 | -------------------------------------------------------------------------------- /.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint-config-egg" 3 | } 4 | -------------------------------------------------------------------------------- /.github/PULL_REQUEST_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | 10 | 11 | ##### Checklist 12 | 13 | 14 | - [ ] `npm test` passes 15 | - [ ] tests and/or benchmarks are included 16 | - [ ] documentation is changed or added 17 | - [ ] commit message follows commit guidelines 18 | 19 | ##### Affected core subsystem(s) 20 | 21 | 22 | 23 | ##### Description of change 24 | 25 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | coverage 2 | .logs 3 | npm-debug.log 4 | npm-debug.log.* 5 | .tmp 6 | tmp 7 | dist 8 | .idea/ 9 | node_modules 10 | logs 11 | run 12 | *.sw* 13 | *.un~ 14 | -------------------------------------------------------------------------------- /History.md: -------------------------------------------------------------------------------- 1 | 2 | 1.2.0 / 2018-11-30 3 | ================== 4 | 5 | **others** 6 | * [[`14746f6`](http://github.com/eggjs/egg-boilerplate-microservice/commit/14746f6bbfe1105924e71f84cb76053a16f51833)] - chore: upgrade egg-cloud to 0.2.0 (#6) (zōng yǔ <>) 7 | 8 | 1.1.1 / 2018-11-03 9 | ================== 10 | 11 | **fixes** 12 | * [[`0b2252f`](http://github.com/eggjs/egg-boilerplate-microservice/commit/0b2252ff7af73edaa7665a3dbc837baf1b079a58)] - fix: template bug (#5) (zōng yǔ <>) 13 | 14 | 1.1.0 / 2018-11-03 15 | ================== 16 | 17 | **features** 18 | * [[`e3c6f6a`](http://github.com/eggjs/egg-boilerplate-microservice/commit/e3c6f6aca007b6cceb91e6a77d1e12bf0476766c)] - feat: use egg-cloud instead of sofa-node (#4) (zōng yǔ <>) 19 | 20 | **fixes** 21 | * [[`1fc8904`](http://github.com/eggjs/egg-boilerplate-microservice/commit/1fc8904a90b6dbcdfd2c26b8b82988366c6f9486)] - fix: typo bug (#3) (lewis liu <<897473127@qq.com>>) 22 | 23 | 1.0.0 / 2018-10-12 24 | ================== 25 | 26 | **others** 27 | * [[`baa6c5b`](http://github.com/eggjs/egg-boilerplate-microservice/commit/baa6c5b245b0af952b6b61a259ef62bd6b90f9ce)] - chore: use sofa-node instead of sofa-node-demo (gxcsoccer <>) 28 | 29 | 0.0.1 / 2018-10-10 30 | ================== 31 | 32 | **fixes** 33 | * [[`bfacd16`](http://github.com/eggjs/egg-boilerplate-microservice/commit/bfacd16ae4a922f44b7c2408ad92a8322f4b4e85)] - fix: remove package files (gxcsoccer <>) 34 | 35 | 0.0.0 / 2018-10-10 36 | ================== 37 | 38 | **others** 39 | * [[`4575c90`](http://github.com/eggjs/egg-boilerplate-microservice/commit/4575c9082959eb34f29bb67f25ececc0808c1304)] - chore: init commit (gxcsoccer <>),fatal: 没有发现名称,无法描述任何东西。 40 | 41 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) 2017 Alibaba Group Holding Limited and other contributors. 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # egg-boilerplate-microservice 2 | 3 | Boilerplate for egg microservice. 4 | 5 | [![NPM version][npm-image]][npm-url] 6 | [![build status][travis-image]][travis-url] 7 | [![Test coverage][codecov-image]][codecov-url] 8 | [![David deps][david-image]][david-url] 9 | [![Known Vulnerabilities][snyk-image]][snyk-url] 10 | [![npm download][download-image]][download-url] 11 | 12 | [npm-image]: https://img.shields.io/npm/v/egg-boilerplate-microservice.svg?style=flat-square 13 | [npm-url]: https://npmjs.org/package/egg-boilerplate-microservice 14 | [travis-image]: https://img.shields.io/travis/eggjs/egg-boilerplate-microservice.svg?style=flat-square 15 | [travis-url]: https://travis-ci.org/eggjs/egg-boilerplate-microservice 16 | [codecov-image]: https://img.shields.io/codecov/c/github/eggjs/egg-boilerplate-microservice.svg?style=flat-square 17 | [codecov-url]: https://codecov.io/gh/eggjs/egg-boilerplate-microservice 18 | [david-image]: https://img.shields.io/david/eggjs/egg-boilerplate-microservice.svg?style=flat-square 19 | [david-url]: https://david-dm.org/eggjs/egg-boilerplate-microservice 20 | [snyk-image]: https://snyk.io/test/npm/egg-boilerplate-microservice/badge.svg?style=flat-square 21 | [snyk-url]: https://snyk.io/test/npm/egg-boilerplate-microservice 22 | [download-image]: https://img.shields.io/npm/dm/egg-boilerplate-microservice.svg?style=flat-square 23 | [download-url]: https://npmjs.org/package/egg-boilerplate-microservice 24 | 25 | ## Installation 26 | 27 | **Don't `npm i` this directly** 28 | 29 | ```bash 30 | $ npx egg-init --type=microservice showcase 31 | $ cd showcase 32 | $ npm i 33 | $ npm run init && npm run dev 34 | $ open http://localhost:7001 35 | ``` 36 | 37 | See [egg-init](https://github.com/eggjs/egg-init) for more detail. 38 | -------------------------------------------------------------------------------- /boilerplate/.autod.conf.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | write: true, 5 | prefix: '^', 6 | plugin: 'autod-egg', 7 | test: [ 8 | 'test', 9 | 'benchmark', 10 | ], 11 | dep: [ 12 | 'egg-cloud', 13 | 'egg-scripts', 14 | ], 15 | devdep: [ 16 | 'egg-ci', 17 | 'egg-bin', 18 | 'egg-mock', 19 | 'autod', 20 | 'autod-egg', 21 | 'eslint', 22 | 'eslint-config-egg', 23 | 'egg-rpc-generator', 24 | 'webstorm-disable-index', 25 | ], 26 | exclude: [ 27 | './test/fixtures', 28 | './dist', 29 | ], 30 | }; 31 | -------------------------------------------------------------------------------- /boilerplate/.eslintignore: -------------------------------------------------------------------------------- 1 | coverage 2 | -------------------------------------------------------------------------------- /boilerplate/.eslintrc: -------------------------------------------------------------------------------- 1 | { 2 | "extends": "eslint-config-egg" 3 | } 4 | -------------------------------------------------------------------------------- /boilerplate/README.md: -------------------------------------------------------------------------------- 1 | # {{name}} 2 | 3 | {{description}} 4 | 5 | ## QuickStart 6 | 7 | ### Development 8 | 9 | ```bash 10 | $ npm i 11 | $ npm run init 12 | $ npm run dev 13 | $ open http://localhost:7001/ 14 | ``` 15 | 16 | ### Deploy 17 | 18 | ```bash 19 | $ npm start 20 | $ npm stop 21 | ``` 22 | 23 | ### Npm Scripts 24 | 25 | - Use `npm run lint` to check code style 26 | - Use `npm test` to run unit test 27 | - se `npm run clean` to clean compiled js at development mode once 28 | 29 | ### Requirement 30 | 31 | - Node.js >= 8.x 32 | -------------------------------------------------------------------------------- /boilerplate/_.gitignore: -------------------------------------------------------------------------------- 1 | logs/ 2 | npm-debug.log 3 | node_modules/ 4 | coverage/ 5 | .idea/ 6 | run/ 7 | logs/ 8 | .DS_Store 9 | .vscode 10 | *.swp 11 | *.lock 12 | *.js 13 | !.autod.conf.js 14 | 15 | app/**/*.js 16 | test/**/*.js 17 | config/**/*.js 18 | app/**/*.map 19 | test/**/*.map 20 | config/**/*.map 21 | -------------------------------------------------------------------------------- /boilerplate/_package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "{{name}}", 3 | "version": "1.0.0", 4 | "description": "{{description}}", 5 | "private": true, 6 | "egg": { 7 | "framework": "egg-cloud" 8 | }, 9 | "scripts": { 10 | "start": "npm run init && egg-scripts start --daemon --title=egg-server-{{name}}", 11 | "stop": "egg-scripts stop --title=egg-server-{{name}}", 12 | "dev": "egg-bin dev", 13 | "debug": "egg-bin debug", 14 | "test": "npm run lint -- --fix && npm run test-local", 15 | "test-local": "egg-bin test", 16 | "cov": "egg-bin cov", 17 | "lint": "eslint .", 18 | "ci": "npm run lint && npm run cov", 19 | "rpc": "egg-rpc-generator", 20 | "init": "npm run rpc", 21 | "autod": "autod" 22 | }, 23 | "dependencies": { 24 | "egg-scripts": "^2.10.0", 25 | "egg-cloud": "^0.2.0" 26 | }, 27 | "devDependencies": { 28 | "autod": "^3.0.1", 29 | "autod-egg": "^1.1.0", 30 | "egg-bin": "^4.9.0", 31 | "egg-ci": "^1.10.0", 32 | "egg-mock": "^3.20.1", 33 | "egg-rpc-generator": "^1.1.1", 34 | "eslint": "^5.9.0", 35 | "eslint-config-egg": "^7.1.0", 36 | "webstorm-disable-index": "^1.2.0" 37 | }, 38 | "engines": { 39 | "node": ">=8.9.0" 40 | }, 41 | "ci": { 42 | "version": "8" 43 | }, 44 | "repository": { 45 | "type": "git", 46 | "url": "" 47 | }, 48 | "eslintIgnore": [ 49 | "coverage" 50 | ], 51 | "author": "{{author}}", 52 | "license": "MIT" 53 | } 54 | -------------------------------------------------------------------------------- /boilerplate/app/controller/home.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const Controller = require('egg-cloud').Controller; 4 | 5 | class HomeController extends Controller { 6 | async index() { 7 | const ctx = this.ctx; 8 | ctx.body = await ctx.proxy.userService.echoUser({ 9 | id: 123456, 10 | name: '宗羽', 11 | address: '蚂蚁 C 空间', 12 | salary: 100000000, 13 | }); 14 | } 15 | } 16 | 17 | module.exports = HomeController; 18 | -------------------------------------------------------------------------------- /boilerplate/app/router.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = app => { 4 | const { router, controller } = app; 5 | 6 | router.get('/', controller.home.index); 7 | }; 8 | -------------------------------------------------------------------------------- /boilerplate/assembly/dubbo-demo-api-1.0-SNAPSHOT-sources.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eggjs/egg-boilerplate-microservice/fd9a155308bcea84a4de7781904da91a2eb9c621/boilerplate/assembly/dubbo-demo-api-1.0-SNAPSHOT-sources.jar -------------------------------------------------------------------------------- /boilerplate/assembly/dubbo-demo-api-1.0-SNAPSHOT.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/eggjs/egg-boilerplate-microservice/fd9a155308bcea84a4de7781904da91a2eb9c621/boilerplate/assembly/dubbo-demo-api-1.0-SNAPSHOT.jar -------------------------------------------------------------------------------- /boilerplate/config/config.default.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | exports.rpc = { 4 | // registry: { 5 | // address: '127.0.0.1:2181', 6 | // }, 7 | // client: {}, 8 | // server: {}, 9 | }; 10 | -------------------------------------------------------------------------------- /boilerplate/config/plugin.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | -------------------------------------------------------------------------------- /boilerplate/config/proxy.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | group: 'HSF', 5 | version: '1.0.0', 6 | services: [{ 7 | appName: 'dubbo', 8 | api: { 9 | UserService: { 10 | interfaceName: 'org.eggjs.dubbo.UserService', 11 | }, 12 | }, 13 | dependency: [{ 14 | groupId: 'eggjs', 15 | artifactId: 'dubbo-demo-api', 16 | version: '1.0-SNAPSHOT', 17 | }], 18 | }], 19 | }; 20 | -------------------------------------------------------------------------------- /boilerplate/test/app/controller/home.test.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | const { app, assert } = require('egg-mock/bootstrap'); 4 | 5 | describe('test/app/controller/home.test.js', () => { 6 | 7 | it('should GET /', () => { 8 | return app.httpRequest() 9 | .get('/') 10 | .expect({ 11 | id: 123456, 12 | name: '宗羽', 13 | address: '蚂蚁 C 空间', 14 | salary: 100000000, 15 | }) 16 | .expect(200); 17 | }); 18 | }); 19 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | 3 | module.exports = { 4 | name: { 5 | desc: 'project name', 6 | }, 7 | description: { 8 | desc: 'project description', 9 | }, 10 | author: { 11 | desc: 'project author', 12 | }, 13 | }; 14 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "egg-boilerplate-microservice", 3 | "version": "1.2.0", 4 | "description": "boilerplate for egg microservice", 5 | "dependencies": {}, 6 | "devDependencies": { 7 | "autod": "^3.0.1", 8 | "egg-bin": "^4.3.7", 9 | "egg-ci": "^1.8.0", 10 | "eslint": "^4.18.1", 11 | "eslint-config-egg": "^7.0.0", 12 | "webstorm-disable-index": "^1.2.0" 13 | }, 14 | "engines": { 15 | "node": ">=8.0.0" 16 | }, 17 | "scripts": { 18 | "autod": "autod", 19 | "lint": "eslint .", 20 | "test": "npm run lint -- --fix && npm run test-boilerplate", 21 | "ci": "npm run lint && npm run ci-boilerplate", 22 | "test-boilerplate": "npm run build && npm run install-deps && cd dist && npm test", 23 | "ci-boilerplate": "npm run build && npm run install-deps && cd dist && npm run ci", 24 | "clean": "rm -rf boilerplate/.idea boilerplate/logs boilerplate/node_modules boilerplate/run", 25 | "build": "npm run clean && egg-init dist --force --silent --template=./", 26 | "install-deps": "cd dist && npm i autod-egg && ../node_modules/.bin/autod && npm i" 27 | }, 28 | "ci": { 29 | "version": "8" 30 | }, 31 | "eslintIgnore": [ 32 | "coverage", 33 | "dist" 34 | ], 35 | "repository": { 36 | "type": "git", 37 | "url": "" 38 | }, 39 | "author": "gxcsoccer ", 40 | "license": "MIT", 41 | "homepage": "https://github.com/eggjs/egg-boilerplate-microservice", 42 | "bugs": "https://github.com/eggjs/egg/issues" 43 | } 44 | --------------------------------------------------------------------------------