Skip to content
This repository has been archived by the owner on Jun 26, 2024. It is now read-only.

Commit

Permalink
Fix api server bug
Browse files Browse the repository at this point in the history
  • Loading branch information
trazyn committed Jul 6, 2018
1 parent 48a442d commit ed35759
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"build-main": "cross-env NODE_ENV=production node -r babel-register ./node_modules/webpack/bin/webpack --config ./config/webpack.config.electron.js --progress --profile --colors",
"build-renderer": "cross-env NODE_ENV=production node -r babel-register ./node_modules/webpack/bin/webpack --config ./config/webpack.config.production.js --progress --profile --colors",
"build": "rm -rf dist && npm run build-main && npm run build-renderer",
"api": "cross-env NODE_ENV=development AUTORUN=1 DEBUG_COLORS=true DEBUG=dev:*,-not_this node -r babel-register server/api.js",
"api": "cross-env NODE_ENV=development APIONLY=1 DEBUG_COLORS=true DEBUG=dev:*,-not_this node -r babel-register server/api.js",
"hot-server": "cross-env NODE_ENV=development DEBUG_COLORS=true DEBUG=dev:*,-not_this node -r babel-register server/dev.js",
"start-hot": "cross-env HOT=1 NODE_ENV=development DEBUG_COLORS=true DEBUG=dev:*,-not_this ./node_modules/.bin/electron -r babel-register -r babel-polyfill ./main",
"package-mac": "npm run build && rm -rf release && build --mac --projectDir ./dist",
Expand Down
2 changes: 1 addition & 1 deletion server/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ app.use('/api/search', require('./router/search'));
app.use('/api/comments', require('./router/comments'));
app.use('/api/lyrics', cache('360 minutes'), require('./router/lyrics'));

if (process.env.AUTORUN) {
if (process.env.APIONLY) {
console.log(`API Server run with port: ${port}`);
app.listen(port);
}
Expand Down
9 changes: 5 additions & 4 deletions server/router/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import apicache from 'apicache'
import axios from 'axios';
import _debug from 'debug';
import chalk from 'chalk';
import search from '../search';
/* eslint-enable */

const debug = _debug('dev:api');
Expand Down Expand Up @@ -260,9 +259,11 @@ router.get('/song/:id/:name/:artists/:flac?', cache('3 minutes', onlyStatus200),
}
} catch (ex) {
try {
// Search from other source
debug(chalk.underline.black.bgYellow(`🔎 ${name} - ${artists}`));
song = await search(name, artists);
if (!process.env.APIONLY) {
// Search from other source
debug(chalk.underline.black.bgYellow(`🔎 ${name} - ${artists}`));
song = await require('../search').default(name, artists);
}
} catch (ex) {
debug(chalk.red.underline.bold(`💔 Not found: "${name} - ${artists}"`));
}
Expand Down

0 comments on commit ed35759

Please sign in to comment.