Fixed lint issues

This commit is contained in:
RemixDev
2021-06-05 13:58:50 +02:00
parent e3e41f775f
commit aa3670bec1
24 changed files with 220 additions and 183 deletions

View File

@@ -13,18 +13,16 @@ Object.defineProperty(exports, "__esModule", { value: true });
const deezer_js_1 = require("deezer-js");
const main_1 = require("../../../main");
const path = '/album-search/';
const handler = (req, res, next) => __awaiter(void 0, void 0, void 0, function* () {
const handler = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
if (!main_1.sessionDZ[req.session.id])
main_1.sessionDZ[req.session.id] = new deezer_js_1.Deezer();
const dz = main_1.sessionDZ[req.session.id];
if (!req.query) {
res.status(400).send();
return next();
return res.status(400).send();
}
const { term, start, nb, ack } = parseQuery(req.query);
if (!term || term.trim() === '') {
res.status(400).send();
return next();
return res.status(400).send();
}
const albums = yield dz.api.search_album(term, { start, nb });
const output = {
@@ -32,9 +30,7 @@ const handler = (req, res, next) => __awaiter(void 0, void 0, void 0, function*
total: albums.data.length,
ack
};
res.send(output);
res.send();
next();
return res.send(output);
});
const apiHandler = { path, handler };
exports.default = apiHandler;

View File

@@ -1 +1,46 @@
"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
// @ts-expect-error
const deemix_1 = __importDefault(require("deemix"));
// @ts-expect-error
const deezer_js_1 = require("deezer-js");
const main_1 = require("../../../main");
const path = '/analyzeLink';
const handler = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
try {
if (!req.query || !req.query.term) {
return res.status(400).send({ errorMessage: 'No term specified', errorCode: 'AL01' });
}
const { term: linkToAnalyze } = req.query;
const [, linkType, linkId] = yield deemix_1.default.parseLink(linkToAnalyze);
const isTrackOrAlbum = ['track', 'album'].includes(linkType);
if (isTrackOrAlbum) {
if (!main_1.sessionDZ[req.session.id])
main_1.sessionDZ[req.session.id] = new deezer_js_1.Deezer();
const dz = main_1.sessionDZ[req.session.id];
const apiMethod = linkType === 'track' ? 'get_track' : 'get_album';
const resBody = yield dz.api[apiMethod](linkId);
return res.status(200).send(resBody);
}
return res.status(400).send({ errorMessage: 'Not supported', errorCode: 'AL02' });
}
catch (error) {
return res
.status(500)
.send({ errorMessage: 'The server had a problem. Please try again', errorObject: error, errorCode: 'AL03' });
}
});
const apiHandler = { path, handler };
exports.default = apiHandler;

View File

@@ -1 +1,19 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
// @ts-expect-error
const deezer_js_1 = require("deezer-js");
const main_1 = require("../../../main");
const path = '/changeAccount';
const handler = (req, res) => {
if (!req.query || !req.query.child) {
return res.status(400).send({ errorMessage: 'No child specified', errorCode: 'CA01' });
}
const { child: accountNum } = req.query;
if (!main_1.sessionDZ[req.session.id])
main_1.sessionDZ[req.session.id] = new deezer_js_1.Deezer();
const dz = main_1.sessionDZ[req.session.id];
const accountData = dz.change_account(accountNum);
return res.status(200).send(accountData);
};
const apiHandler = { path, handler };
exports.default = apiHandler;

View File

@@ -4,12 +4,7 @@ const main_1 = require("../../../main");
const path = '/getQueue';
// let homeCache: any
const handler = (_, res) => {
const result = {
queue: main_1.queue,
order: main_1.queueOrder
};
if (main_1.currentJob)
result.currentItem = main_1.currentJob.downloadObject.getSlimmedDict();
const result = main_1.getQueue();
res.send(result);
};
const apiHandler = { path, handler };

View File

@@ -31,14 +31,14 @@ const handler = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
if (!main_1.plugins.spotify.enabled) {
res.send({
collaborative: false,
description: "",
description: '',
external_urls: { spotify: null },
followers: { total: 0, href: null },
id: null,
images: [],
name: "Something went wrong",
name: 'Something went wrong',
owner: {
display_name: "Error",
display_name: 'Error',
id: null
},
public: true,
@@ -48,15 +48,15 @@ const handler = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
});
break;
}
let sp = main_1.plugins.spotify.sp;
const sp = main_1.plugins.spotify.sp;
let playlist = yield sp.getPlaylist(list_id);
playlist = playlist.body;
let tracklist = playlist.tracks.items;
while (playlist.tracks.next) {
let regExec = /offset=(\d+)&limit=(\d+)/g.exec(playlist.tracks.next);
let offset = regExec[1];
let limit = regExec[2];
let playlistTracks = yield sp.getPlaylistTracks(list_id, { offset, limit });
const regExec = /offset=(\d+)&limit=(\d+)/g.exec(playlist.tracks.next);
const offset = regExec[1];
const limit = regExec[2];
const playlistTracks = yield sp.getPlaylistTracks(list_id, { offset, limit });
playlist.tracks = playlistTracks.body;
tracklist = tracklist.concat(playlist.tracks.items);
}

View File

@@ -14,16 +14,16 @@ const path = '/getUserSpotifyPlaylists';
const handler = (req, res) => __awaiter(void 0, void 0, void 0, function* () {
let data;
if (main_1.plugins.spotify.enabled) {
let sp = main_1.plugins.spotify.sp;
const sp = main_1.plugins.spotify.sp;
const username = req.query.spotifyUser;
data = [];
let playlists = yield sp.getUserPlaylists(username);
let playlistList = playlists.body.items;
while (playlists.next) {
let regExec = /offset=(\d+)&limit=(\d+)/g.exec(playlists.next);
let offset = regExec[1];
let limit = regExec[2];
let newPlaylists = yield sp.getUserPlaylists(username, { offset, limit });
const regExec = /offset=(\d+)&limit=(\d+)/g.exec(playlists.next);
const offset = regExec[1];
const limit = regExec[2];
const newPlaylists = yield sp.getUserPlaylists(username, { offset, limit });
playlists = newPlaylists.body;
playlistList = playlistList.concat(playlists.items);
}

View File

@@ -3,6 +3,8 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const analyzeLink_1 = __importDefault(require("./analyzeLink"));
const changeAccount_1 = __importDefault(require("./changeAccount"));
const getHome_1 = __importDefault(require("./getHome"));
const getCharts_1 = __importDefault(require("./getCharts"));
const mainSearch_1 = __importDefault(require("./mainSearch"));
@@ -20,6 +22,8 @@ const getUserFavorites_1 = __importDefault(require("./getUserFavorites"));
const getQueue_1 = __importDefault(require("./getQueue"));
exports.default = [
albumSearch_1.default,
changeAccount_1.default,
analyzeLink_1.default,
getHome_1.default,
getCharts_1.default,
getChartTracks_1.default,