We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi 各位使用和 forked 的小伙伴们, 我正在计划着将本项目的版本更新一下,由于本人时间有限,所以恳请各位的支援,欢迎大家 PR 或者在此处👇 讨论。
forked
更多请看👇详情描述
v2.0.0
v2.0.0大版本修改是为了修复之前 接口设计 的 可读性差 , API 不合理 等众多问题。
我们在旧版本的基础上, 针对性修改。所以对 接口参数, 接口返回, 路由 等方面做了一定的 优化, 我们推荐新用户使用当前时间最新版 v2.0.0。
下面我们拿 singer.js 举个 🌰
singer.js
const YRequest = require('../module/y-axios'); const URequest = require('../module/URequest'); const { commonParams } = require('../module/config'); const moment = require('moment'); const { handleXml } = require('../util/xml'); const singerParams = Object.assign(commonParams, { g_tk: 1290642389, sign: 'zzafsjavizx8rzd4m36c2a7e17c9f884980ef9092cb8809e415', format: 'json', }); // /singe/similar?singermid=0025NhlN2yWrP4 const similarOld = async (ctx, next) => { const { singermid: singer_mid } = ctx.query; const options = { params: { format: 'json', outCharset: 'utf-8', utf8: 1, start: 0, num: 5, singer_mid, }, }; return await YRequest({ url: '/v8/fcg-bin/fcg_v8_simsinger.fcg', method: 'get', options, thenable: res => { if (!singer_mid) { ctx.status = 400; ctx.body = { message: 'no singermid', }; return; } Object.assign(ctx, { status: 200, body: { response: res.data, }, }); }, catcher: error => { console.log('error', error); ctx.status = 400; ctx.body = { error }; }, }); }; // 周杰伦 /singe/similar?id=4558&singermid=0025NhlN2yWrP4 const similar = async (ctx, next) => { const { id: singerId, singermid: singerMid, pageSize: num = 5 } = ctx.query; console.log('similar error: not support pageSize'); const data = { comm: { ct: 24, cv: 10000, }, similarSingerList: { method: 'GetSimilarSingerList', param: { singerId: parseInt(singerId, 10), singerMid, // TODO: QQ 貌似不支持 num: 5, }, module: 'music.SimilarSingerSvr', }, }; const params = Object.assign(singerParams, { '-': 'getSimilarSingerList1112654390871275', data: JSON.stringify(data), }); return await URequest({ method: 'get', params, thenable: res => { if (!singerMid) { ctx.status = 400; ctx.body = { message: 'no singermid', }; return; } Object.assign(ctx, { status: 200, body: { data: res.data, }, }); }, catcher: error => { console.log('error', error); ctx.status = 400; ctx.body = { error }; }, }); }; module.exports = { getSimilarSingerOld: similarOld, getSimilarSinger: similar, };
对于先前接入的用户, 我们也做了一些兼容性的接口处理, 主要是 路由的变化 mapping, 具体可以在 routers/map-router.js 👇中体现, 感谢你的关注和使用。
routers/map-router.js
const context = require('.'); module.exports = { // INFO: singer Module // /getSimilarSinger?singermid=0025NhlN2yWrP4 '/getSimilarSinger/:singermid?': { cb: context.getSimilarSingerOld, }, // /singe/similar?id=4558&singermid=0025NhlN2yWrP4 '/singer/similar/:id/:singermid/:pageNum?': { cb: context.getSimilarSinger, }, };
const Router = require('koa-router'); const router = new Router(); const mapRouter = require('./map-router'); Object.keys(mapRouter).forEach(key => { if (key && mapRouter[key]) { const { method = 'get', cb } = mapRouter[key]; router[method](key, cb); } }); module.exports = router;
The text was updated successfully, but these errors were encountered:
Rain120
Successfully merging a pull request may close this issue.
Hi 各位使用和
forked
的小伙伴们, 我正在计划着将本项目的版本更新一下,由于本人时间有限,所以恳请各位的支援,欢迎大家 PR 或者在此处👇 讨论。Goals
更多请看👇详情描述
Status
Branch
v2.0.0
Description
v2.0.0
大版本修改是为了修复之前 接口设计 的 可读性差 , API 不合理 等众多问题。我们在旧版本的基础上, 针对性修改。所以对 接口参数, 接口返回, 路由 等方面做了一定的 优化, 我们推荐新用户使用当前时间最新版
v2.0.0
。下面我们拿
singer.js
举个 🌰singer.js
对于先前接入的用户, 我们也做了一些兼容性的接口处理, 主要是 路由的变化 mapping, 具体可以在
routers/map-router.js
👇中体现, 感谢你的关注和使用。map-router.js
new-router.js
The text was updated successfully, but these errors were encountered: