""refactor"" basically everything

This commit is contained in:
Enstrayed
2024-09-22 14:04:15 -07:00
parent 2e527a8539
commit 5f1181476d
14 changed files with 78 additions and 90 deletions

View File

@@ -1,4 +1,4 @@
const { globalConfig } = require("../index.js")
import { globalConfig } from "../index.js"
/**
* Checks if a token exists in the sessions file (authentication) and if it has the correct permissions (authorization)
@@ -27,4 +27,4 @@ async function checkToken(token,scope) {
})
}
module.exports = {checkToken}
export {checkToken}

View File

@@ -1,4 +1,4 @@
const { globalConfig } = require("../index.js")
import { globalConfig } from "../index.js"
/**
* Queries LastFM for user set in config file and returns formatted result
@@ -30,4 +30,17 @@ async function queryLastfm() {
})
}
module.exports = { queryLastfm }
// async function queryJellyfin() {
// return await fetch(`${globalConfig.nowplaying.jellyfin.host}/Sessions`, {
// headers: {
// "Authorization": `MediaBrowser Token=${globalConfig.nowplaying.jellyfin.apiKey}`
// }
// }).then(response => response.json()).then(response => {
// for (x in response) {
// if (response[x].UserName !== globalConfig.nowplaying.jellyfin.target) { break }
// if (response[x].)
// }
// })
// }
export { queryLastfm }

View File

@@ -23,4 +23,4 @@ function logRequest(response,request,code,extra) {
console.log(`${request.get("cf-connecting-ip") ?? request.ip}${actualAuth}${request.method} ${request.path} returned ${code}${actualExtra}`)
}
module.exports = { logRequest }
export { logRequest }