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.
51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { orpc } from "@/lib/orpc/client";
|
|
import type {
|
|
DashboardActivity,
|
|
DashboardChannelDetail,
|
|
DashboardStats,
|
|
DashboardUserDetail,
|
|
PaginatedChannels,
|
|
PaginatedUsers,
|
|
TopReactedMessage,
|
|
TopReactor,
|
|
} from "@/lib/types";
|
|
|
|
export const dashboardApi = {
|
|
getStats: () => orpc.dashboard.stats() as unknown as Promise<DashboardStats>,
|
|
|
|
getActivity: (days = 14) =>
|
|
orpc.dashboard.activity({ days }) as unknown as Promise<DashboardActivity>,
|
|
|
|
listUsers: (limit?: number, cursor?: string, search?: string) =>
|
|
orpc.dashboard.users({
|
|
limit,
|
|
cursor,
|
|
search,
|
|
}) as unknown as Promise<PaginatedUsers>,
|
|
|
|
getUserDetail: (userId: string) =>
|
|
orpc.dashboard.userDetail({
|
|
userId,
|
|
}) as unknown as Promise<DashboardUserDetail>,
|
|
|
|
listChannels: (limit?: number, search?: string, guildId?: string) =>
|
|
orpc.dashboard.channels({
|
|
limit,
|
|
search,
|
|
guildId,
|
|
}) as unknown as Promise<PaginatedChannels>,
|
|
|
|
getChannelDetail: (channelId: string) =>
|
|
orpc.dashboard.channelDetail({
|
|
channelId,
|
|
}) as unknown as Promise<DashboardChannelDetail>,
|
|
|
|
getTopReactions: (limit = 20) =>
|
|
orpc.dashboard.reactions({ limit }) as unknown as Promise<
|
|
TopReactedMessage[]
|
|
>,
|
|
|
|
getTopReactors: (limit = 20) =>
|
|
orpc.dashboard.reactors({ limit }) as unknown as Promise<TopReactor[]>,
|
|
};
|