u
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import * as db from '../../db/companysetting.js';
|
||||
|
||||
// #region Helpers
|
||||
|
||||
const ALLOWED_KEYS = [
|
||||
'ui.theme',
|
||||
'keys.tavily',
|
||||
@@ -52,6 +54,8 @@ function shapeSetting(s) {
|
||||
return { key: s.key, value: s.value ?? null };
|
||||
}
|
||||
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* Registers company-settings routes for the authenticated user's selected company.
|
||||
* @param {import('express').Application} app
|
||||
@@ -109,6 +113,8 @@ export function register(app, basePath = '') {
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
// #region GET /company/setting
|
||||
|
||||
app.get(`${basePath}/company/setting`, async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -140,6 +146,8 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /company/setting/{key}:
|
||||
@@ -193,6 +201,8 @@ export function register(app, basePath = '') {
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
// #region GET /company/setting/:key
|
||||
|
||||
app.get(`${basePath}/company/setting/:key`, async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -225,6 +235,8 @@ export function register(app, basePath = '') {
|
||||
}
|
||||
});
|
||||
|
||||
// #endregion
|
||||
|
||||
/**
|
||||
* @openapi
|
||||
* /company/setting/{key}:
|
||||
@@ -296,6 +308,8 @@ export function register(app, basePath = '') {
|
||||
* schema:
|
||||
* $ref: '#/components/schemas/Error'
|
||||
*/
|
||||
// #region PUT /company/setting/:key
|
||||
|
||||
app.put(`${basePath}/company/setting/:key`, async (req, res) => {
|
||||
const selected = requireSelectedCompany(req);
|
||||
if (selected.error) {
|
||||
@@ -347,4 +361,6 @@ export function register(app, basePath = '') {
|
||||
res.status(status).json({ error: error.message });
|
||||
}
|
||||
});
|
||||
|
||||
// #endregion
|
||||
}
|
||||
Reference in New Issue
Block a user