diff --git a/server/lib/settings.ts b/server/lib/settings.ts index 55b6cbd0d..31dd1dad0 100644 --- a/server/lib/settings.ts +++ b/server/lib/settings.ts @@ -42,11 +42,16 @@ interface MainSettings { apiKey: string; } +interface PublicSettings { + initialized: boolean; +} + interface AllSettings { main: MainSettings; plex: PlexSettings; radarr: RadarrSettings[]; sonarr: SonarrSettings[]; + public: PublicSettings; } const SETTINGS_PATH = path.join(__dirname, '../../config/settings.json'); @@ -68,6 +73,9 @@ class Settings { }, radarr: [], sonarr: [], + public: { + initialized: false, + }, }; if (initialSettings) { Object.assign(this.data, initialSettings); @@ -106,6 +114,14 @@ class Settings { this.data.sonarr = data; } + get public(): PublicSettings { + return this.data.public; + } + + set public(data: PublicSettings) { + this.data.public = data; + } + /** * Settings Load * @@ -126,7 +142,7 @@ class Settings { const data = fs.readFileSync(SETTINGS_PATH, 'utf-8'); if (data) { - this.data = JSON.parse(data); + this.data = Object.assign(this.data, JSON.parse(data)); } return this.data; } diff --git a/server/overseerr-api.yml b/server/overseerr-api.yml index 461fbd068..14b699b8a 100644 --- a/server/overseerr-api.yml +++ b/server/overseerr-api.yml @@ -184,6 +184,12 @@ components: - activeDirectory - is4k - enableSeasonFolders + PublicSettings: + type: object + properties: + initialized: + type: boolean + example: false AllSettings: type: object properties: @@ -199,11 +205,14 @@ components: type: array items: $ref: '#/components/schemas/SonarrSettings' + public: + $ref: '#/components/schemas/PublicSettings' required: - main - plex - radarr - sonarr + - public securitySchemes: cookieAuth: @@ -430,6 +439,19 @@ paths: application/json: schema: $ref: '#/components/schemas/SonarrSettings' + /settings/public: + get: + summary: Returns public settings + description: Returns settings that are not protected or sensitive. Mainly used to determine if the app has been configured for the first time. + tags: + - settings + responses: + '200': + description: Public Settings returned + content: + application/json: + schema: + $ref: '#/components/schemas/PublicSettings' /auth/me: get: summary: Returns the currently logged in user diff --git a/server/routes/index.ts b/server/routes/index.ts index 9669bf4a2..4d786e3eb 100644 --- a/server/routes/index.ts +++ b/server/routes/index.ts @@ -4,6 +4,7 @@ import authRoutes from './auth'; import { checkUser, isAuthenticated } from '../middleware/auth'; import settingsRoutes from './settings'; import { Permission } from '../lib/permissions'; +import { getSettings } from '../lib/settings'; const router = Router(); @@ -16,7 +17,13 @@ router.use( ); router.use('/auth', authRoutes); -router.get('/', (req, res) => { +router.get('/settings/public', (_req, res) => { + const settings = getSettings(); + + return res.status(200).json(settings.public); +}); + +router.get('/', (_req, res) => { return res.status(200).json({ api: 'Overseerr API', version: '1.0', diff --git a/src/components/Layout/Sidebar/index.tsx b/src/components/Layout/Sidebar/index.tsx index 71763076f..57259b4e1 100644 --- a/src/components/Layout/Sidebar/index.tsx +++ b/src/components/Layout/Sidebar/index.tsx @@ -1,4 +1,4 @@ -import React, { useState } from 'react'; +import React from 'react'; import Transition from '../../Transition'; interface SidebarProps {