Add editable system configuration flow
This commit is contained in:
@@ -1,13 +1,13 @@
|
||||
import express, { type Request, type Response } from 'express';
|
||||
import fs from 'node:fs/promises';
|
||||
import path from 'node:path';
|
||||
import type { ControlPlaneState, CreateUserInput } from '../src/shared/contracts';
|
||||
import type { ControlPlaneState, CreateUserInput, UpdateSystemInput } from '../src/shared/contracts';
|
||||
import { validateCreateUserInput, validateSystemInput } from '../src/shared/validation';
|
||||
import {
|
||||
buildRuntimePaths,
|
||||
createUserRecord,
|
||||
deriveDashboardSnapshot,
|
||||
render3proxyConfig,
|
||||
validateCreateUserInput,
|
||||
type RuntimePaths,
|
||||
} from './lib/config';
|
||||
import type { RuntimeController } from './lib/runtime';
|
||||
@@ -85,6 +85,18 @@ export function createApp({ store, runtime, runtimeRootDir }: AppServices) {
|
||||
}
|
||||
});
|
||||
|
||||
app.put('/api/system', async (request, response, next) => {
|
||||
try {
|
||||
const state = await store.read();
|
||||
state.system = validateSystemInput(request.body as Partial<UpdateSystemInput>, state.userRecords);
|
||||
state.service.lastEvent = 'System configuration updated from panel';
|
||||
await persistRuntimeMutation(store, runtime, state, runtimePaths);
|
||||
response.json(await getSnapshot(store, runtime, runtimePaths));
|
||||
} catch (error) {
|
||||
next(error);
|
||||
}
|
||||
});
|
||||
|
||||
app.post('/api/users/:id/pause', async (request, response, next) => {
|
||||
try {
|
||||
const state = await store.read();
|
||||
|
||||
Reference in New Issue
Block a user