Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
m0_66418769
NeteaseCloudMusicApi
提交
b8d9fac7
N
NeteaseCloudMusicApi
项目概览
m0_66418769
/
NeteaseCloudMusicApi
与 Fork 源项目一致
从无法访问的项目Fork
通知
2
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
N
NeteaseCloudMusicApi
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
b8d9fac7
编写于
5月 31, 2018
作者:
D
dds_feng
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
自动注册 router 目录中的js文件为对应的路由, 免除在app.js中不停的添加 router 的问题
上级
7b9b1513
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
30 addition
and
256 deletion
+30
-256
app.js
app.js
+30
-256
未找到文件。
app.js
浏览文件 @
b8d9fac7
const
express
=
require
(
"
express
"
);
const
apicache
=
require
(
"
apicache
"
);
const
path
=
require
(
"
path
"
);
const
fs
=
require
(
"
fs
"
);
const
app
=
express
();
let
cache
=
apicache
.
middleware
;
...
...
@@ -32,263 +32,37 @@ app.use(function(req, res, next) {
next
();
});
// 获取专辑内容
app
.
use
(
"
/album
"
,
require
(
"
./router/album
"
));
// 获取歌手单曲
app
.
use
(
"
/artists
"
,
require
(
"
./router/artists
"
));
// 获取歌手专辑列表
app
.
use
(
"
/artist/album
"
,
require
(
"
./router/artist_album
"
));
//艺术家-信息
app
.
use
(
"
/artist/desc
"
,
require
(
"
./router/artist_desc
"
));
//艺术家-mv
app
.
use
(
"
/artist/mv
"
,
require
(
"
./router/artist_mv
"
));
// 收藏歌手
app
.
use
(
"
/artist/sub
"
,
require
(
"
./router/artist_sub
"
));
// 取消收藏歌手
app
.
use
(
"
/artist/unsub
"
,
require
(
"
./router/artist_unsub
"
));
// 已关注歌手
app
.
use
(
"
/artist/sublist
"
,
require
(
"
./router/artist_sublist
"
));
// 歌手分类
app
.
use
(
"
/artist/list
"
,
require
(
"
./router/artist_list
"
));
// 获取 banner
app
.
use
(
"
/banner
"
,
require
(
"
./router/banner
"
));
app
.
use
(
"
/check/music
"
,
require
(
"
./router/check_music
"
));
app
.
use
(
"
/comment/music
"
,
require
(
"
./router/comment_music
"
));
app
.
use
(
"
/comment/mv
"
,
require
(
"
./router/comment_mv
"
));
app
.
use
(
"
/comment/album
"
,
require
(
"
./router/comment_album
"
));
app
.
use
(
"
/comment/playlist
"
,
require
(
"
./router/comment_playlist
"
));
//未知 api
app
.
use
(
"
/comment/like
"
,
require
(
"
./router/comment_like
"
));
app
.
use
(
"
/comment/dj
"
,
require
(
"
./router/comment_dj
"
));
//签到
app
.
use
(
"
/daily_signin
"
,
require
(
"
./router/daily_signin
"
));
//djradio detail
app
.
use
(
"
/dj/detail
"
,
require
(
"
./router/dj_detail
"
));
//dj主播 radio
app
.
use
(
"
/dj/program
"
,
require
(
"
./router/dj_program
"
));
app
.
use
(
"
/dj/program/detail
"
,
require
(
"
./router/dj_program_detail
"
));
app
.
use
(
"
/dj/sub
"
,
require
(
"
./router/dj_sub
"
));
app
.
use
(
"
/dj/catelist
"
,
require
(
"
./router/dj_catelist
"
));
app
.
use
(
"
/dj/hot
"
,
require
(
"
./router/dj_hot
"
));
app
.
use
(
"
/dj/sublist
"
,
require
(
"
./router/dj_sublist
"
));
// 精选电台
app
.
use
(
"
/dj/recommend
"
,
require
(
"
./router/dj_recommend
"
));
//精选电台-分类电台
app
.
use
(
"
/dj/recommend/type
"
,
require
(
"
./router/dj_recommend_type
"
));
//获取动态
app
.
use
(
"
/event
"
,
require
(
"
./router/event
"
));
//垃圾桶
app
.
use
(
"
/fm_trash
"
,
require
(
"
./router/fm_trash
"
));
app
.
use
(
"
/follow
"
,
require
(
"
./router/follow
"
));
// 喜欢歌曲
app
.
use
(
"
/like
"
,
require
(
"
./router/like
"
));
app
.
use
(
"
/likelist
"
,
require
(
"
./router/likelist
"
));
//手机登录
app
.
use
(
"
/login/cellphone
"
,
require
(
"
./router/loginCellphone
"
));
//邮箱登录
app
.
use
(
"
/login
"
,
require
(
"
./router/login
"
));
//登录刷新
app
.
use
(
"
/login/refresh
"
,
require
(
"
./router/login_refresh
"
));
// 不明 api
app
.
use
(
"
/log/web
"
,
require
(
"
./router/logWeb
"
));
// 获取歌词
app
.
use
(
"
/lyric
"
,
require
(
"
./router/lyric
"
));
// 获取音乐 url
app
.
use
(
"
/music/url
"
,
require
(
"
./router/musicUrl
"
));
//最新 mv
app
.
use
(
"
/mv/first
"
,
require
(
"
./router/mv_first
"
));
//播放 mv
app
.
use
(
"
/mv/url
"
,
require
(
"
./router/mv_url
"
));
//mv
app
.
use
(
"
/mv
"
,
require
(
"
./router/mv
"
));
// 私人 FM
app
.
use
(
"
/personal_fm
"
,
require
(
"
./router/personal_fm
"
));
//推荐歌单
app
.
use
(
"
/personalized
"
,
require
(
"
./router/personalized
"
));
//推荐dj
app
.
use
(
"
/personalized/djprogram
"
,
require
(
"
./router/personalized_djprogram
"
));
//推荐新音乐
app
.
use
(
"
/personalized/newsong
"
,
require
(
"
./router/personalized_newsong
"
));
//独家放送
app
.
use
(
"
/personalized/privatecontent
"
,
require
(
"
./router/personalized_privatecontent
"
)
);
//推荐mv
app
.
use
(
"
/personalized/mv
"
,
require
(
"
./router/personalized_mv
"
));
// 获取歌单内列表
app
.
use
(
"
/playlist/detail
"
,
require
(
"
./router/playlist_detail
"
));
//收藏单曲到歌单,从歌单删除歌曲 op=del,add;pid=歌单id,tracks=歌曲id
app
.
use
(
"
/playlist/tracks
"
,
require
(
"
./router/playlist_tracks
"
));
// 热门歌单分类
app
.
use
(
"
/playlist/hot
"
,
require
(
"
./router/playlist_hot
"
));
// 全部歌单分类
app
.
use
(
"
/playlist/catlist
"
,
require
(
"
./router/playlist_catlist
"
));
// 新建歌单
app
.
use
(
"
/playlist/create
"
,
require
(
"
./router/playlist_create
"
));
// 收藏/取消收藏歌单
app
.
use
(
"
/playlist/subscribe
"
,
require
(
"
./router/playlist_subscribe
"
));
//推荐节目
app
.
use
(
"
/program/recommend
"
,
require
(
"
./router/program_recommend
"
));
// 获取每日推荐歌曲
app
.
use
(
"
/recommend/songs
"
,
require
(
"
./router/recommend_songs
"
));
// 获取每日推荐歌单
app
.
use
(
"
/recommend/resource
"
,
require
(
"
./router/recommend_resource
"
));
//取消推荐
app
.
use
(
"
/recommend/dislike
"
,
require
(
"
./router/recommend_dislike
"
));
app
.
use
(
"
/resource/like
"
,
require
(
"
./router/resource_like
"
));
// 搜索
app
.
use
(
"
/search
"
,
require
(
"
./router/search
"
));
// 热搜
app
.
use
(
"
/search/hot
"
,
require
(
"
./router/search_hot.js
"
));
//搜索 multimatch
app
.
use
(
"
/search/multimatch
"
,
require
(
"
./router/search_multimatch
"
));
// 搜索 suggest,搜索结果包含单曲,歌手,歌单,mv信息
app
.
use
(
"
/search/suggest
"
,
require
(
"
./router/search_suggest
"
));
//simi ,相似歌单
app
.
use
(
"
/simi/playlist
"
,
require
(
"
./router/simi_playlist
"
));
//simi ,相似歌曲
app
.
use
(
"
/simi/song
"
,
require
(
"
./router/simi_song
"
));
//相似 mv
app
.
use
(
"
/simi/mv
"
,
require
(
"
./router/simi_mv
"
));
//simi ,相似关注的用户
app
.
use
(
"
/simi/user
"
,
require
(
"
./router/simi_user
"
));
//相似歌手
app
.
use
(
"
/simi/artist
"
,
require
(
"
./router/simi_artist
"
));
// 获取音乐详情
app
.
use
(
"
/song/detail
"
,
require
(
"
./router/song_detail
"
));
// 新碟上架 http://music.163.com/#/discover/album/
app
.
use
(
"
/top/album
"
,
require
(
"
./router/top_album
"
));
// 热门歌手 http://music.163.com/#/discover/artist/
app
.
use
(
"
/top/artists
"
,
require
(
"
./router/top_artists
"
));
app
.
use
(
"
/top/list
"
,
require
(
"
./router/top_list
"
));
app
.
use
(
"
/top/mv
"
,
require
(
"
./router/top_mv
"
));
//分类歌单
app
.
use
(
"
/top/playlist
"
,
require
(
"
./router/top_playlist
"
));
//精品歌单
app
.
use
(
"
/top/playlist/highquality
"
,
require
(
"
./router/top_playlist_highquality
"
)
);
app
.
use
(
"
/top/song
"
,
require
(
"
./router/top_song
"
));
app
.
use
(
"
/toplist
"
,
require
(
"
./router/toplist
"
));
app
.
use
(
"
/toplist/artist
"
,
require
(
"
./router/toplist_artist
"
));
app
.
use
(
"
/toplist/detail
"
,
require
(
"
./router/toplist_detail
"
));
// 获取用户歌单
app
.
use
(
"
/user/playlist
"
,
require
(
"
./router/user_playlist
"
));
// 获取用户电台
app
.
use
(
"
/user/audio
"
,
require
(
"
./router/user_audio
"
));
//云盘数据
app
.
use
(
"
/user/cloud
"
,
require
(
"
./router/user_cloud
"
));
//云盘数据详情? 暂时不要使用
app
.
use
(
"
/user/cloud/search
"
,
require
(
"
./router/user_cloud_search
"
));
//用户动态
app
.
use
(
"
/user/event
"
,
require
(
"
./router/user_event
"
));
app
.
use
(
"
/user/detail
"
,
require
(
"
./router/user_detail
"
));
app
.
use
(
"
/user/dj
"
,
require
(
"
./router/user_dj
"
));
app
.
use
(
"
/user/followeds
"
,
require
(
"
./router/user_followeds
"
));
app
.
use
(
"
/user/follows
"
,
require
(
"
./router/user_follows
"
));
app
.
use
(
"
/user/subcount
"
,
require
(
"
./router/user_subcount
"
));
app
.
use
(
"
/user/record
"
,
require
(
"
./router/user_record
"
));
app
.
use
(
"
/user/update
"
,
require
(
"
./router/user_update
"
));
app
.
use
(
"
/send/text
"
,
require
(
"
./router/send_text
"
));
app
.
use
(
"
/send/playlist
"
,
require
(
"
./router/send_playlist
"
));
app
.
use
(
"
/playlist/create
"
,
require
(
"
./router/playlist_create
"
));
// 因为这几个文件对外所注册的路由 和 其他文件对外注册的路由规则不一样, 所以专门写个MAP对这些文件做特殊处理
const
UnusualRouteFileMap
=
{
// key 为文件名, value 为对外注册的路由
"
daily_signin.js
"
:
"
/daily_signin
"
,
"
fm_trash.js
"
:
"
/fm_trash
"
,
"
personal_fm.js
"
:
"
/personal_fm
"
};
// 同步读取 router 目录中的js文件, 根据命名规则, 自动注册路由
fs
.
readdirSync
(
"
./router/
"
).
forEach
(
file
=>
{
if
(
/
\.
js$/i
.
test
(
file
)
===
false
)
{
return
;
}
app
.
use
(
"
/playlist/subscribe
"
,
require
(
"
./router/playlist_subscribe
"
));
let
route
;
if
(
typeof
UnusualRouteFileMap
[
file
]
!==
"
undefined
"
)
{
route
=
UnusualRouteFileMap
[
file
];
}
else
{
route
=
"
/
"
+
file
.
replace
(
/
\.
js$/i
,
""
)
.
replace
(
/_/g
,
"
/
"
)
.
replace
(
/
[
A-Z
]
/g
,
a
=>
{
return
"
/
"
+
a
.
toLowerCase
();
});
}
app
.
use
(
"
/playlist/update
"
,
require
(
"
./router/playlist_update
"
));
app
.
use
(
route
,
require
(
"
./router/
"
+
file
));
});
const
port
=
process
.
env
.
PORT
||
3000
;
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录