- discord-gateway: 74 lint errors -> 0 (format, import sorting, unused imports/vars, dead breath var) - backend: format + sort imports (11 warnings left: noExplicitAny) - frontend: remove unused imports, drop dead breathing var, fix useExhaustiveDependencies (scroll keyed on messages), a11y biome-ignore for drag surface + stopPropagation container (mouse-only gestures) - remaining warnings are false positives: index keys on static lists, <img> in static export (next/image unsupported), noExplicitAny tsc --noEmit clean on all 3 services; vitest green (60+36).
81 lines
2.5 KiB
TypeScript
81 lines
2.5 KiB
TypeScript
import type { Request, Response, Router } from "express";
|
|
import express from "express";
|
|
import { createChildLogger } from "@/shared/logger/index";
|
|
import { asyncHandler, validateBody } from "../../shared/middlewares/index.js";
|
|
import {
|
|
handleConnectVoice,
|
|
handleDisconnectVoice,
|
|
handleGetVoiceStatus,
|
|
handleVoiceCommand,
|
|
} from "./voice.controller.js";
|
|
import { connectVoiceSchema, voiceCommandSchema } from "./voice.schema.js";
|
|
import {
|
|
getGuilds,
|
|
getTextChannels,
|
|
getVoiceChannels,
|
|
} from "./voice.service.js";
|
|
|
|
const logger = createChildLogger("voice.routes");
|
|
|
|
export function createVoiceRouter(): Router {
|
|
const router = express.Router();
|
|
|
|
// ── Guilds ──────────────────────────────────────────────────────────────
|
|
|
|
// GET /api/guilds
|
|
router.get(
|
|
"/guilds",
|
|
asyncHandler(async (_req: Request, res: Response) => {
|
|
logger.debug("Fetching guilds");
|
|
const guilds = await getGuilds();
|
|
res.json(guilds);
|
|
}),
|
|
);
|
|
|
|
// GET /api/guilds/:guildId/channels
|
|
router.get(
|
|
"/guilds/:guildId/channels",
|
|
asyncHandler(async (req: Request, res: Response) => {
|
|
const guildId = req.params.guildId as string;
|
|
logger.debug({ guildId }, "Fetching text channels");
|
|
const channels = await getTextChannels(guildId);
|
|
res.json(channels);
|
|
}),
|
|
);
|
|
|
|
// GET /api/guilds/:guildId/voice-channels
|
|
router.get(
|
|
"/guilds/:guildId/voice-channels",
|
|
asyncHandler(async (req: Request, res: Response) => {
|
|
const guildId = req.params.guildId as string;
|
|
logger.debug({ guildId }, "Fetching voice channels");
|
|
const channels = await getVoiceChannels(guildId);
|
|
res.json(channels);
|
|
}),
|
|
);
|
|
|
|
// ── Voice connection ────────────────────────────────────────────────────
|
|
|
|
// GET /api/voice/status
|
|
router.get("/voice/status", handleGetVoiceStatus);
|
|
|
|
// POST /api/voice/connect
|
|
router.post(
|
|
"/voice/connect",
|
|
validateBody(connectVoiceSchema),
|
|
handleConnectVoice,
|
|
);
|
|
|
|
// POST /api/voice/disconnect
|
|
router.post("/voice/disconnect", handleDisconnectVoice);
|
|
|
|
// POST /api/voice/command — send arbitrary voice command (transmit start/stop)
|
|
router.post(
|
|
"/voice/command",
|
|
validateBody(voiceCommandSchema),
|
|
handleVoiceCommand,
|
|
);
|
|
|
|
return router;
|
|
}
|