mirror of
https://github.com/fallenbagel/jellyseerr.git
synced 2026-01-01 04:08:45 -05:00
feat(jellyfinapi): switch to API tokens instead of auth tokens (#868)
* feat(jellyfinapi): create Jellyfin API key from admin user * fix(jellyfinapi): add migration script for Jellyfin API key * feat(jellyfinapi): use Jellyfin API key instead of admin auth token * fix(jellyfinapi): fix api key migration * feat(jellyfinapi): add API key field to Jellyfin settings * fix: move the API key field in the Jellyfin settings
This commit is contained in:
@@ -1,10 +1,13 @@
|
||||
import type { AllSettings } from '@server/lib/settings';
|
||||
import logger from '@server/logger';
|
||||
import fs from 'fs';
|
||||
import path from 'path';
|
||||
|
||||
const migrationsDir = path.join(__dirname, 'migrations');
|
||||
|
||||
export const runMigrations = (settings: AllSettings): AllSettings => {
|
||||
export const runMigrations = async (
|
||||
settings: AllSettings
|
||||
): Promise<AllSettings> => {
|
||||
const migrations = fs
|
||||
.readdirSync(migrationsDir)
|
||||
.filter((file) => file.endsWith('.js') || file.endsWith('.ts'))
|
||||
@@ -13,8 +16,15 @@ export const runMigrations = (settings: AllSettings): AllSettings => {
|
||||
|
||||
let migrated = settings;
|
||||
|
||||
for (const migration of migrations) {
|
||||
migrated = migration(migrated);
|
||||
try {
|
||||
for (const migration of migrations) {
|
||||
migrated = await migration(migrated);
|
||||
}
|
||||
} catch (e) {
|
||||
logger.error(
|
||||
`Something went wrong while running settings migrations: ${e.message}`,
|
||||
{ label: 'Settings Migrator' }
|
||||
);
|
||||
}
|
||||
|
||||
return migrated;
|
||||
|
||||
Reference in New Issue
Block a user