flesh out startup, connect to jf, handover to discordjs

This commit is contained in:
mightypanders 2023-04-16 02:04:34 +02:00
parent a80ccb6bfd
commit 92d8f805b6

View File

@ -1,26 +1,21 @@
import { ExtendedClient } from "./server/structures/client" import { ExtendedClient } from "./server/structures/client"
export const client = new ExtendedClient() import { JellyfinHandler } from "./jellyfin/handler"
import { AuthenticateUserByNameRequest, CreateUserByNameRequest } from "./jellyfin/api"
import { UserApi } from "./jellyfin/api/userApi"
import { config } from "./server/configuration" import { config } from "./server/configuration"
client.start() import { logger } from "./server/logger"
const requestId = 'startup'
async function start() { const jellyfinHandler = new JellyfinHandler(config)
const jfUserAPI: UserApi = new UserApi(config.jellyfin_url)
const options = { export const client = new ExtendedClient(jellyfinHandler)
headers: {
"X-MediaBrowser-Token": config.jellfin_token async function init() {
try {
const users = await jellyfinHandler.getCurrentUsers("", requestId)
logger.info(`Fetched ${users.map(x => x.name).join(', ')} from JF`, { requestId })
} catch (error) {
logger.error(`Error fetching existing users from Jellyfin`, { requestId })
} }
} logger.info(`Starting client`, { requestId })
let u = (await jfUserAPI.getUsers(false, false, options)).body client.start()
console.log(JSON.stringify(u.map(x => x.name), null, 2))
const user: CreateUserByNameRequest = {
name: "Testuser1",
password: "1234"
}
const a = await jfUserAPI.createUserByName(user, options)
console.log(JSON.stringify(a, null, 2))
u = (await jfUserAPI.getUsers(undefined, undefined, options)).body
console.log(JSON.stringify(u.map(x => x.name), null, 2))
} }
init()