refactor(server): separate server from app

我們需要 NCM API 的伺服器部分,但 app.js
目前的做法讓我們不太好單獨啟動伺服器。

我將 app.js 的伺服器部分抽成各個函數,並將原有
會 blocking 的函數更改為非同步函式。
這樣不僅能最大化善用 Node.js 的 Event Loop,
亦能提升未來維護的程式碼易讀性。
This commit is contained in:
pan93412
2022-01-26 11:29:07 +08:00
parent 6d335bd85f
commit 7985690987
3 changed files with 271 additions and 146 deletions
+6 -2
View File
@@ -1,12 +1,12 @@
{
"name": "NeteaseCloudMusicApi",
"version": "4.2.0",
"version": "4.3.0",
"lockfileVersion": 2,
"requires": true,
"packages": {
"": {
"name": "NeteaseCloudMusicApi",
"version": "4.2.0",
"version": "4.3.0",
"license": "MIT",
"dependencies": {
"axios": "^0.24.0",
@@ -1502,6 +1502,8 @@
"resolved": "https://registry.npm.taobao.org/enquirer/download/enquirer-2.3.6.tgz?cache=0&sync_timestamp=1593693291943&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fenquirer%2Fdownload%2Fenquirer-2.3.6.tgz",
"integrity": "sha1-Kn/l3WNKHkElqXXsmU/1RW3Dc00=",
"dev": true,
"optional": true,
"peer": true,
"dependencies": {
"ansi-colors": "^4.1.1"
},
@@ -6743,6 +6745,8 @@
"resolved": "https://registry.npm.taobao.org/enquirer/download/enquirer-2.3.6.tgz?cache=0&sync_timestamp=1593693291943&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fenquirer%2Fdownload%2Fenquirer-2.3.6.tgz",
"integrity": "sha1-Kn/l3WNKHkElqXXsmU/1RW3Dc00=",
"dev": true,
"optional": true,
"peer": true,
"requires": {
"ansi-colors": "^4.1.1"
}