Skip to content

Commit

Permalink
Fix bugs.
Browse files Browse the repository at this point in the history
  • Loading branch information
a632079 committed Jun 22, 2018
1 parent bc34969 commit 4c115f8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 15 deletions.
4 changes: 2 additions & 2 deletions src/controllers/netease.js
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ controllers.detail = async (ctx, next) => {
return
} else {
ret = await nm.song(ctx.params.id)
if (ret.songs.length > 0) {
if (Array.isArray(ret.songs) && ret.songs.length > 0) {
cache.set('nm:detail:' + ctx.params.id, ret, 60 * 60 * 2)
}
}
Expand Down Expand Up @@ -463,7 +463,7 @@ const Response400 = (ctx, code = 0) => {
const silentSummary = async (id, ctx) => {
// First, Get Music URL
const URLs = await nm.url(id)
if (URLs && URLs.data && URLs.data.length > 0) {
if (URLs && Array.isArray(URLs.data) && URLs.data.length > 0) {
const ids = []
for (let _ of URLs.data) {
if (_.code !== 404 && _.url) {
Expand Down
25 changes: 12 additions & 13 deletions src/route.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,19 +10,18 @@ class route {
}

async routes () {
let routes
await this.controller
.then((controller) => {
// Load RouteMap
const Router = require('koa-router')
const RouteMap = require(path.join(__dirname, '../', './routes'))(new Router(), controller)
routes = RouteMap
})
.catch(err => {
winston.error(err)
process.exit(1)
})
return routes
try {
let routes
const controller = await this.controller
// Load RouteMap
const Router = require('koa-router')
const RouteMap = require(path.join(__dirname, '../', './routes'))(new Router(), controller)
routes = RouteMap
return routes
} catch (err) {
winston.error(err)
process.exit(1)
}
}
}
module.exports = route

0 comments on commit 4c115f8

Please sign in to comment.