Skip to content

Commit 90ea582

Browse files
committed
add cov & lint & update README & some fix
1 parent 57e45d1 commit 90ea582

File tree

4 files changed

+29
-11
lines changed

4 files changed

+29
-11
lines changed

.eslintrc

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,15 @@
11
{
22
"extends": "eslint-config-egg",
3+
"parseOptions": {
4+
ecmaVersion: 2017
5+
},
36
"rules": {
7+
},
8+
"globals": {
9+
"app": true,
10+
"request": true,
11+
"mm": true,
12+
"mock": true,
13+
"assert": true,
414
}
515
}

README.md

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ $ npm run dev
1616

1717
Node.js >= 7.6.0 required(support native async & await).
1818

19+
* 可以在 `app/router.js` 中查看完整路由配置和demo示例
20+
1921
## Features
2022

2123
- ✔︎ Full APIs Wrapped
@@ -32,14 +34,13 @@ Node.js >= 7.6.0 required(support native async & await).
3234

3335
- Use `npm start` to run server
3436
- Use `npm run dev` to dev
35-
- Use `npm test` to run unit test.
37+
- Use `npm run lint` to run eslint(eslint not native support es@next now)
38+
- Use `npm test` to run unit test
39+
- Use `npm run cov` to run cov
3640

3741
### Todo
3842

39-
- use `router prefix`
40-
- use `middleware in router`
41-
- more & more
42-
- develop `webapp` using this apis
43+
- make `pwa` using the APIs
4344

4445
### Links
4546

app/router.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,13 @@
66
* Date : Fri 03 Mar 2017 03:22:10 PM CST
77
*/
88

9+
'use strict'
910

1011
module.exports = app => {
1112

1213
const prefix = '/api/v2'
1314

14-
// @auth, all require auth
15+
// @auth
1516
app.post('v2ex', `${prefix}/auth/login`, 'auth.login')
1617
app.get('v2ex', `${prefix}/auth/login`, 'auth.login') // for test
1718
app.post('v2ex', `${prefix}/auth/login`, 'auth.login')
@@ -35,13 +36,13 @@ module.exports = app => {
3536
app.get('v2ex', `${prefix}/topics/hot`, 'topics.hot')
3637
app.get('v2ex', `${prefix}/topics/:id`, 'topics.show')
3738
app.get('v2ex', `${prefix}/topics/all/:type/:value`, 'topics.getAllByType')
38-
// require auth
39+
// auth required
3940
app.post('v2ex', `${prefix}/topics/new`, 'topics.create')
4041
// app.get('v2ex', `${prefix}/topics/new`, 'topics.create') // for test
4142

4243
// @repies
4344
app.get('v2ex', `${prefix}/replies/:topic_id`, 'replies.show')
44-
// require auth
45+
// auth required
4546
app.post('v2ex', `${prefix}/replies/:topic_id`, 'replies.create')
4647
// app.get('v2ex', `${prefix}/replies/:topic_id/new`, 'replies.create') // for test
4748

@@ -79,5 +80,5 @@ module.exports = app => {
7980
// @replies
8081
// http://localhost:7001/replies/344499?page=1&page_size=20 // page_size貌似没用...
8182

82-
} // /.router
83+
} // /.router map
8384

package.json

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,19 @@
66
"scripts": {
77
"start": "node index.js",
88
"dev": "egg-bin dev",
9+
"lint": "eslint .",
10+
"cov": "egg-bin cov",
911
"test": "egg-bin test"
1012
},
1113
"dependencies": {
1214
"egg": "^1.0.0-rc.2",
15+
"eslint": "^3.18.0",
1316
"set-cookie-parser": "^2.0.0"
1417
},
1518
"devDependencies": {
16-
"egg-bin": "^2.2.3",
19+
"egg-bin": "^3.1.0",
1720
"egg-mock": "^3.0.1",
21+
"eslint-config-egg": "^3.2.0",
1822
"supertest": "^3.0.0"
1923
},
2024
"engines": {
@@ -26,8 +30,10 @@
2630
},
2731
"keywords": [
2832
"v2ex",
33+
"RESTful API",
2934
"egg",
30-
"async-await"
35+
"async-await",
36+
"unittest"
3137
],
3238
"author": "indexxuan",
3339
"license": "MIT"

0 commit comments

Comments
 (0)