style: fix Biome dead-code warnings from oRPC migration (CI lint gate)
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
import { RPCHandler } from "@orpc/server/node";
|
|
||||||
import { onError } from "@orpc/server";
|
import { onError } from "@orpc/server";
|
||||||
|
import { RPCHandler } from "@orpc/server/node";
|
||||||
import express, {
|
import express, {
|
||||||
type Express,
|
type Express,
|
||||||
type NextFunction,
|
type NextFunction,
|
||||||
@@ -9,8 +9,8 @@ import express, {
|
|||||||
import helmet from "helmet";
|
import helmet from "helmet";
|
||||||
import { createChildLogger } from "@/shared/logger/index";
|
import { createChildLogger } from "@/shared/logger/index";
|
||||||
import { createHealthRouter } from "../modules/health/index.js";
|
import { createHealthRouter } from "../modules/health/index.js";
|
||||||
import { errorHandler } from "../shared/middlewares/index.js";
|
|
||||||
import { appRouter } from "../orpc/router";
|
import { appRouter } from "../orpc/router";
|
||||||
|
import { errorHandler } from "../shared/middlewares/index.js";
|
||||||
|
|
||||||
// Auth removed — dashboard is public.
|
// Auth removed — dashboard is public.
|
||||||
// All data APIs (dashboard, messages, moderation, media, voice, recordings,
|
// All data APIs (dashboard, messages, moderation, media, voice, recordings,
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { createServer, type Server } from "node:http";
|
import { createServer, type Server } from "node:http";
|
||||||
import { createChildLogger } from "@/shared/logger/index";
|
import { createChildLogger } from "@/shared/logger/index";
|
||||||
|
import { createORPCWebSocketServer } from "../orpc/ws.js";
|
||||||
import { config } from "../shared/config/index.js";
|
import { config } from "../shared/config/index.js";
|
||||||
import { initializeDatabase } from "../shared/database/index.js";
|
import { initializeDatabase } from "../shared/database/index.js";
|
||||||
import { createORPCWebSocketServer } from "../orpc/ws.js";
|
|
||||||
import { startRedisBridge } from "../ws/redis-bridge.js";
|
import { startRedisBridge } from "../ws/redis-bridge.js";
|
||||||
import { createWebSocketServer } from "../ws/server.js";
|
import { createWebSocketServer } from "../ws/server.js";
|
||||||
import { createHttpApp } from "./app.js";
|
import { createHttpApp } from "./app.js";
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { and, desc, eq, type SQL, sql } from "drizzle-orm";
|
import { desc, eq } from "drizzle-orm";
|
||||||
import { getDatabase } from "../../shared/database/index.js";
|
import { getDatabase } from "../../shared/database/index.js";
|
||||||
import { pgChatbotMessagesTable, pgMessagesTable } from "../../shared/index.js";
|
import { pgChatbotMessagesTable } from "../../shared/index.js";
|
||||||
import { createChildLogger } from "../../shared/logger/index.js";
|
import { createChildLogger } from "../../shared/logger/index.js";
|
||||||
|
|
||||||
const logger = createChildLogger("chatbot.repository");
|
const logger = createChildLogger("chatbot.repository");
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import {
|
|||||||
pgUserReputationsTable,
|
pgUserReputationsTable,
|
||||||
pgVoiceRecordingsTable,
|
pgVoiceRecordingsTable,
|
||||||
} from "../../shared/index.js";
|
} from "../../shared/index.js";
|
||||||
import { tools } from "./chatbot.toolDefs.js";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executor for the chatbot's server-watcher tools. The tool *definitions*
|
* Executor for the chatbot's server-watcher tools. The tool *definitions*
|
||||||
@@ -430,7 +429,7 @@ async function moderationTimeline(
|
|||||||
return JSON.stringify(rows);
|
return JSON.stringify(rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function corrections(guildId?: string, limit = 10): Promise<string> {
|
async function corrections(_guildId?: string, limit = 10): Promise<string> {
|
||||||
const db = getDatabase();
|
const db = getDatabase();
|
||||||
const rows = await db
|
const rows = await db
|
||||||
.select({
|
.select({
|
||||||
|
|||||||
@@ -5,8 +5,17 @@ import { chatRequestSchema } from "../modules/chatbot/chatbot.schema";
|
|||||||
import { chatbotService } from "../modules/chatbot/chatbot.service";
|
import { chatbotService } from "../modules/chatbot/chatbot.service";
|
||||||
// ── Service imports ──────────────────────────────────────────────
|
// ── Service imports ──────────────────────────────────────────────
|
||||||
import { dashboardService } from "../modules/dashboard/dashboard.service";
|
import { dashboardService } from "../modules/dashboard/dashboard.service";
|
||||||
import { mediaLoopSchema, mediaQueueSchema } from "../modules/media/media.schema";
|
import {
|
||||||
import { getStatus, queue, setLoop, skip, stop } from "../modules/media/media.service";
|
mediaLoopSchema,
|
||||||
|
mediaQueueSchema,
|
||||||
|
} from "../modules/media/media.schema";
|
||||||
|
import {
|
||||||
|
getStatus,
|
||||||
|
queue,
|
||||||
|
setLoop,
|
||||||
|
skip,
|
||||||
|
stop,
|
||||||
|
} from "../modules/media/media.service";
|
||||||
import { messageQuerySchema } from "../modules/messages/messages.schema";
|
import { messageQuerySchema } from "../modules/messages/messages.schema";
|
||||||
import { messagesService } from "../modules/messages/messages.service";
|
import { messagesService } from "../modules/messages/messages.service";
|
||||||
import { moderationService } from "../modules/moderation/moderation.service";
|
import { moderationService } from "../modules/moderation/moderation.service";
|
||||||
@@ -27,7 +36,9 @@ import { publishCommandNoReply } from "../shared/redis/index";
|
|||||||
const dashboardRouter = {
|
const dashboardRouter = {
|
||||||
stats: os.handler(() => dashboardService.getStats()),
|
stats: os.handler(() => dashboardService.getStats()),
|
||||||
activity: os
|
activity: os
|
||||||
.input(z.object({ days: z.coerce.number().int().min(1).max(90).default(14) }))
|
.input(
|
||||||
|
z.object({ days: z.coerce.number().int().min(1).max(90).default(14) }),
|
||||||
|
)
|
||||||
.handler(({ input }) => dashboardService.getActivity(input.days)),
|
.handler(({ input }) => dashboardService.getActivity(input.days)),
|
||||||
users: os
|
users: os
|
||||||
.input(
|
.input(
|
||||||
@@ -152,12 +163,10 @@ const moderationRouter = {
|
|||||||
// ── Media ────────────────────────────────────────────────────────
|
// ── Media ────────────────────────────────────────────────────────
|
||||||
const mediaRouter = {
|
const mediaRouter = {
|
||||||
status: os.handler(() => getStatus()),
|
status: os.handler(() => getStatus()),
|
||||||
queue: os
|
queue: os.input(mediaQueueSchema).handler(async ({ input }) => {
|
||||||
.input(mediaQueueSchema)
|
await queue(input.source, input.mode);
|
||||||
.handler(async ({ input }) => {
|
return getStatus();
|
||||||
await queue(input.source, input.mode);
|
}),
|
||||||
return getStatus();
|
|
||||||
}),
|
|
||||||
skip: os.handler(async () => {
|
skip: os.handler(async () => {
|
||||||
await skip();
|
await skip();
|
||||||
return getStatus();
|
return getStatus();
|
||||||
@@ -166,12 +175,10 @@ const mediaRouter = {
|
|||||||
await stop();
|
await stop();
|
||||||
return getStatus();
|
return getStatus();
|
||||||
}),
|
}),
|
||||||
loop: os
|
loop: os.input(mediaLoopSchema).handler(async ({ input }) => {
|
||||||
.input(mediaLoopSchema)
|
await setLoop(input.loop);
|
||||||
.handler(async ({ input }) => {
|
return getStatus();
|
||||||
await setLoop(input.loop);
|
}),
|
||||||
return getStatus();
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ── Voice ─────────────────────────────────────────────────────────
|
// ── Voice ─────────────────────────────────────────────────────────
|
||||||
@@ -220,12 +227,10 @@ const recordingsRouter = {
|
|||||||
cursor: input.cursor,
|
cursor: input.cursor,
|
||||||
}),
|
}),
|
||||||
),
|
),
|
||||||
delete: os
|
delete: os.input(z.object({ id: z.string() })).handler(async ({ input }) => {
|
||||||
.input(z.object({ id: z.string() }))
|
await recordingsService.deleteById(input.id);
|
||||||
.handler(async ({ input }) => {
|
return { ok: true };
|
||||||
await recordingsService.deleteById(input.id);
|
}),
|
||||||
return { ok: true };
|
|
||||||
}),
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// ── Analysis (search) ──────────────────────────────────────────────
|
// ── Analysis (search) ──────────────────────────────────────────────
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
import type { IncomingMessage, Server } from "node:http";
|
import type { IncomingMessage, Server } from "node:http";
|
||||||
import type { Duplex } from "node:stream";
|
import type { Duplex } from "node:stream";
|
||||||
import { RPCHandler } from "@orpc/server/ws";
|
|
||||||
import { onError } from "@orpc/server";
|
import { onError } from "@orpc/server";
|
||||||
|
import { RPCHandler } from "@orpc/server/ws";
|
||||||
import { WebSocketServer } from "ws";
|
import { WebSocketServer } from "ws";
|
||||||
import { createChildLogger } from "@/shared/logger/index";
|
import { createChildLogger } from "@/shared/logger/index";
|
||||||
import { appRouter } from "./router";
|
import { appRouter } from "./router";
|
||||||
@@ -24,7 +24,9 @@ const logger = createChildLogger("orpc.ws");
|
|||||||
*/
|
*/
|
||||||
export function createORPCWebSocketServer(server: Server): WebSocketServer {
|
export function createORPCWebSocketServer(server: Server): WebSocketServer {
|
||||||
const handler = new RPCHandler(appRouter, {
|
const handler = new RPCHandler(appRouter, {
|
||||||
interceptors: [onError((error) => logger.error({ error }, "oRPC WS error"))],
|
interceptors: [
|
||||||
|
onError((error) => logger.error({ error }, "oRPC WS error")),
|
||||||
|
],
|
||||||
});
|
});
|
||||||
|
|
||||||
const wss = new WebSocketServer({ noServer: true, perMessageDeflate: false });
|
const wss = new WebSocketServer({ noServer: true, perMessageDeflate: false });
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ describe("chatbot tool definitions", () => {
|
|||||||
] as const) {
|
] as const) {
|
||||||
const tool = byName.get(name);
|
const tool = byName.get(name);
|
||||||
expect(tool, `missing tool ${name}`).toBeDefined();
|
expect(tool, `missing tool ${name}`).toBeDefined();
|
||||||
expect(tool!.function.parameters.required).toContain(required);
|
expect(tool?.function.parameters.required).toContain(required);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user