chore: clean dependencies and format restructure
This commit is contained in:
+26
-27
@@ -2,7 +2,11 @@ import fs from "node:fs";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import type { Client } from "discord.js-selfbot-v13";
|
||||
import express, { type NextFunction, type Request, type Response } from "express";
|
||||
import express, {
|
||||
type NextFunction,
|
||||
type Request,
|
||||
type Response,
|
||||
} from "express";
|
||||
import helmet from "helmet";
|
||||
import { AppError } from "../errors";
|
||||
import type { createChildLogger } from "../logger";
|
||||
@@ -83,11 +87,13 @@ export function createHttpApp(options: CreateHttpAppOptions) {
|
||||
});
|
||||
|
||||
// Health and auth routes
|
||||
app.use(createHealthRoutes({
|
||||
adminPassword: options.adminPassword,
|
||||
activeUserCount: options.activeUserCount,
|
||||
wsClientCount: options.wsClientCount,
|
||||
}));
|
||||
app.use(
|
||||
createHealthRoutes({
|
||||
adminPassword: options.adminPassword,
|
||||
activeUserCount: options.activeUserCount,
|
||||
wsClientCount: options.wsClientCount,
|
||||
}),
|
||||
);
|
||||
|
||||
// Route modules
|
||||
app.use(
|
||||
@@ -117,28 +123,21 @@ export function createHttpApp(options: CreateHttpAppOptions) {
|
||||
}),
|
||||
);
|
||||
|
||||
app.use(
|
||||
(
|
||||
error: Error,
|
||||
_req: Request,
|
||||
res: Response,
|
||||
_next: NextFunction,
|
||||
) => {
|
||||
if (error instanceof AppError) {
|
||||
res.status(error.statusCode).json({
|
||||
error: error.code,
|
||||
message: error.message,
|
||||
});
|
||||
return;
|
||||
}
|
||||
|
||||
options.logger.error({ error }, "Unhandled webserver error");
|
||||
res.status(500).json({
|
||||
error: "INTERNAL_SERVER_ERROR",
|
||||
message: "Internal server error",
|
||||
app.use((error: Error, _req: Request, res: Response, _next: NextFunction) => {
|
||||
if (error instanceof AppError) {
|
||||
res.status(error.statusCode).json({
|
||||
error: error.code,
|
||||
message: error.message,
|
||||
});
|
||||
},
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
options.logger.error({ error }, "Unhandled webserver error");
|
||||
res.status(500).json({
|
||||
error: "INTERNAL_SERVER_ERROR",
|
||||
message: "Internal server error",
|
||||
});
|
||||
});
|
||||
|
||||
return app;
|
||||
}
|
||||
|
||||
+2
-1
@@ -33,7 +33,8 @@ export async function startWebserver(
|
||||
client: Client,
|
||||
voiceController: VoiceController,
|
||||
) {
|
||||
const { getSharedUIState, patchSharedUIState } = await createSharedUIStateStore();
|
||||
const { getSharedUIState, patchSharedUIState } =
|
||||
await createSharedUIStateStore();
|
||||
let mediaSettings = await initializeMediaSettings();
|
||||
|
||||
const wsPath = "/ws";
|
||||
|
||||
@@ -9,7 +9,10 @@ export const defaultMediaSettings: MediaSettings = {
|
||||
};
|
||||
|
||||
export async function initializeMediaSettings(): Promise<MediaSettings> {
|
||||
const stored = await getPersistedValue("media-settings", defaultMediaSettings);
|
||||
const stored = await getPersistedValue(
|
||||
"media-settings",
|
||||
defaultMediaSettings,
|
||||
);
|
||||
return {
|
||||
...defaultMediaSettings,
|
||||
...(stored as MediaSettings),
|
||||
|
||||
@@ -1,5 +1,8 @@
|
||||
import type { createChildLogger } from "../logger";
|
||||
import type { BroadcasterClient, ModerationBroadcaster } from "../moderation/types";
|
||||
import type {
|
||||
BroadcasterClient,
|
||||
ModerationBroadcaster,
|
||||
} from "../moderation/types";
|
||||
|
||||
type Logger = ReturnType<typeof createChildLogger>;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user