feat: update desktop workflows and app center
This commit is contained in:
28
electron/api/routes/local-preferences.ts
Normal file
28
electron/api/routes/local-preferences.ts
Normal file
@@ -0,0 +1,28 @@
|
||||
import type { IncomingMessage, ServerResponse } from 'http';
|
||||
import { getAllLocalPreferences, patchLocalPreferences, type AppLocalPreferences } from '../../utils/local-preferences';
|
||||
import type { HostApiContext } from '../context';
|
||||
import { parseJsonBody, sendJson } from '../route-utils';
|
||||
|
||||
export async function handleLocalPreferenceRoutes(
|
||||
req: IncomingMessage,
|
||||
res: ServerResponse,
|
||||
url: URL,
|
||||
_ctx: HostApiContext,
|
||||
): Promise<boolean> {
|
||||
if (url.pathname === '/api/local-preferences' && req.method === 'GET') {
|
||||
sendJson(res, 200, await getAllLocalPreferences());
|
||||
return true;
|
||||
}
|
||||
|
||||
if (url.pathname === '/api/local-preferences' && req.method === 'PUT') {
|
||||
try {
|
||||
const patch = await parseJsonBody<AppLocalPreferences>(req);
|
||||
sendJson(res, 200, await patchLocalPreferences(patch));
|
||||
} catch (error) {
|
||||
sendJson(res, 500, { success: false, error: String(error) });
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
Reference in New Issue
Block a user