Skip to content

Commit 20e3df6

Browse files
committed
chore: egg-init --type=simple
0 parents  commit 20e3df6

File tree

12 files changed

+220
-0
lines changed

12 files changed

+220
-0
lines changed

Diff for: .autod.conf.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
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',
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+
'webstorm-disable-index',
24+
],
25+
exclude: [
26+
'./test/fixtures',
27+
'./dist',
28+
],
29+
};
30+

Diff for: .eslintignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
coverage

Diff for: .eslintrc

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"extends": "eslint-config-egg"
3+
}

Diff for: .gitignore

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
logs/
2+
npm-debug.log
3+
yarn-error.log
4+
node_modules/
5+
package-lock.json
6+
yarn.lock
7+
coverage/
8+
.idea/
9+
run/
10+
.DS_Store
11+
*.sw*
12+
*.un~

Diff for: README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# smart-signature-server
2+
3+
4+
5+
## QuickStart
6+
7+
<!-- add docs here for user -->
8+
9+
see [egg docs][egg] for more detail.
10+
11+
### Development
12+
13+
```bash
14+
$ npm i
15+
$ npm run dev
16+
$ open http://localhost:7001/
17+
```
18+
19+
### Deploy
20+
21+
```bash
22+
$ npm start
23+
$ npm stop
24+
```
25+
26+
### npm scripts
27+
28+
- Use `npm run lint` to check code style.
29+
- Use `npm test` to run unit test.
30+
- Use `npm run autod` to auto detect dependencies upgrade, see [autod](https://www.npmjs.com/package/autod) for more detail.
31+
32+
33+
[egg]: https://eggjs.org

Diff for: README.zh-CN.md

+39
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# smart-signature-server
2+
3+
4+
5+
## 快速入门
6+
7+
<!-- 在此次添加使用文档 -->
8+
9+
如需进一步了解,参见 [egg 文档][egg]
10+
11+
### 本地开发
12+
13+
```bash
14+
$ npm i
15+
$ npm run dev
16+
$ open http://localhost:7001/
17+
```
18+
19+
### 部署
20+
21+
```bash
22+
$ npm start
23+
$ npm stop
24+
```
25+
26+
### 单元测试
27+
28+
- [egg-bin] 内置了 [mocha], [thunk-mocha], [power-assert], [istanbul] 等框架,让你可以专注于写单元测试,无需理会配套工具。
29+
- 断言库非常推荐使用 [power-assert]
30+
- 具体参见 [egg 文档 - 单元测试](https://eggjs.org/zh-cn/core/unittest)
31+
32+
### 内置指令
33+
34+
- 使用 `npm run lint` 来做代码风格检查。
35+
- 使用 `npm test` 来执行单元测试。
36+
- 使用 `npm run autod` 来自动检测依赖更新,详细参见 [autod](https://www.npmjs.com/package/autod)
37+
38+
39+
[egg]: https://eggjs.org

Diff for: app/controller/home.js

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
'use strict';
2+
3+
const Controller = require('egg').Controller;
4+
5+
class HomeController extends Controller {
6+
async index() {
7+
this.ctx.body = 'hi, egg';
8+
}
9+
}
10+
11+
module.exports = HomeController;

Diff for: app/router.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
/**
4+
* @param {Egg.Application} app - egg application
5+
*/
6+
module.exports = app => {
7+
const { router, controller } = app;
8+
router.get('/', controller.home.index);
9+
};

Diff for: config/config.default.js

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
'use strict';
2+
3+
module.exports = appInfo => {
4+
const config = exports = {};
5+
6+
// use for cookie sign key, should change to your own and keep security
7+
config.keys = appInfo.name + '_1527505397586_5715';
8+
9+
// add your config here
10+
config.middleware = [];
11+
12+
return config;
13+
};

Diff for: config/plugin.js

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
'use strict';
2+
3+
// had enabled by egg
4+
// exports.static = true;

Diff for: package.json

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
{
2+
"name": "smart-signature-server",
3+
"version": "1.0.0",
4+
"description": "",
5+
"private": true,
6+
"dependencies": {
7+
"egg": "^2.2.1",
8+
"egg-scripts": "^2.5.0"
9+
},
10+
"devDependencies": {
11+
"autod": "^3.0.1",
12+
"autod-egg": "^1.0.0",
13+
"egg-bin": "^4.3.5",
14+
"egg-ci": "^1.8.0",
15+
"egg-mock": "^3.14.0",
16+
"eslint": "^4.11.0",
17+
"eslint-config-egg": "^6.0.0",
18+
"webstorm-disable-index": "^1.2.0"
19+
},
20+
"engines": {
21+
"node": ">=8.9.0"
22+
},
23+
"scripts": {
24+
"start": "egg-scripts start --daemon --title=egg-server-smart-signature-server",
25+
"stop": "egg-scripts stop --title=egg-server-smart-signature-server",
26+
"dev": "egg-bin dev",
27+
"debug": "egg-bin debug",
28+
"test": "npm run lint -- --fix && npm run test-local",
29+
"test-local": "egg-bin test",
30+
"cov": "egg-bin cov",
31+
"lint": "eslint .",
32+
"ci": "npm run lint && npm run cov",
33+
"autod": "autod"
34+
},
35+
"ci": {
36+
"version": "8"
37+
},
38+
"repository": {
39+
"type": "git",
40+
"url": ""
41+
},
42+
"author": "KJlmfe <[email protected]>",
43+
"license": "MIT"
44+
}

Diff for: test/app/controller/home.test.js

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
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 assert', function* () {
8+
const pkg = require('../../../package.json');
9+
assert(app.config.keys.startsWith(pkg.name));
10+
11+
// const ctx = app.mockContext({});
12+
// yield ctx.service.xx();
13+
});
14+
15+
it('should GET /', () => {
16+
return app.httpRequest()
17+
.get('/')
18+
.expect('hi, egg')
19+
.expect(200);
20+
});
21+
});

0 commit comments

Comments
 (0)