env file handling + fix error in libnowplaying
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -2,3 +2,4 @@ node_modules/
|
||||
bun.lockb
|
||||
todo.txt
|
||||
proto.js
|
||||
.env
|
||||
6
index.js
6
index.js
@@ -7,9 +7,13 @@ import cookieParser from 'cookie-parser'
|
||||
const app = express()
|
||||
|
||||
if (!process.env.DATABASE_URL) {
|
||||
console.log("FATAL: DATABASE_URI must be set")
|
||||
try {
|
||||
process.loadEnvFile("./.env")
|
||||
} catch {
|
||||
console.log("FATAL: DATABASE_URL was not defined or found in env file")
|
||||
process.exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
const db = postgres(process.env.DATABASE_URL)
|
||||
|
||||
|
||||
@@ -42,6 +42,7 @@ async function queryLastfm() {
|
||||
* @returns {object} Object containing response in JSON and HTML (as string)
|
||||
*/
|
||||
async function queryJellyfin() {
|
||||
try {
|
||||
return await fetch(`${globalConfig.nowplaying.jellyfin.host}/Sessions`, {
|
||||
headers: {
|
||||
"Authorization": `MediaBrowser Token=${globalConfig.nowplaying.jellyfin.apiKey}`
|
||||
@@ -66,6 +67,9 @@ async function queryJellyfin() {
|
||||
|
||||
return notPlayingAnythingPlaceholder
|
||||
})
|
||||
} catch {
|
||||
return notPlayingAnythingPlaceholder
|
||||
}
|
||||
}
|
||||
|
||||
export { queryLastfm, queryJellyfin }
|
||||
Reference in New Issue
Block a user