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
|
bun.lockb
|
||||||
todo.txt
|
todo.txt
|
||||||
proto.js
|
proto.js
|
||||||
|
.env
|
||||||
6
index.js
6
index.js
@@ -7,9 +7,13 @@ import cookieParser from 'cookie-parser'
|
|||||||
const app = express()
|
const app = express()
|
||||||
|
|
||||||
if (!process.env.DATABASE_URL) {
|
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)
|
process.exit(1)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const db = postgres(process.env.DATABASE_URL)
|
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)
|
* @returns {object} Object containing response in JSON and HTML (as string)
|
||||||
*/
|
*/
|
||||||
async function queryJellyfin() {
|
async function queryJellyfin() {
|
||||||
|
try {
|
||||||
return await fetch(`${globalConfig.nowplaying.jellyfin.host}/Sessions`, {
|
return await fetch(`${globalConfig.nowplaying.jellyfin.host}/Sessions`, {
|
||||||
headers: {
|
headers: {
|
||||||
"Authorization": `MediaBrowser Token=${globalConfig.nowplaying.jellyfin.apiKey}`
|
"Authorization": `MediaBrowser Token=${globalConfig.nowplaying.jellyfin.apiKey}`
|
||||||
@@ -66,6 +67,9 @@ async function queryJellyfin() {
|
|||||||
|
|
||||||
return notPlayingAnythingPlaceholder
|
return notPlayingAnythingPlaceholder
|
||||||
})
|
})
|
||||||
|
} catch {
|
||||||
|
return notPlayingAnythingPlaceholder
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export { queryLastfm, queryJellyfin }
|
export { queryLastfm, queryJellyfin }
|
||||||
Reference in New Issue
Block a user