fix: type checking errors; feat: added .yarnrc file; chore: linting
This commit is contained in:
parent
d672b9bc55
commit
9fc36abf06
1
server/.yarnrc
Normal file
1
server/.yarnrc
Normal file
@ -0,0 +1 @@
|
|||||||
|
save-prefix: ""
|
@ -1,10 +1,10 @@
|
|||||||
NODE_BIN ?= .\node_modules\.bin
|
NODE_BIN ?= .\node_modules\.bin
|
||||||
|
|
||||||
lint:
|
lint:
|
||||||
@$(NODE_BIN)\eslint ./src/** --fix
|
$(NODE_BIN)\eslint ./src/** --fix
|
||||||
|
|
||||||
test:
|
test:
|
||||||
@$(NODE_BIN)\jest
|
$(NODE_BIN)\jest
|
||||||
|
|
||||||
build: lint test
|
build: lint test
|
||||||
@$(NODE_BIN)\tsc
|
$(NODE_BIN)\tsc
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
|
||||||
// @ts-expect-error
|
|
||||||
import deemix from 'deemix'
|
import deemix from 'deemix'
|
||||||
|
|
||||||
export let settings: any = deemix.settings.load()
|
export const settings: any = deemix.settings.load()
|
||||||
export const defaultSettings: any = deemix.settings.DEFAULTS
|
export const defaultSettings: any = deemix.settings.DEFAULTS
|
||||||
export let sessionDZ: any = {}
|
export const sessionDZ: any = {}
|
||||||
|
@ -4,14 +4,14 @@ import express from 'express'
|
|||||||
import cookieParser from 'cookie-parser'
|
import cookieParser from 'cookie-parser'
|
||||||
import session from 'express-session'
|
import session from 'express-session'
|
||||||
|
|
||||||
declare module 'express-session' {
|
|
||||||
export interface SessionData {
|
|
||||||
dz: any;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
import { WEBUI_DIR } from './helpers/paths'
|
import { WEBUI_DIR } from './helpers/paths'
|
||||||
|
|
||||||
|
declare module 'express-session' {
|
||||||
|
export interface SessionData {
|
||||||
|
dz: any
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
export function registerMiddlewares(app: Application) {
|
export function registerMiddlewares(app: Application) {
|
||||||
if (process.env.NODE_ENV !== 'test') {
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
app.use(logger('dev'))
|
app.use(logger('dev'))
|
||||||
@ -20,10 +20,12 @@ export function registerMiddlewares(app: Application) {
|
|||||||
app.use(express.json())
|
app.use(express.json())
|
||||||
app.use(express.urlencoded({ extended: false }))
|
app.use(express.urlencoded({ extended: false }))
|
||||||
app.use(cookieParser())
|
app.use(cookieParser())
|
||||||
app.use(session({
|
app.use(
|
||||||
secret: "U2hoLCBpdHMgYSBzZWNyZXQh",
|
session({
|
||||||
resave: true,
|
secret: 'U2hoLCBpdHMgYSBzZWNyZXQh',
|
||||||
saveUninitialized: true
|
resave: true,
|
||||||
}))
|
saveUninitialized: true
|
||||||
|
})
|
||||||
|
)
|
||||||
app.use(express.static(WEBUI_DIR))
|
app.use(express.static(WEBUI_DIR))
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { RequestHandler } from 'express'
|
import { RequestHandler } from 'express'
|
||||||
import { ApiHandler } from '../../../types'
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
|
import { ApiHandler } from '../../../types'
|
||||||
import { sessionDZ } from '../../../main'
|
import { sessionDZ } from '../../../main'
|
||||||
|
|
||||||
export interface RawAlbumQuery {
|
export interface RawAlbumQuery {
|
||||||
@ -26,7 +26,7 @@ const path: ApiHandler['path'] = '/album-search/'
|
|||||||
|
|
||||||
const handler: RequestHandler<{}, {}, {}, RawAlbumQuery> = async (req, res, next) => {
|
const handler: RequestHandler<{}, {}, {}, RawAlbumQuery> = async (req, res, next) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
|
|
||||||
if (!req.query) {
|
if (!req.query) {
|
||||||
res.status(400).send()
|
res.status(400).send()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import { RequestHandler } from 'express'
|
import { RequestHandler } from 'express'
|
||||||
import { ApiHandler } from '../../../types'
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
|
import { ApiHandler } from '../../../types'
|
||||||
import { sessionDZ } from '../../../main'
|
import { sessionDZ } from '../../../main'
|
||||||
|
|
||||||
import { isObjectEmpy } from '../../../helpers/primitive-checks'
|
import { isObjectEmpy } from '../../../helpers/primitive-checks'
|
||||||
@ -18,7 +18,7 @@ const path: ApiHandler['path'] = '/getChartTracks'
|
|||||||
const handler: RequestHandler<{}, {}, {}, RawChartTracksQuery> = async (req, res, next) => {
|
const handler: RequestHandler<{}, {}, {}, RawChartTracksQuery> = async (req, res, next) => {
|
||||||
try {
|
try {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
|
|
||||||
if (isObjectEmpy(req.query) || !req.query.id) {
|
if (isObjectEmpy(req.query) || !req.query.id) {
|
||||||
throw new BadRequestError()
|
throw new BadRequestError()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { ApiHandler } from '../../../types'
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
|
import { ApiHandler } from '../../../types'
|
||||||
import { sessionDZ } from '../../../main'
|
import { sessionDZ } from '../../../main'
|
||||||
|
|
||||||
const path: ApiHandler['path'] = '/getCharts'
|
const path: ApiHandler['path'] = '/getCharts'
|
||||||
@ -10,7 +10,7 @@ let chartsCache: any
|
|||||||
const handler: ApiHandler['handler'] = async (req, res) => {
|
const handler: ApiHandler['handler'] = async (req, res) => {
|
||||||
if (!chartsCache) {
|
if (!chartsCache) {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
|
|
||||||
const chartsData = await dz.api.get_countries_charts()
|
const chartsData = await dz.api.get_countries_charts()
|
||||||
const countries: any[] = []
|
const countries: any[] = []
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
import { ApiHandler } from '../../../types'
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
|
import { ApiHandler } from '../../../types'
|
||||||
import { sessionDZ } from '../../../main'
|
import { sessionDZ } from '../../../main'
|
||||||
|
|
||||||
const path: ApiHandler['path'] = '/getHome'
|
const path: ApiHandler['path'] = '/getHome'
|
||||||
@ -9,7 +9,7 @@ let homeCache: any
|
|||||||
|
|
||||||
const handler: ApiHandler['handler'] = async (req, res) => {
|
const handler: ApiHandler['handler'] = async (req, res) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
|
|
||||||
if (!homeCache) {
|
if (!homeCache) {
|
||||||
homeCache = await dz.api.get_chart(0, { limit: 30 })
|
homeCache = await dz.api.get_chart(0, { limit: 30 })
|
||||||
|
@ -4,7 +4,7 @@ import { settings, defaultSettings } from '../../../main'
|
|||||||
const path: ApiHandler['path'] = '/getSettings'
|
const path: ApiHandler['path'] = '/getSettings'
|
||||||
|
|
||||||
const handler: ApiHandler['handler'] = async (_, res) => {
|
const handler: ApiHandler['handler'] = async (_, res) => {
|
||||||
res.send({settings, defaultSettings})
|
res.send({ settings, defaultSettings })
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiHandler: ApiHandler = { path, handler }
|
const apiHandler: ApiHandler = { path, handler }
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
import { ApiHandler } from '../../../types'
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
|
import { ApiHandler } from '../../../types'
|
||||||
import { sessionDZ } from '../../../main'
|
import { sessionDZ } from '../../../main'
|
||||||
|
|
||||||
const path: ApiHandler['path'] = '/getTracklist'
|
const path: ApiHandler['path'] = '/getTracklist'
|
||||||
|
|
||||||
const handler: ApiHandler['handler'] = async (req, res) => {
|
const handler: ApiHandler['handler'] = async (req, res) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
|
|
||||||
let list_id = String(req.query.id)
|
const list_id = String(req.query.id)
|
||||||
let list_type = String(req.query.type)
|
const list_type = String(req.query.type)
|
||||||
switch (list_type) {
|
switch (list_type) {
|
||||||
case 'artist': {
|
case 'artist': {
|
||||||
const artistAPI = await dz.api.get_artist(list_id)
|
const artistAPI = await dz.api.get_artist(list_id)
|
||||||
artistAPI.releases = await dz.gw.get_artist_discography_tabs(list_id, {limit: 100})
|
artistAPI.releases = await dz.gw.get_artist_discography_tabs(list_id, { limit: 100 })
|
||||||
res.send(artistAPI)
|
res.send(artistAPI)
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
import { ApiHandler } from '../../../types'
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
|
import { ApiHandler } from '../../../types'
|
||||||
import { sessionDZ } from '../../../main'
|
import { sessionDZ } from '../../../main'
|
||||||
|
|
||||||
const path: ApiHandler['path'] = '/getUserAlbums'
|
const path: ApiHandler['path'] = '/getUserAlbums'
|
||||||
|
|
||||||
const handler: ApiHandler['handler'] = async (req, res) => {
|
const handler: ApiHandler['handler'] = async (req, res) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
let data
|
let data
|
||||||
|
|
||||||
if (dz.logged_in){
|
if (dz.logged_in) {
|
||||||
let userID = dz.current_user.id
|
const userID = dz.current_user.id
|
||||||
try {
|
try {
|
||||||
data = await dz.api.get_user_albums(userID, {limit: -1})
|
data = await dz.api.get_user_albums(userID, { limit: -1 })
|
||||||
data = data.data
|
data = data.data
|
||||||
} catch {
|
} catch {
|
||||||
data = await dz.gw.get_user_albums(userID, {limit: -1})
|
data = await dz.gw.get_user_albums(userID, { limit: -1 })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data = {error: "notLoggedIn"}
|
data = { error: 'notLoggedIn' }
|
||||||
}
|
}
|
||||||
res.send(data)
|
res.send(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiHandler: ApiHandler = { path, handler }
|
const apiHandler: ApiHandler = { path, handler }
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
import { ApiHandler } from '../../../types'
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
|
import { ApiHandler } from '../../../types'
|
||||||
import { sessionDZ } from '../../../main'
|
import { sessionDZ } from '../../../main'
|
||||||
|
|
||||||
const path: ApiHandler['path'] = '/getUserArtists'
|
const path: ApiHandler['path'] = '/getUserArtists'
|
||||||
|
|
||||||
const handler: ApiHandler['handler'] = async (req, res) => {
|
const handler: ApiHandler['handler'] = async (req, res) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
let data
|
let data
|
||||||
|
|
||||||
if (dz.logged_in){
|
if (dz.logged_in) {
|
||||||
let userID = dz.current_user.id
|
const userID = dz.current_user.id
|
||||||
try {
|
try {
|
||||||
data = await dz.api.get_user_artists(userID, {limit: -1})
|
data = await dz.api.get_user_artists(userID, { limit: -1 })
|
||||||
data = data.data
|
data = data.data
|
||||||
} catch {
|
} catch {
|
||||||
data = await dz.gw.get_user_artists(userID, {limit: -1})
|
data = await dz.gw.get_user_artists(userID, { limit: -1 })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data = {error: "notLoggedIn"}
|
data = { error: 'notLoggedIn' }
|
||||||
}
|
}
|
||||||
res.send(data)
|
res.send(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiHandler: ApiHandler = { path, handler }
|
const apiHandler: ApiHandler = { path, handler }
|
||||||
|
@ -1,39 +1,39 @@
|
|||||||
import { ApiHandler } from '../../../types'
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
|
import { ApiHandler } from '../../../types'
|
||||||
import { sessionDZ } from '../../../main'
|
import { sessionDZ } from '../../../main'
|
||||||
|
|
||||||
const path: ApiHandler['path'] = '/getUserFavorites'
|
const path: ApiHandler['path'] = '/getUserFavorites'
|
||||||
|
|
||||||
const handler: ApiHandler['handler'] = async (req, res) => {
|
const handler: ApiHandler['handler'] = async (req, res) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
|
|
||||||
let result: any = {}
|
let result: any = {}
|
||||||
|
|
||||||
if (dz.logged_in){
|
if (dz.logged_in) {
|
||||||
let userID = dz.current_user.id
|
const userID = dz.current_user.id
|
||||||
|
|
||||||
try {
|
try {
|
||||||
let data
|
let data
|
||||||
data = await dz.api.get_user_playlists(userID, {limit: -1})
|
data = await dz.api.get_user_playlists(userID, { limit: -1 })
|
||||||
result['playlists'] = data.data
|
result.playlists = data.data
|
||||||
data = await dz.api.get_user_albums(userID, {limit: -1})
|
data = await dz.api.get_user_albums(userID, { limit: -1 })
|
||||||
result['albums'] = data.data
|
result.albums = data.data
|
||||||
data = await dz.api.get_user_artists(userID, {limit: -1})
|
data = await dz.api.get_user_artists(userID, { limit: -1 })
|
||||||
result['artists'] = data.data
|
result.artists = data.data
|
||||||
data = await dz.api.get_user_tracks(userID, {limit: -1})
|
data = await dz.api.get_user_tracks(userID, { limit: -1 })
|
||||||
result['tracks'] = data.data
|
result.tracks = data.data
|
||||||
} catch {
|
} catch {
|
||||||
result['playlists'] = await dz.gw.get_user_playlists(userID, {limit: -1})
|
result.playlists = await dz.gw.get_user_playlists(userID, { limit: -1 })
|
||||||
result['albums'] = await dz.gw.get_user_albums(userID, {limit: -1})
|
result.albums = await dz.gw.get_user_albums(userID, { limit: -1 })
|
||||||
result['artists'] = await dz.gw.get_user_artists(userID, {limit: -1})
|
result.artists = await dz.gw.get_user_artists(userID, { limit: -1 })
|
||||||
result['tracks'] = await dz.gw.get_user_tracks(userID, {limit: -1})
|
result.tracks = await dz.gw.get_user_tracks(userID, { limit: -1 })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result = {error: "notLoggedIn"}
|
result = { error: 'notLoggedIn' }
|
||||||
}
|
}
|
||||||
res.send(result)
|
res.send(result)
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiHandler: ApiHandler = { path, handler }
|
const apiHandler: ApiHandler = { path, handler }
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
import { ApiHandler } from '../../../types'
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
|
import { ApiHandler } from '../../../types'
|
||||||
import { sessionDZ } from '../../../main'
|
import { sessionDZ } from '../../../main'
|
||||||
|
|
||||||
const path: ApiHandler['path'] = '/getUserPlaylists'
|
const path: ApiHandler['path'] = '/getUserPlaylists'
|
||||||
|
|
||||||
const handler: ApiHandler['handler'] = async (req, res) => {
|
const handler: ApiHandler['handler'] = async (req, res) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
let data
|
let data
|
||||||
|
|
||||||
if (dz.logged_in){
|
if (dz.logged_in) {
|
||||||
let userID = dz.current_user.id
|
const userID = dz.current_user.id
|
||||||
try {
|
try {
|
||||||
data = await dz.api.get_user_playlists(userID, {limit: -1})
|
data = await dz.api.get_user_playlists(userID, { limit: -1 })
|
||||||
data = data.data
|
data = data.data
|
||||||
} catch {
|
} catch {
|
||||||
data = await dz.gw.get_user_playlists(userID, {limit: -1})
|
data = await dz.gw.get_user_playlists(userID, { limit: -1 })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data = {error: "notLoggedIn"}
|
data = { error: 'notLoggedIn' }
|
||||||
}
|
}
|
||||||
res.send(data)
|
res.send(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiHandler: ApiHandler = { path, handler }
|
const apiHandler: ApiHandler = { path, handler }
|
||||||
|
@ -1,27 +1,27 @@
|
|||||||
import { ApiHandler } from '../../../types'
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
|
import { ApiHandler } from '../../../types'
|
||||||
import { sessionDZ } from '../../../main'
|
import { sessionDZ } from '../../../main'
|
||||||
|
|
||||||
const path: ApiHandler['path'] = '/getUserTracks'
|
const path: ApiHandler['path'] = '/getUserTracks'
|
||||||
|
|
||||||
const handler: ApiHandler['handler'] = async (req, res) => {
|
const handler: ApiHandler['handler'] = async (req, res) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
let data
|
let data
|
||||||
|
|
||||||
if (dz.logged_in){
|
if (dz.logged_in) {
|
||||||
let userID = dz.current_user.id
|
const userID = dz.current_user.id
|
||||||
try {
|
try {
|
||||||
data = await dz.api.get_user_tracks(userID, {limit: -1})
|
data = await dz.api.get_user_tracks(userID, { limit: -1 })
|
||||||
data = data.data
|
data = data.data
|
||||||
} catch {
|
} catch {
|
||||||
data = await dz.gw.get_user_tracks(userID, {limit: -1})
|
data = await dz.gw.get_user_tracks(userID, { limit: -1 })
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
data = {error: "notLoggedIn"}
|
data = { error: 'notLoggedIn' }
|
||||||
}
|
}
|
||||||
res.send(data)
|
res.send(data)
|
||||||
}
|
}
|
||||||
|
|
||||||
const apiHandler: ApiHandler = { path, handler }
|
const apiHandler: ApiHandler = { path, handler }
|
||||||
|
@ -13,17 +13,17 @@ import getUserPlaylists from './getUserPlaylists'
|
|||||||
import getUserFavorites from './getUserFavorites'
|
import getUserFavorites from './getUserFavorites'
|
||||||
|
|
||||||
export default [
|
export default [
|
||||||
albumSearch,
|
albumSearch,
|
||||||
getHome,
|
getHome,
|
||||||
getCharts,
|
getCharts,
|
||||||
getChartTracks,
|
getChartTracks,
|
||||||
mainSearch,
|
mainSearch,
|
||||||
search,
|
search,
|
||||||
getTracklist,
|
getTracklist,
|
||||||
getSettings,
|
getSettings,
|
||||||
getUserTracks,
|
getUserTracks,
|
||||||
getUserAlbums,
|
getUserAlbums,
|
||||||
getUserArtists,
|
getUserArtists,
|
||||||
getUserPlaylists,
|
getUserPlaylists,
|
||||||
getUserFavorites
|
getUserFavorites
|
||||||
]
|
]
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
import { ApiHandler } from '../../../types'
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
|
import { ApiHandler } from '../../../types'
|
||||||
import { sessionDZ } from '../../../main'
|
import { sessionDZ } from '../../../main'
|
||||||
|
|
||||||
const path: ApiHandler['path'] = '/mainSearch'
|
const path: ApiHandler['path'] = '/mainSearch'
|
||||||
|
|
||||||
const handler: ApiHandler['handler'] = async (req, res) => {
|
const handler: ApiHandler['handler'] = async (req, res) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
|
|
||||||
const term = String(req.query.term)
|
const term = String(req.query.term)
|
||||||
let results = await dz.gw.search(term)
|
const results = await dz.gw.search(term)
|
||||||
const order: string[] = []
|
const order: string[] = []
|
||||||
results.ORDER.forEach((element: string) => {
|
results.ORDER.forEach((element: string) => {
|
||||||
if (['TOP_RESULT', 'TRACK', 'ALBUM', 'ARTIST', 'PLAYLIST'].includes(element)) order.push(element)
|
if (['TOP_RESULT', 'TRACK', 'ALBUM', 'ARTIST', 'PLAYLIST'].includes(element)) order.push(element)
|
||||||
|
@ -1,20 +1,20 @@
|
|||||||
import { ApiHandler } from '../../../types'
|
|
||||||
// @ts-expect-error
|
// @ts-expect-error
|
||||||
import { Deezer } from 'deezer-js'
|
import { Deezer } from 'deezer-js'
|
||||||
|
import { ApiHandler } from '../../../types'
|
||||||
import { sessionDZ } from '../../../main'
|
import { sessionDZ } from '../../../main'
|
||||||
|
|
||||||
const path: ApiHandler['path'] = '/search'
|
const path: ApiHandler['path'] = '/search'
|
||||||
|
|
||||||
const handler: ApiHandler['handler'] = async (req, res) => {
|
const handler: ApiHandler['handler'] = async (req, res) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
|
|
||||||
const term = String(req.query.term)
|
const term = String(req.query.term)
|
||||||
const type = String(req.query.type)
|
const type = String(req.query.type)
|
||||||
const start = parseInt(String(req.query.start))
|
const start = parseInt(String(req.query.start))
|
||||||
const nb = parseInt(String(req.query.nb))
|
const nb = parseInt(String(req.query.nb))
|
||||||
|
|
||||||
let data;
|
let data
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case 'track':
|
case 'track':
|
||||||
@ -39,7 +39,7 @@ const handler: ApiHandler['handler'] = async (req, res) => {
|
|||||||
data = await dz.api.search(term, { limit: nb, index: start })
|
data = await dz.api.search(term, { limit: nb, index: start })
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
|
|
||||||
data.type = type
|
data.type = type
|
||||||
res.send(data)
|
res.send(data)
|
||||||
}
|
}
|
||||||
|
@ -21,7 +21,7 @@ const path: ApiHandler['path'] = '/login-arl/'
|
|||||||
|
|
||||||
const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, next) => {
|
const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, next) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
|
|
||||||
if (!req.query) {
|
if (!req.query) {
|
||||||
res.status(400).send()
|
res.status(400).send()
|
||||||
@ -44,7 +44,7 @@ const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, n
|
|||||||
let response
|
let response
|
||||||
|
|
||||||
if (process.env.NODE_ENV !== 'test') {
|
if (process.env.NODE_ENV !== 'test') {
|
||||||
if (!dz.logged_in){
|
if (!dz.logged_in) {
|
||||||
response = await dz.login_via_arl(...loginParams)
|
response = await dz.login_via_arl(...loginParams)
|
||||||
response = response ? 1 : 0
|
response = response ? 1 : 0
|
||||||
} else {
|
} else {
|
||||||
@ -55,7 +55,7 @@ const handler: RequestHandler<{}, {}, {}, RawLoginArlQuery> = async (req, res, n
|
|||||||
response = await testDz.login_via_arl(...loginParams)
|
response = await testDz.login_via_arl(...loginParams)
|
||||||
}
|
}
|
||||||
console.log(response)
|
console.log(response)
|
||||||
let returnValue = {status: response, arl: req.query.arl, user: dz.current_user}
|
const returnValue = { status: response, arl: req.query.arl, user: dz.current_user }
|
||||||
|
|
||||||
res.status(200).send(returnValue)
|
res.status(200).send(returnValue)
|
||||||
next()
|
next()
|
||||||
|
@ -16,14 +16,14 @@ router.get('/', (_, res) => {
|
|||||||
|
|
||||||
router.get('/connect', (req, res) => {
|
router.get('/connect', (req, res) => {
|
||||||
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
if (!sessionDZ[req.session.id]) sessionDZ[req.session.id] = new Deezer()
|
||||||
let dz = sessionDZ[req.session.id]
|
const dz = sessionDZ[req.session.id]
|
||||||
|
|
||||||
res.send({
|
res.send({
|
||||||
update: {
|
update: {
|
||||||
currentCommit: "testing",
|
currentCommit: 'testing',
|
||||||
latestCommit: "testing",
|
latestCommit: 'testing',
|
||||||
updateAvailable: false,
|
updateAvailable: false,
|
||||||
deemixVersion: "3.0_beta"
|
deemixVersion: '3.0_beta'
|
||||||
},
|
},
|
||||||
autologin: !dz.logged_in,
|
autologin: !dz.logged_in,
|
||||||
currentUser: dz.current_user,
|
currentUser: dz.current_user,
|
||||||
|
2
webui
2
webui
@ -1 +1 @@
|
|||||||
Subproject commit 6baf7d989bafdf1100422d03308ddedf49af1c2c
|
Subproject commit 9710a5f19f6614fefc760e1771cb67b410ee55de
|
Loading…
Reference in New Issue
Block a user