flake.nix only rewrote @/ aliases but left extensionless relative imports (./router) in compiled dist/. node dist/index.js (how prod runs) cannot resolve extensionless ESM specifiers -> ERR_MODULE_NOT_FOUND -> backend crashlooped (444 restarts, port 4001 dead). Extract the fixer into a shared scripts/fix-imports.mjs that appends .js to extensionless relative imports and rewrites @/ aliases, and wire it into backend + discord-gateway build phases. Verified: fresh tsc + fixer -> node dist/index.js boots; oRPC over /trpc serves both HTTP POST and WebSocket (config/dashboard/voice/moderation/ media/chatbot/analysis) end-to-end against Postgres + Redis. next build passes with the oRPC client + partysocket.
66 lines
1.7 KiB
TypeScript
66 lines
1.7 KiB
TypeScript
import { orpc } from "@/lib/orpc/client";
|
|
import type { AttachmentRecord, MessageRecord } from "@/lib/types";
|
|
|
|
export const messagesApi = {
|
|
list: (
|
|
guildId: string,
|
|
limit?: number,
|
|
channelId?: string,
|
|
cursor?: string,
|
|
) =>
|
|
orpc.messages.list({
|
|
guildId,
|
|
limit,
|
|
channelId,
|
|
cursor,
|
|
}) as unknown as Promise<{
|
|
data: MessageRecord[];
|
|
nextCursor: string | null;
|
|
}>,
|
|
|
|
getByChannel: (channelId: string, limit?: number, cursor?: string) =>
|
|
orpc.messages.byChannel({
|
|
channelId,
|
|
query: { channelId, limit, cursor },
|
|
}) as unknown as Promise<{
|
|
data: MessageRecord[];
|
|
nextCursor: string | null;
|
|
}>,
|
|
|
|
getDetail: (id: string) =>
|
|
orpc.messages.detail({ id }) as unknown as Promise<MessageRecord>,
|
|
|
|
getImages: (guildId: string, limit?: number) =>
|
|
orpc.messages.images({ guildId, limit }) as unknown as Promise<{
|
|
data: MessageRecord[];
|
|
nextCursor: string | null;
|
|
}>,
|
|
|
|
getAttachments: (
|
|
channelId: string,
|
|
limit?: number,
|
|
cursor?: string,
|
|
messageId?: string,
|
|
) =>
|
|
orpc.messages.attachmentsByChannel({
|
|
channelId,
|
|
query: { channelId, limit, cursor, messageId },
|
|
}) as unknown as Promise<{
|
|
data: AttachmentRecord[];
|
|
nextCursor: string | null;
|
|
}>,
|
|
|
|
getReview: (limit?: number, channelId?: string) =>
|
|
orpc.messages.review({ limit, channelId }) as unknown as Promise<{
|
|
results: MessageRecord[];
|
|
limit: number;
|
|
cursor: null;
|
|
}>,
|
|
|
|
// Analysis search (formerly /api/analysis/search → oRPC analysis.search)
|
|
search: (q: string, limit?: number) =>
|
|
orpc.analysis.search({ q, limit }) as unknown as Promise<{
|
|
results: MessageRecord[];
|
|
}>,
|
|
};
|