Skip to content

Commit 2a91ea7

Browse files
committed
增加开发文档和API文档|增加Profile|代码优化|todo:API完善|旅游去哈哈
1 parent d8402d3 commit 2a91ea7

File tree

155 files changed

+20167
-9919
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+20167
-9919
lines changed

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ run/
88
.DS_Store
99
*.swp
1010
out/
11-
11+
todo.md

README.md

Lines changed: 22 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@
2323

2424
## Intro
2525

26-
`V2EX API Bridge`: 提供论坛公开API的封装和私有API的挖掘实现,目前已支持 `登录,签到,发帖,回帖` 等非官方API功能.  
26+
`V2EX API Bridge`: 提供论坛公开API的封装和私有API的挖掘实现,目前已支持 `登录,签到,发帖,回帖,账户,消息` 等非官方API功能.  
27+
* see `app/router.js` to find full router config & demo api links
2728

2829
- Thanks for:
2930
- [official API] (https://www.v2ex.com/p/7v9TEc53)
@@ -32,22 +33,25 @@
3233
## Development
3334

3435
- require Node.js 7.6.0+ (async & await)
35-
- recommend yarn install
36+
- recommend `yarn install`
3637
- recommend [nvm](https://github.com/creationix/nvm) - the Node.js Version Manager
3738

3839
```bash
3940
$ npm install
4041
$ npm run dev
4142
```
42-
* see `app/router.js` to find full router config & demo api links
43-
4443
## Features
4544

46-
- ✔︎ Full APIs Wrapped
47-
- ✔︎ RESTful Style
48-
- ✔︎ 30+ Case, 100%+ Unit Test(`BDD`)
49-
- ✔︎ Hot Reload in Dev
50-
- ✔︎ pre-commit hook to run cov & build docs and host in Github Pages @see `package.json`
45+
- ✔︎ Full RESTful Style APIs Wrapped
46+
- ✔︎ 40+ Case, 95%+ Unit Test(`BDD`) with Docs
47+
- ✔︎ Server Hot Reload in Dev
48+
- ✔︎ pre-commit hook to run codecov & build jsdoc, host in Github Pages @see `package.json#pre-commit`
49+
- ✔︎ CI Support
50+
51+
## Docs
52+
53+
- ✔︎ Public API Docs - [go] (https://indexxuan.github.io/v2ex-api-bridge/api/index.html)
54+
- ✔︎ Project Dev Docs - [go] (https://indexxuan.github.io/v2ex-api-bridge/project/index.html)
5155

5256
## Unit Test
5357

@@ -57,16 +61,18 @@ $ npm run dev
5761

5862
## npm scripts
5963

60-
- Use `npm start` to run server
64+
- Use `npm start` to run server in prod mode
6165
- Use `npm run dev` to dev
62-
- Use `npm run lint` to run eslint(eslint not native support es@next now)
66+
- Use `npm run lint` to run eslint(eslint not native support es@next now, so...)
6367
- Use `npm test` to run unit test
64-
- Use `npm run cov` to run cov
68+
- Use `npm run cov` to run code coverage
6569

6670
## Todo
6771

68-
- make `pwa` using the APIs
6972
- parse the `response html` to get more private APIs
73+
- improve `docs` and 'codecov'
74+
- make `pwa` using the APIs
75+
- make it more `egg best practice`
7076

7177
## Links
7278

@@ -77,4 +83,7 @@ $ npm run dev
7783
- [thunk-mocha] (https://npmjs.com/thunk-mocha)
7884
- [power-assert] (https://github.com/power-assert-js/power-assert)
7985
- [istanbul] (https://github.com/gotwarlost/istanbul)
86+
- [circleci] (https://circleci.com/)
87+
- [codecov] (https://codecov.io/)
88+
- [jsdoc] (https://github.com/jsdoc3/jsdoc)
8089

app.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* Author : IndexXuan(https://github.com/IndexXuan)
3+
* Mail : indexxuan@gmail.com
4+
* Date : Sat 01 Apr 2017 03:55:02 PM CST
5+
*/
6+
7+
'use strict'
8+
9+
module.exports = app => {
10+
// class BaseService extends app.Service {
11+
// }
12+
// override
13+
// app.Service = BaseService
14+
} // /.exports
15+

app/api/auth.js

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
/**
2+
* Mail : indexxuan@gmail.com
3+
* Date : Fri 03 Mar 2017 03:22:10 PM CST
4+
*/
5+
6+
/**
7+
* @module Auth
8+
* @author IndexXuan
9+
*/
10+
11+
'use strict'
12+
13+
module.exports = app => prefix => {
14+
/**
15+
* 登录
16+
* @method login
17+
*
18+
* @example
19+
* POST /api/v2/auth/login
20+
* data: { username: ${username}, password: ${password} }
21+
*
22+
* {
23+
* result: true|false,
24+
* msg: 'ok|${errormsg}',
25+
* data: {
26+
* username: ${username}
27+
* }
28+
* }
29+
*/
30+
app.post('v2ex', `${prefix}/auth/login`, 'auth.login')
31+
app.get('v2ex', `${prefix}/auth/login`, 'auth.login') // for test
32+
33+
/**
34+
* 签到
35+
* @method signin
36+
*
37+
* @example
38+
* POST /api/v2/auth/signin
39+
*
40+
* {
41+
* result: true|false,
42+
* msg: 'ok|${errormsg: e.g. 今天已经签到了}',
43+
* data: {
44+
* username: ${username},
45+
* detail: '已连续登录XX天'
46+
* }
47+
* }
48+
*/
49+
app.post('v2ex', `${prefix}/auth/signin`, 'auth.signin')
50+
app.get('v2ex', `${prefix}/auth/signin`, 'auth.signin') // for test
51+
}
52+

app/api/members.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/**
2+
* Mail : indexxuan@gmail.com
3+
* Date : Fri 13 Mar 2017 03:22:10 PM CST
4+
*/
5+
6+
/**
7+
* @module Members
8+
* @author IndexXuan
9+
*/
10+
11+
'use strict'
12+
13+
module.exports = app => prefix => {
14+
/**
15+
* 查看一个成员公开信息,无需权限
16+
* @method show
17+
*
18+
* @example
19+
* GET /api/v2/members/id/105309
20+
* GET /api/v2/members/username/IndexXuan
21+
*
22+
* Object
23+
* {
24+
* "status": "found",
25+
* "id": 105309,
26+
* "url": "http://www.v2ex.com/member/IndexXuan",
27+
* "username": "IndexXuan",
28+
* "website": "",
29+
* "twitter": "",
30+
* "psn": "",
31+
* "github": "",
32+
* "btc": "",
33+
* "location": "",
34+
* "tagline": "",
35+
* "bio": "",
36+
* "avatar_mini": "//v2ex.assets.uxengine.net/gravatar/abda94899b0173bb17e815a5c0bf9e93?s=24&d=retro",
37+
* "avatar_normal": "//v2ex.assets.uxengine.net/gravatar/abda94899b0173bb17e815a5c0bf9e93?s=48&d=retro",
38+
* "avatar_large": "//v2ex.assets.uxengine.net/gravatar/abda94899b0173bb17e815a5c0bf9e93?s=73&d=retro",
39+
* "created": 1426662703
40+
* }
41+
*/
42+
app.get('v2ex', `${prefix}/members/username/:username`, 'members.show')
43+
app.get('v2ex', `${prefix}/members/id/:id`, 'members.show')
44+
}
45+

app/api/nodes.js

Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/**
2+
* Mail : indexxuan@gmail.com
3+
* Date : Fri 13 Mar 2017 03:22:10 PM CST
4+
*/
5+
6+
/**
7+
* @module Nodes
8+
* @author IndexXuan
9+
*/
10+
11+
'use strict'
12+
13+
module.exports = app => prefix => {
14+
/**
15+
* 返回全部节点元信息
16+
* @method all
17+
*
18+
* @example
19+
* GET /api/v2/nodes/all
20+
*
21+
* Array<Object>
22+
* [{
23+
* "id": 249,
24+
* "name": "vim",
25+
* "url": "http://www.v2ex.com/go/vim",
26+
* "title": "Vim",
27+
* "title_alternative": "Vim",
28+
* "topics": 405,
29+
* "header": null,
30+
* "footer": null,
31+
* "created": 1289706010
32+
* }, {
33+
* ...
34+
* }]
35+
*/
36+
app.get('v2ex', `${prefix}/nodes/all`, 'nodes.all')
37+
38+
/**
39+
* 返回一个特定节点信息
40+
* @method show
41+
*
42+
* @example
43+
* GET /api/v2/nodes/id/249
44+
* GET /api/v2/nodes/name/vim
45+
*
46+
* Object
47+
* {
48+
* "id": 249,
49+
* "name": "vim",
50+
* "url": "http://www.v2ex.com/go/vim",
51+
* "title": "Vim",
52+
* "title_alternative": "Vim",
53+
* "topics": 405,
54+
* "header": null,
55+
* "footer": null,
56+
* "created": 1289706010
57+
* }
58+
*/
59+
app.get('v2ex', `${prefix}/nodes/id/:id`, 'nodes.show')
60+
app.get('v2ex', `${prefix}/nodes/name/:name`, 'nodes.show')
61+
}
62+

app/api/profile.js

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/**
2+
* Mail : indexxuan@gmail.com
3+
* Date : Fri 13 Mar 2017 03:22:10 PM CST
4+
*/
5+
6+
/**
7+
* @module Profile
8+
* @author IndexXuan
9+
*/
10+
11+
'use strict'
12+
13+
module.exports = app => prefix => {
14+
/**
15+
* 返回本人全部信息,包含发布的主题,回复的主题,财富收支,消息通知等
16+
* @method all
17+
*
18+
* @example
19+
* GET /api/v2/profile/all
20+
*
21+
* Array<Object>
22+
* [{
23+
* "id": 4096325,
24+
* "thanks": 0,
25+
* "content": "站长辛苦了😆😆😆",
26+
* "content_rendered": "站长辛苦了😆😆😆",
27+
* "member": {
28+
* "id": 154020,
29+
* "username": "misaka19000",
30+
* "tagline": "",
31+
* "avatar_mini": "//v2ex.assets.uxengine.net/avatar/4271/6be2/154020_mini.png?m=1479258611",
32+
* "avatar_normal": "//v2ex.assets.uxengine.net/avatar/4271/6be2/154020_normal.png?m=1479258611",
33+
* "avatar_large": "//v2ex.assets.uxengine.net/avatar/4271/6be2/154020_large.png?m=1479258611"
34+
* },
35+
* "created": 1488489066,
36+
* "last_modified": 1488489066
37+
* }, {me
38+
* ...
39+
* }]
40+
*/
41+
app.get('v2ex', `${prefix}/profile/all`, 'profile.all')
42+
43+
/**
44+
* 返回本人发布的所有主题
45+
* @method topics
46+
*
47+
* @example
48+
* GET /api/v2/profile/topics
49+
*
50+
* Array<Object>
51+
* [{
52+
* }]
53+
*/
54+
app.get('v2ex', `${prefix}/profile/topics`, 'profile.topics')
55+
56+
/**
57+
* 返回本人的所有回复
58+
* @method show
59+
*
60+
* @example
61+
* GET /api/v2/profile/replies
62+
*
63+
* Array<Object>
64+
* [{
65+
* }]
66+
*/
67+
app.get('v2ex', `${prefix}/profile/replies`, 'profile.replies')
68+
69+
/**
70+
* 返回本人所有收支情况
71+
* @method balance
72+
*
73+
* @example
74+
* GET /api/v2/profile/balance
75+
*
76+
* Array<Object>
77+
* [{
78+
* }]
79+
*/
80+
app.get('v2ex', `${prefix}/profile/balance`, 'profile.balance')
81+
82+
/**
83+
* 返回本人所有的消息通知
84+
* @method notification
85+
*
86+
* @example
87+
* GET /api/v2/profile/notification
88+
*
89+
* Array<Object>
90+
* [{
91+
* }]
92+
*/
93+
app.get('v2ex', `${prefix}/profile/notification`, 'profile.notification')
94+
} // /.exports
95+

0 commit comments

Comments
 (0)