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