Skip to content
This repository was archived by the owner on Nov 28, 2023. It is now read-only.

Commit a65e8bb

Browse files
committed
init: egg
0 parents  commit a65e8bb

14 files changed

+254
-0
lines changed

.autod.conf.js

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

.eslintignore

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

.eslintrc

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

.gitignore

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
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~
13+
typings/
14+
.nyc_output/
15+
.vscode

.travis.yml

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
2+
language: node_js
3+
node_js:
4+
- '10'
5+
before_install:
6+
- npm i npminstall -g
7+
install:
8+
- npminstall
9+
script:
10+
- npm run ci
11+
after_script:
12+
- npminstall codecov && codecov

LICENSE

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
MIT License
2+
3+
Copyright (c) 2020 liaoy
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.

README.md

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# tools-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

app/controller/home.js

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

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+
};

appveyor.yml

+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
environment:
2+
matrix:
3+
- nodejs_version: '10'
4+
5+
install:
6+
- ps: Install-Product node $env:nodejs_version
7+
- npm i npminstall && node_modules\.bin\npminstall
8+
9+
test_script:
10+
- node --version
11+
- npm --version
12+
- npm run test
13+
14+
build: off

config/config.default.js

+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
/* eslint valid-jsdoc: "off" */
2+
3+
'use strict';
4+
5+
/**
6+
* @param {Egg.EggAppInfo} appInfo app info
7+
*/
8+
module.exports = appInfo => {
9+
/**
10+
* built-in config
11+
* @type {Egg.EggAppConfig}
12+
**/
13+
const config = exports = {};
14+
15+
// use for cookie sign key, should change to your own and keep security
16+
config.keys = appInfo.name + '_1586501413819_4461';
17+
18+
// add your middleware config here
19+
config.middleware = [];
20+
21+
// add your user config here
22+
const userConfig = {
23+
// myAppName: 'egg',
24+
};
25+
26+
return {
27+
...config,
28+
...userConfig,
29+
};
30+
};

config/plugin.js

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
'use strict';
2+
3+
/** @type Egg.EggPlugin */
4+
module.exports = {
5+
// had enabled by egg
6+
// static: {
7+
// enable: true,
8+
// }
9+
};

package.json

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
{
2+
"name": "tools-server",
3+
"version": "1.0.0",
4+
"description": "",
5+
"private": true,
6+
"egg": {
7+
"declarations": true
8+
},
9+
"dependencies": {
10+
"egg": "^2.15.1",
11+
"egg-scripts": "^2.11.0"
12+
},
13+
"devDependencies": {
14+
"autod": "^3.0.1",
15+
"autod-egg": "^1.1.0",
16+
"egg-bin": "^4.11.0",
17+
"egg-ci": "^1.11.0",
18+
"egg-mock": "^3.21.0",
19+
"eslint": "^5.13.0",
20+
"eslint-config-egg": "^7.1.0"
21+
},
22+
"engines": {
23+
"node": ">=10.0.0"
24+
},
25+
"scripts": {
26+
"start": "egg-scripts start --daemon --title=egg-server-tools-server",
27+
"stop": "egg-scripts stop --title=egg-server-tools-server",
28+
"dev": "egg-bin dev",
29+
"debug": "egg-bin debug",
30+
"test": "npm run lint -- --fix && npm run test-local",
31+
"test-local": "egg-bin test",
32+
"cov": "egg-bin cov",
33+
"lint": "eslint .",
34+
"ci": "npm run lint && npm run cov",
35+
"autod": "autod"
36+
},
37+
"ci": {
38+
"version": "10"
39+
},
40+
"repository": {
41+
"type": "git",
42+
"url": ""
43+
},
44+
"author": "BackRunner",
45+
"license": "MIT"
46+
}

test/app/controller/home.test.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
'use strict';
2+
3+
const { app, assert } = require('egg-mock/bootstrap');
4+
5+
describe('test/app/controller/home.test.js', () => {
6+
it('should assert', () => {
7+
const pkg = require('../../../package.json');
8+
assert(app.config.keys.startsWith(pkg.name));
9+
10+
// const ctx = app.mockContext({});
11+
// yield ctx.service.xx();
12+
});
13+
14+
it('should GET /', () => {
15+
return app.httpRequest()
16+
.get('/')
17+
.expect('hi, egg')
18+
.expect(200);
19+
});
20+
});

0 commit comments

Comments
 (0)