fix(build): make oRPC/tRPC dist runnable under node ESM (deploy crashloop)
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.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { trpc } from "@/lib/trpc/client";
|
||||
import { orpc } from "@/lib/orpc/client";
|
||||
import type {
|
||||
DashboardActivity,
|
||||
DashboardChannelDetail,
|
||||
@@ -11,45 +11,40 @@ import type {
|
||||
} from "@/lib/types";
|
||||
|
||||
export const dashboardApi = {
|
||||
getStats: () =>
|
||||
trpc.dashboard.stats.query() as unknown as Promise<DashboardStats>,
|
||||
getStats: () => orpc.dashboard.stats() as unknown as Promise<DashboardStats>,
|
||||
|
||||
getActivity: (days = 14) =>
|
||||
trpc.dashboard.activity.query({
|
||||
days,
|
||||
}) as unknown as Promise<DashboardActivity>,
|
||||
orpc.dashboard.activity({ days }) as unknown as Promise<DashboardActivity>,
|
||||
|
||||
listUsers: (limit?: number, cursor?: string, search?: string) =>
|
||||
trpc.dashboard.users.query({
|
||||
orpc.dashboard.users({
|
||||
limit,
|
||||
cursor,
|
||||
search,
|
||||
}) as unknown as Promise<PaginatedUsers>,
|
||||
|
||||
getUserDetail: (userId: string) =>
|
||||
trpc.dashboard.userDetail.query({
|
||||
orpc.dashboard.userDetail({
|
||||
userId,
|
||||
}) as unknown as Promise<DashboardUserDetail>,
|
||||
|
||||
listChannels: (limit?: number, search?: string, guildId?: string) =>
|
||||
trpc.dashboard.channels.query({
|
||||
orpc.dashboard.channels({
|
||||
limit,
|
||||
search,
|
||||
guildId,
|
||||
}) as unknown as Promise<PaginatedChannels>,
|
||||
|
||||
getChannelDetail: (channelId: string) =>
|
||||
trpc.dashboard.channelDetail.query({
|
||||
orpc.dashboard.channelDetail({
|
||||
channelId,
|
||||
}) as unknown as Promise<DashboardChannelDetail>,
|
||||
|
||||
getTopReactions: (limit = 20) =>
|
||||
trpc.dashboard.reactions.query({ limit }) as unknown as Promise<
|
||||
orpc.dashboard.reactions({ limit }) as unknown as Promise<
|
||||
TopReactedMessage[]
|
||||
>,
|
||||
|
||||
getTopReactors: (limit = 20) =>
|
||||
trpc.dashboard.reactors.query({ limit }) as unknown as Promise<
|
||||
TopReactor[]
|
||||
>,
|
||||
orpc.dashboard.reactors({ limit }) as unknown as Promise<TopReactor[]>,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user