flesh out startup, connect to jf, handover to discordjs
This commit is contained in:
parent
a80ccb6bfd
commit
92d8f805b6
37
index.ts
37
index.ts
@ -1,26 +1,21 @@
|
||||
import { ExtendedClient } from "./server/structures/client"
|
||||
export const client = new ExtendedClient()
|
||||
|
||||
import { AuthenticateUserByNameRequest, CreateUserByNameRequest } from "./jellyfin/api"
|
||||
import { UserApi } from "./jellyfin/api/userApi"
|
||||
import { JellyfinHandler } from "./jellyfin/handler"
|
||||
import { config } from "./server/configuration"
|
||||
client.start()
|
||||
import { logger } from "./server/logger"
|
||||
const requestId = 'startup'
|
||||
|
||||
async function start() {
|
||||
const jfUserAPI: UserApi = new UserApi(config.jellyfin_url)
|
||||
const options = {
|
||||
headers: {
|
||||
"X-MediaBrowser-Token": config.jellfin_token
|
||||
const jellyfinHandler = new JellyfinHandler(config)
|
||||
|
||||
export const client = new ExtendedClient(jellyfinHandler)
|
||||
|
||||
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 })
|
||||
client.start()
|
||||
}
|
||||
let u = (await jfUserAPI.getUsers(false, false, options)).body
|
||||
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()
|
||||
|
Loading…
Reference in New Issue
Block a user