2021-04-03 17:46:54 +00:00
|
|
|
"use strict";
|
2021-06-28 22:10:02 +00:00
|
|
|
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());
|
|
|
|
});
|
|
|
|
};
|
2021-04-03 17:46:54 +00:00
|
|
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
|
|
};
|
|
|
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
|
const express_1 = __importDefault(require("express"));
|
2021-05-23 20:42:02 +00:00
|
|
|
// @ts-expect-error
|
|
|
|
const deezer_js_1 = require("deezer-js");
|
|
|
|
const main_1 = require("../main");
|
2021-04-03 17:46:54 +00:00
|
|
|
const router = express_1.default.Router();
|
2021-06-28 22:10:02 +00:00
|
|
|
let update = null;
|
2021-04-03 17:46:54 +00:00
|
|
|
/**
|
|
|
|
* GET home page
|
|
|
|
*
|
|
|
|
* @since 0.0.0
|
|
|
|
*/
|
|
|
|
router.get('/', (_, res) => {
|
2021-05-23 20:42:02 +00:00
|
|
|
res.render('index', { title: 'deemix' });
|
|
|
|
});
|
2021-06-28 22:10:02 +00:00
|
|
|
router.get('/connect', (req, res) => __awaiter(void 0, void 0, void 0, function* () {
|
2021-05-23 20:42:02 +00:00
|
|
|
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];
|
2021-06-28 22:10:02 +00:00
|
|
|
if (!update) {
|
|
|
|
update = {
|
2021-05-23 20:42:02 +00:00
|
|
|
currentCommit: 'testing',
|
|
|
|
latestCommit: 'testing',
|
|
|
|
updateAvailable: false,
|
2021-06-28 22:10:02 +00:00
|
|
|
deemixVersion: main_1.deemixVersion
|
|
|
|
};
|
|
|
|
}
|
|
|
|
const result = {
|
|
|
|
update,
|
2021-05-23 20:42:02 +00:00
|
|
|
autologin: !dz.logged_in,
|
|
|
|
currentUser: dz.current_user,
|
2021-06-28 22:10:02 +00:00
|
|
|
deezerAvailable: yield main_1.isDeezerAvailable()
|
2021-05-23 20:42:02 +00:00
|
|
|
};
|
2021-06-05 11:58:50 +00:00
|
|
|
const queue = main_1.getQueue();
|
|
|
|
if (Object.keys(queue.queue).length > 0) {
|
|
|
|
result.queue = queue;
|
2021-05-23 20:42:02 +00:00
|
|
|
}
|
|
|
|
res.send(result);
|
2021-06-28 22:10:02 +00:00
|
|
|
}));
|
2021-04-03 17:46:54 +00:00
|
|
|
exports.default = router;
|