Files
webstudio/apps/builder/app/services/trpc.server.ts
T
Bogdan Chadkin e1fa2075a5 Enforce server constraints for packages (#1507)
Ref
https://remix.run/docs/en/1.15.0/guides/constraints#server-code-pruning

Remix use NAME.server.ts extension to enforce omitting module from
client bundles. Though we heavily used `/server` in packages which had
no affect and blocked us in using a few node apis which were not
polifilled with empty modules while bundling for client.

Here I replaced `/server` with `/index.server` and removed all legacy
server entry points which are not longer necessary with new typescript
resolution.
2023-04-22 09:14:14 +07:00

17 lines
528 B
TypeScript

import { createTrpcProxyServiceClient } from "@webstudio-is/trpc-interface/index.server";
import env from "~/env/env.server";
const TRPC_SERVER_URL = env.TRPC_SERVER_URL ?? "";
const TRPC_SERVER_API_TOKEN = env.TRPC_SERVER_API_TOKEN ?? "";
const BRANCH_NAME = env.BRANCH_NAME;
export const trpcClient = createTrpcProxyServiceClient(
TRPC_SERVER_URL !== "" && TRPC_SERVER_API_TOKEN !== ""
? {
url: TRPC_SERVER_URL,
token: TRPC_SERVER_API_TOKEN,
branchName: BRANCH_NAME,
}
: undefined
);