@sansenjian/qq-music-api 1.0.6 ā 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.babelrc +2 -2
- package/.dockerignore +5 -5
- package/.editorconfig +31 -31
- package/.eslintrc.json +21 -17
- package/.github/FUNDING.yml +12 -12
- package/.github/ISSUE_TEMPLATE/bug_report.md +38 -38
- package/.github/ISSUE_TEMPLATE/custom.md +24 -24
- package/.github/ISSUE_TEMPLATE/feature_request.md +20 -20
- package/.github/workflows/publish.yml +26 -0
- package/.husky/commit-msg +1 -0
- package/.husky/pre-commit +1 -0
- package/.prettierignore +1 -1
- package/.prettierrc +9 -9
- package/CHANGELOG.md +70 -70
- package/Dockerfile +18 -18
- package/LICENSE +21 -21
- package/README.md +218 -177
- package/app.js +75 -75
- package/commitlint.config.js +20 -20
- package/config/user-info.js +42 -42
- package/index.js +1 -1
- package/middlewares/koa-cors.js +97 -97
- package/module/apis/UCommon/UCommon.js +6 -6
- package/module/apis/album/getAlbumInfo.js +33 -33
- package/module/apis/comments/getComments.js +35 -35
- package/module/apis/digitalAlbum/getDigitalAlbumLists.js +34 -34
- package/module/apis/downloadQQMusic.js +41 -41
- package/module/apis/music/getLyric.js +42 -41
- package/module/apis/mv/getMvByTag.js +35 -35
- package/module/apis/radio/getRadioLists.js +38 -38
- package/module/apis/rank/getTopLists.js +44 -44
- package/module/apis/search/getHotKey.js +35 -35
- package/module/apis/search/getSearchByKey.js +45 -45
- package/module/apis/search/getSmartbox.js +34 -34
- package/module/apis/singers/getSimilarSinger.js +36 -36
- package/module/apis/singers/getSingerDesc.js +38 -38
- package/module/apis/singers/getSingerMv.js +35 -35
- package/module/apis/singers/getSingerStarNum.js +36 -36
- package/module/apis/songLists/songListCategories.js +33 -33
- package/module/apis/songLists/songListDetail.js +38 -38
- package/module/apis/songLists/songLists.js +41 -41
- package/module/apis/u_common.js +17 -16
- package/module/apis/user/checkQQLoginQr.js +125 -86
- package/module/apis/user/getQQLoginQr.js +17 -11
- package/module/apis/y_common.js +27 -14
- package/module/config.js +31 -31
- package/module/index.js +82 -82
- package/package.json +72 -83
- package/public/index.html +47 -47
- package/routers/context/batchGetSongInfo.js +59 -59
- package/routers/context/batchGetSongLists.js +50 -50
- package/routers/context/checkQQLoginQr.js +17 -15
- package/routers/context/cookies.js +36 -36
- package/routers/context/getAlbumInfo.js +27 -27
- package/routers/context/getComments.js +51 -51
- package/routers/context/getDigitalAlbumLists.js +14 -14
- package/routers/context/getDownloadQQMusic.js +14 -14
- package/routers/context/getHotkey.js +14 -14
- package/routers/context/getImageUrl.js +34 -34
- package/routers/context/getLyric.js +26 -26
- package/routers/context/getMusicPlay.js +116 -112
- package/routers/context/getMv.js +56 -56
- package/routers/context/getMvByTag.js +15 -15
- package/routers/context/getMvPlay.js +128 -118
- package/routers/context/getNewDisks.js +50 -51
- package/routers/context/getQQLoginQr.js +12 -12
- package/routers/context/getRadioLists.js +14 -14
- package/routers/context/getRanks.js +90 -86
- package/routers/context/getRecommend.js +86 -86
- package/routers/context/getSearchByKey.js +32 -32
- package/routers/context/getSimilarSinger.js +25 -25
- package/routers/context/getSingerAlbum.js +52 -52
- package/routers/context/getSingerDesc.js +25 -25
- package/routers/context/getSingerHotsong.js +52 -52
- package/routers/context/getSingerList.js +51 -52
- package/routers/context/getSingerMv.js +32 -32
- package/routers/context/getSingerStarNum.js +24 -24
- package/routers/context/getSmartbox.js +24 -24
- package/routers/context/getSongInfo.js +49 -49
- package/routers/context/getSongListCategories.js +22 -22
- package/routers/context/getSongListDetail.js +25 -25
- package/routers/context/getSongLists.js +32 -32
- package/routers/context/getTicketInfo.js +45 -45
- package/routers/context/getTopLists.js +15 -15
- package/routers/context/index.js +74 -74
- package/routers/router.js +116 -112
- package/scripts/build-images.js +36 -36
- package/scripts/commit-push.sh +103 -103
- package/util/colors.js +16 -16
- package/util/cookie.js +22 -22
- package/util/loginUtils.js +28 -23
- package/util/lyricParse.js +64 -64
- package/util/request.js +57 -57
- package/vercel.json +15 -15
package/README.md
CHANGED
|
@@ -1,177 +1,218 @@
|
|
|
1
|
-
<h1 align="center">QQ Music API</h1>
|
|
2
|
-
|
|
3
|
-
<div align="center">
|
|
4
|
-
|
|
5
|
-
<img src='music.png' />
|
|
6
|
-
|
|
7
|
-
  
|
|
8
|
+
<br />
|
|
9
|
+

|
|
10
|
+
<br />
|
|
11
|
+
      
|
|
12
|
+
|
|
13
|
+
</div>
|
|
14
|
+
|
|
15
|
+
> š“ ę¬é”¹ē® Fork čŖ [Rain120/qq-music-api](https://github.com/Rain120/qq-music-api)ļ¼å锹ē®å·²åę¢ē»“ę¤ļ¼ę¤ēę¬ęē»ę“ę°äø
|
|
16
|
+
|
|
17
|
+
> QQé³ä¹API koa2 ēę¬, éčæWebē½é”µē请ę±QQé³ä¹ę„å£ę°ę®, ęé®é¢čÆ·ę [issue](https://github.com/sansenjian/qq-music-api/issues)
|
|
18
|
+
|
|
19
|
+
> å½å代ē ä»
ä¾å¦ä¹ ļ¼äøåÆååäøēØé
|
|
20
|
+
|
|
21
|
+
### APIē»ęå¾
|
|
22
|
+
|
|
23
|
+
> ē®åęę¶ę²”ęę¶é“åē»å½ęØ”åēę„å£ļ¼ę¬¢čæåä½å¤§ä½¬ē»ę`PR`, éæéåå¤
|
|
24
|
+
|
|
25
|
+

|
|
26
|
+
|
|
27
|
+
### ēÆå¢č¦ę±
|
|
28
|
+
|
|
29
|
+
> ę¬é”¹ē®éēØ `koa2`ļ¼éč¦ Node.js 18.0.0+
|
|
30
|
+
|
|
31
|
+
```
|
|
32
|
+
node -v
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
### š¦ å®č£
|
|
36
|
+
|
|
37
|
+
**ę¹å¼äøļ¼å
éä»åŗ**
|
|
38
|
+
```
|
|
39
|
+
git clone git@github.com:sansenjian/qq-music-api.git
|
|
40
|
+
cd qq-music-api
|
|
41
|
+
npm install
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
**ę¹å¼äŗļ¼NPM å®č£
**
|
|
45
|
+
```
|
|
46
|
+
npm install @sansenjian/qq-music-api
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
åØé”¹ē®äøä½æēØļ¼
|
|
50
|
+
```javascript
|
|
51
|
+
// åÆåØ API ęå”
|
|
52
|
+
const { spawn } = require('child_process');
|
|
53
|
+
const path = require('path');
|
|
54
|
+
|
|
55
|
+
const qqMusicPath = path.join(__dirname, 'node_modules', '@sansenjian/qq-music-api', 'app.js');
|
|
56
|
+
spawn('node', [qqMusicPath], {
|
|
57
|
+
env: { ...process.env, PORT: '3200' },
|
|
58
|
+
stdio: 'inherit'
|
|
59
|
+
});
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
### šØ 锹ē®åÆåØ
|
|
63
|
+
```
|
|
64
|
+
// npm i -g nodemon
|
|
65
|
+
npm run start
|
|
66
|
+
|
|
67
|
+
// or don't install nodemon
|
|
68
|
+
node app.js
|
|
69
|
+
```
|
|
70
|
+
锹ē®ēå¬ē«Æå£ęÆ `3200`
|
|
71
|
+
|
|
72
|
+
### š ä¾čµę“ę° (2026-03)
|
|
73
|
+
|
|
74
|
+
ę¬é”¹ē®å·²å®ęä¾čµē°ä»£ååēŗ§ļ¼äø»č¦åę“å¦äøļ¼
|
|
75
|
+
|
|
76
|
+
**ēäŗ§ä¾čµ**
|
|
77
|
+
| ä¾čµ | ēę¬ | 诓ę |
|
|
78
|
+
|-----|------|-----|
|
|
79
|
+
| axios | ^1.6.0 | äæ®å¤å®å
Øę¼ę“ CVE-2021-3749 |
|
|
80
|
+
| koa | ^2.15.0 | ę”ę¶ę“ę° |
|
|
81
|
+
| koa-bodyparser | ^4.4.0 | č§£ęåØę“ę° |
|
|
82
|
+
| @koa/router | ^12.0.0 | ęæä»£ koa-router |
|
|
83
|
+
| koa-static | ^5.0.0 | éęęä»¶ęå” |
|
|
84
|
+
| dayjs | ^1.11.10 | ęæä»£ moment.js (ę“č½»é) |
|
|
85
|
+
|
|
86
|
+
**å¼åä¾čµ**
|
|
87
|
+
| ä¾čµ | ēę¬ | 诓ę |
|
|
88
|
+
|-----|------|-----|
|
|
89
|
+
| eslint | ^8.56.0 | 代ē ę£ę„ |
|
|
90
|
+
| eslint-config-standard | ^17.0.0 | ę åé
ē½® |
|
|
91
|
+
| prettier | ^3.0.0 | 代ē ę ¼å¼å |
|
|
92
|
+
| husky | ^9.0.0 | Git é©å |
|
|
93
|
+
| lint-staged | ^15.0.0 | ęååŗę£ę„ |
|
|
94
|
+
| @commitlint/* | ^18.0.0 | ę交俔ęÆč§č |
|
|
95
|
+
| @babel/* | ^7.23.0 | ē¼čÆå·„å
· |
|
|
96
|
+
| nodemon | ^3.0.0 | å¼åēéč½½ |
|
|
97
|
+
|
|
98
|
+
**已移é¤ēä¾čµ**
|
|
99
|
+
- `colors` - ååØå®å
Øé®é¢ļ¼å·²ēØ chalk ęæä»£
|
|
100
|
+
- `moment` - å·²ēØ dayjs ęæä»£
|
|
101
|
+
- `lodash.get` - å·²ēØåēåÆéé¾ `?.` ęæä»£
|
|
102
|
+
- `eslint-plugin-node` - å·²ēØ eslint-plugin-n ęæä»£
|
|
103
|
+
- `eslint-plugin-standard` - å·²éęå° eslint-config-standard
|
|
104
|
+
|
|
105
|
+
### åč½ē¹ę§
|
|
106
|
+
|
|
107
|
+
- [x] č·åęę²ęę¾é¾ę„ **2021-01-24**
|
|
108
|
+
|
|
109
|
+
- [x] ęÆęčŖå®ä¹č®¾ē½® `cookie` **2021-01-23**
|
|
110
|
+
|
|
111
|
+
- [x] č·åęę² + äøč¾å¾ē **2020-05-24**
|
|
112
|
+
|
|
113
|
+
- [x] č·åęęēéØęę² **2020-07-04**
|
|
114
|
+
|
|
115
|
+
- [x] č·åQQé³ä¹äŗ§åēäøč½½å°å
|
|
116
|
+
|
|
117
|
+
- [x] č·åęååē±»
|
|
118
|
+
|
|
119
|
+
- [x] č·åęåå蔨
|
|
120
|
+
|
|
121
|
+
- [x] č·åęå详ę
|
|
122
|
+
|
|
123
|
+
- [x] č·åMVę ē¾
|
|
124
|
+
|
|
125
|
+
- [x] č·åMVęę¾äæ”ęÆ
|
|
126
|
+
|
|
127
|
+
- [x] č·åęęMV
|
|
128
|
+
|
|
129
|
+
- [x] č·åēøä¼¼ęę
|
|
130
|
+
|
|
131
|
+
- [x] č·åęęäæ”ęÆ
|
|
132
|
+
|
|
133
|
+
- [x] č·åęę被å
³ę³Øę°éäæ”ęÆ
|
|
134
|
+
|
|
135
|
+
- [x] č·åēµå°å蔨
|
|
136
|
+
|
|
137
|
+
- [x] č·åäøč¾
|
|
138
|
+
|
|
139
|
+
- [x] č·åę°åäøč¾
|
|
140
|
+
|
|
141
|
+
- [x] č·åęę²ęčÆ
|
|
142
|
+
|
|
143
|
+
- [x] č·åMV
|
|
144
|
+
|
|
145
|
+
- [x] č·åę°ē¢äæ”ęÆ
|
|
146
|
+
|
|
147
|
+
- [x] č·åęęäøč¾
|
|
148
|
+
|
|
149
|
+
- [x] ~~č·åęę²VKey~~ **2021-01-24**
|
|
150
|
+
|
|
151
|
+
- [x] č·åęē“¢ēčÆ
|
|
152
|
+
|
|
153
|
+
- [x] č·åå
³é®åęē“¢ę示
|
|
154
|
+
|
|
155
|
+
- [x] č·åęē“¢ē»ę
|
|
156
|
+
|
|
157
|
+
- [x] č·åé¦é”µęØč
|
|
158
|
+
|
|
159
|
+
- [x] č·åęč”ę¦åå蔨
|
|
160
|
+
|
|
161
|
+
- [x] č·åęč”ę¦å详ę
|
|
162
|
+
|
|
163
|
+
- [x] č·åčÆč®ŗäæ”ęÆ(cmd代蔨ēęę沔太å¼ęē½)
|
|
164
|
+
|
|
165
|
+
- [x] č·å焨å”äæ”ęÆ
|
|
166
|
+
|
|
167
|
+
- [x] č·åęå详ę
|
|
168
|
+
|
|
169
|
+
- [x] č·åęęå蔨
|
|
170
|
+
|
|
171
|
+
### 使ēØę攣
|
|
172
|
+
|
|
173
|
+
使ēØ`apis`详č§[ę攣](https://rain120.github.io/qq-music-api/#/)
|
|
174
|
+
|
|
175
|
+
### å
³äŗé”¹ē®
|
|
176
|
+
|
|
177
|
+
**ēµęę„čŖ**
|
|
178
|
+
|
|
179
|
+
[Binaryify/NeteaseCloudMusicApi](https://github.com/Binaryify/NeteaseCloudMusicApi)
|
|
180
|
+
|
|
181
|
+
[Vue2.0å¼åä¼äøēŗ§ē§»åØē«Æé³ä¹Web App](https://coding.imooc.com/class/107.html)
|
|
182
|
+
|
|
183
|
+
**åčå
容**
|
|
184
|
+
|
|
185
|
+
[Koa 2](https://koa.bootcss.com/)
|
|
186
|
+
|
|
187
|
+
[Axios](https://github.com/axios/axios)
|
|
188
|
+
|
|
189
|
+
[é®äøå³°čåø - HTTP Referer ęēØ](http://www.ruanyifeng.com/blog/2019/06/http-referer.html)
|
|
190
|
+
|
|
191
|
+
### 锹ē®äøč¶³
|
|
192
|
+
|
|
193
|
+
1. å äøŗę¬äŗŗę²”åčæ`unit test`, ę仄ę¬é”¹ē®å°ęŖę·»å `unit test`, ēęę¶é“åę·»å ;
|
|
194
|
+
|
|
195
|
+
2. ē»å½č·åäøŖäŗŗäæ”ęÆēę„å£é½ę²”å
|
|
196
|
+
|
|
197
|
+
#### š¤ č“”ē® 
|
|
198
|
+
|
|
199
|
+
We welcome all contributions. You can submit any ideas as [pull requests](https://github.com/sansenjian/qq-music-api/pulls) or as a GitHub [issue](https://github.com/sansenjian/qq-music-api/issues).
|
|
200
|
+
|
|
201
|
+
#### šØāš 结ę¤č
|
|
202
|
+
|
|
203
|
+
- [GitHub](https://github.com/sansenjian)
|
|
204
|
+
|
|
205
|
+
#### š åä½č
|
|
206
|
+
|
|
207
|
+
ę¬é”¹ē®åŗäŗ [Rain120](https://github.com/Rain120) ēå¼ęŗé”¹ē®ļ¼ęč°¢åä½č
ēč“”ē®ļ¼
|
|
208
|
+
|
|
209
|
+
- [GitHub](https://github.com/Rain120)
|
|
210
|
+
- [ē„ä¹](https://www.zhihu.com/people/yan-yang-nian-hua-120/activities)
|
|
211
|
+
- [ęé](https://juejin.im/user/57c616496be3ff00584f54db)
|
|
212
|
+
|
|
213
|
+
#### š License
|
|
214
|
+
|
|
215
|
+
[MIT](https://github.com/sansenjian/qq-music-api/blob/master/LICENSE)
|
|
216
|
+
|
|
217
|
+
Copyright Ā© 2019-present [Rain120](https://github.com/Rain120).
|
|
218
|
+
Fork maintained by [sansenjian](https://github.com/sansenjian).
|
package/app.js
CHANGED
|
@@ -1,75 +1,75 @@
|
|
|
1
|
-
require('@babel/register');
|
|
2
|
-
const Koa = require('koa');
|
|
3
|
-
const app = new Koa();
|
|
4
|
-
const bodyParser = require('koa-bodyparser');
|
|
5
|
-
const path = require('path');
|
|
6
|
-
const static = require('koa-static');
|
|
7
|
-
const exec = require('child_process').exec;
|
|
8
|
-
const chalk = require('chalk');
|
|
9
|
-
|
|
10
|
-
const cors = require('./middlewares/koa-cors');
|
|
11
|
-
const router = require('./routers/router');
|
|
12
|
-
const cookie = require('./util/cookie');
|
|
13
|
-
require('./util/colors');
|
|
14
|
-
const userInfo = require('./config/user-info');
|
|
15
|
-
const package = require('./package.json');
|
|
16
|
-
global.userInfo = Object.assign({}, userInfo);
|
|
17
|
-
|
|
18
|
-
console.log(chalk.green('\nš„³š We had supported config the user cookies. \n'));
|
|
19
|
-
|
|
20
|
-
if (!(global.userInfo.loginUin || global.userInfo.uin)) {
|
|
21
|
-
console.log(chalk.yellow(`š The configuration ${chalk.red('loginUin')} or your ${chalk.red('cookie')} in file ${chalk.green('config/user-info')} has not configured. \n`));
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
if (!global.userInfo.cookie) {
|
|
25
|
-
console.log(chalk.yellow(`š The configuration ${chalk.red('cookie')} in file ${chalk.green('config/user-info')} has not configured. \n`));
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
exec('npm info QQ-Music-API version', (err, stdout, stderr) => {
|
|
29
|
-
if(!err){
|
|
30
|
-
let version = stdout.trim();
|
|
31
|
-
if(package.version < version){
|
|
32
|
-
console.log(`Current Version: ${version}, Current Version: ${package.version}, Please update it
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
});
|
|
36
|
-
|
|
37
|
-
app.use(bodyParser());
|
|
38
|
-
app.use(cookie());
|
|
39
|
-
app.use(static(
|
|
40
|
-
path.join(__dirname, 'public')
|
|
41
|
-
));
|
|
42
|
-
|
|
43
|
-
// logger
|
|
44
|
-
app.use(async (ctx, next) => {
|
|
45
|
-
await next();
|
|
46
|
-
const rt = ctx.response.get('X-Response-Time');
|
|
47
|
-
console.log(`${ctx.method} ${ctx.url} - ${rt}
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
// cors
|
|
51
|
-
app.use(cors({
|
|
52
|
-
origin: (ctx) => ctx.request.header.origin,
|
|
53
|
-
exposeHeaders: ['WWW-Authenticate', 'Server-Authorization'],
|
|
54
|
-
maxAge: 5,
|
|
55
|
-
credentials: true,
|
|
56
|
-
allowMethods: ['GET', 'POST', 'DELETE'],
|
|
57
|
-
allowHeaders: ['Content-Type', 'Authorization', 'Accept'],
|
|
58
|
-
}));
|
|
59
|
-
|
|
60
|
-
// x-response-time
|
|
61
|
-
app.use(async (ctx, next) => {
|
|
62
|
-
const start = Date.now();
|
|
63
|
-
await next();
|
|
64
|
-
const ms = Date.now() - start;
|
|
65
|
-
ctx.set('X-Response-Time', `${ms}ms`);
|
|
66
|
-
});
|
|
67
|
-
|
|
68
|
-
app.use(router.routes())
|
|
69
|
-
.use(router.allowedMethods());
|
|
70
|
-
|
|
71
|
-
const PORT = process.env.PORT || 3200;
|
|
72
|
-
|
|
73
|
-
app.listen(PORT, () => {
|
|
74
|
-
console.log(`server running @ http://localhost:${PORT}
|
|
75
|
-
});
|
|
1
|
+
require('@babel/register');
|
|
2
|
+
const Koa = require('koa');
|
|
3
|
+
const app = new Koa();
|
|
4
|
+
const bodyParser = require('koa-bodyparser');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const static = require('koa-static');
|
|
7
|
+
const exec = require('child_process').exec;
|
|
8
|
+
const chalk = require('chalk');
|
|
9
|
+
|
|
10
|
+
const cors = require('./middlewares/koa-cors');
|
|
11
|
+
const router = require('./routers/router');
|
|
12
|
+
const cookie = require('./util/cookie');
|
|
13
|
+
const colors = require('./util/colors');
|
|
14
|
+
const userInfo = require('./config/user-info');
|
|
15
|
+
const package = require('./package.json');
|
|
16
|
+
global.userInfo = Object.assign({}, userInfo);
|
|
17
|
+
|
|
18
|
+
console.log(chalk.green('\nš„³š We had supported config the user cookies. \n'));
|
|
19
|
+
|
|
20
|
+
if (!(global.userInfo.loginUin || global.userInfo.uin)) {
|
|
21
|
+
console.log(chalk.yellow(`š The configuration ${chalk.red('loginUin')} or your ${chalk.red('cookie')} in file ${chalk.green('config/user-info')} has not configured. \n`));
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
if (!global.userInfo.cookie) {
|
|
25
|
+
console.log(chalk.yellow(`š The configuration ${chalk.red('cookie')} in file ${chalk.green('config/user-info')} has not configured. \n`));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
exec('npm info QQ-Music-API version', (err, stdout, stderr) => {
|
|
29
|
+
if(!err){
|
|
30
|
+
let version = stdout.trim();
|
|
31
|
+
if(package.version < version){
|
|
32
|
+
console.log(colors.prompt(`Current Version: ${version}, Current Version: ${package.version}, Please update it.`));
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
app.use(bodyParser());
|
|
38
|
+
app.use(cookie());
|
|
39
|
+
app.use(static(
|
|
40
|
+
path.join(__dirname, 'public')
|
|
41
|
+
));
|
|
42
|
+
|
|
43
|
+
// logger
|
|
44
|
+
app.use(async (ctx, next) => {
|
|
45
|
+
await next();
|
|
46
|
+
const rt = ctx.response.get('X-Response-Time');
|
|
47
|
+
console.log(colors.prompt(`${ctx.method} ${ctx.url} - ${rt}`));
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
// cors
|
|
51
|
+
app.use(cors({
|
|
52
|
+
origin: (ctx) => ctx.request.header.origin,
|
|
53
|
+
exposeHeaders: ['WWW-Authenticate', 'Server-Authorization'],
|
|
54
|
+
maxAge: 5,
|
|
55
|
+
credentials: true,
|
|
56
|
+
allowMethods: ['GET', 'POST', 'DELETE'],
|
|
57
|
+
allowHeaders: ['Content-Type', 'Authorization', 'Accept'],
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
// x-response-time
|
|
61
|
+
app.use(async (ctx, next) => {
|
|
62
|
+
const start = Date.now();
|
|
63
|
+
await next();
|
|
64
|
+
const ms = Date.now() - start;
|
|
65
|
+
ctx.set('X-Response-Time', `${ms}ms`);
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
app.use(router.routes())
|
|
69
|
+
.use(router.allowedMethods());
|
|
70
|
+
|
|
71
|
+
const PORT = process.env.PORT || 3200;
|
|
72
|
+
|
|
73
|
+
app.listen(PORT, () => {
|
|
74
|
+
console.log(colors.prompt(`server running @ http://localhost:${PORT}`));
|
|
75
|
+
});
|
package/commitlint.config.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
/*
|
|
2
|
-
* @Author: Rainy
|
|
3
|
-
* @Date: 2020-07-03 18:47:30
|
|
4
|
-
* @LastEditors: Rainy
|
|
5
|
-
* @LastEditTime: 2020-07-03 18:51:11
|
|
6
|
-
*/
|
|
7
|
-
|
|
8
|
-
module.exports = {
|
|
9
|
-
extends: ['@commitlint/config-conventional'],
|
|
10
|
-
rules: {
|
|
11
|
-
'type-enum': [
|
|
12
|
-
2,
|
|
13
|
-
'always',
|
|
14
|
-
['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'build', 'ci', 'chore', 'revert', 'config'],
|
|
15
|
-
],
|
|
16
|
-
'subject-full-stop': [0, 'never'],
|
|
17
|
-
'subject-case': [0, 'never'],
|
|
18
|
-
'header-max-length': [0, 'always', 150],
|
|
19
|
-
},
|
|
20
|
-
};
|
|
1
|
+
/*
|
|
2
|
+
* @Author: Rainy
|
|
3
|
+
* @Date: 2020-07-03 18:47:30
|
|
4
|
+
* @LastEditors: Rainy
|
|
5
|
+
* @LastEditTime: 2020-07-03 18:51:11
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
module.exports = {
|
|
9
|
+
extends: ['@commitlint/config-conventional'],
|
|
10
|
+
rules: {
|
|
11
|
+
'type-enum': [
|
|
12
|
+
2,
|
|
13
|
+
'always',
|
|
14
|
+
['feat', 'fix', 'docs', 'style', 'refactor', 'perf', 'test', 'build', 'ci', 'chore', 'revert', 'config'],
|
|
15
|
+
],
|
|
16
|
+
'subject-full-stop': [0, 'never'],
|
|
17
|
+
'subject-case': [0, 'never'],
|
|
18
|
+
'header-max-length': [0, 'always', 150],
|
|
19
|
+
},
|
|
20
|
+
};
|