mirror of
https://github.com/sct/overseerr.git
synced 2025-09-17 17:24:35 +02:00
feat(api): public settings route (#57)
adds public settings route that provides initalized value to check if the app has been configured for the first time
This commit is contained in:
@@ -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<AllSettings, AllSettings>(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;
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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',
|
||||
|
@@ -1,4 +1,4 @@
|
||||
import React, { useState } from 'react';
|
||||
import React from 'react';
|
||||
import Transition from '../../Transition';
|
||||
|
||||
interface SidebarProps {
|
||||
|
Reference in New Issue
Block a user