anan7
anan7
TtRPC
Created by anan7 on 5/12/2023 in #❓-help
Dockerfile in Tubrorepo
Hi I have a Turborepo where I have a nextjs frontend “web” and an express backend “api” both connected through trpc (guess that’s obv). I’m kinda finding it difficult to create a docker image for this 🫠 has anybody else done this before? Any example I could take a look at? Thanks!
8 replies
TtRPC
Created by anan7 on 2/8/2023 in #❓-help
Websocket is not defined error
I'm getting a "WebSocket is not defined error" on my next app connected to an express backend. Any idea what I'm doing wrong? My server/index file is import * as trpcExpress from "@trpc/server/adapters/express"; import { applyWSSHandler } from "@trpc/server/adapters/ws"; import express from "express"; import cors from "cors"; import { appRouter } from "./routers/_app"; import { createContext } from "./context"; import ws from 'ws' const app = express(); app.use(cors({ origin: ["http://localhost:3000", "http://localhost:3001"] })); app.use( "/trpc", trpcExpress.createExpressMiddleware({ router: appRouter, createContext, }) ); const server = app.listen(8000); applyWSSHandler({ wss: new ws.Server({ server }), router: appRouter, createContext }) My context file is import { inferAsyncReturnType } from "@trpc/server"; import * as trpcExpress from "@trpc/server/adapters/express"; import { NodeHTTPCreateContextFnOptions } from '@trpc/server/adapters/node-http'; import { IncomingMessage } from 'http'; import ws from 'ws'; export const createContext = ({ req, res }: trpcExpress.CreateExpressContextOptions | NodeHTTPCreateContextFnOptions<IncomingMessage, ws>) => { return ({ req, res }) } export type Context = inferAsyncReturnType<typeof createContext>;
3 replies