25 lines
576 B
TypeScript
25 lines
576 B
TypeScript
import express from "express";
|
|
import { expressHandler } from "trpc-playground/handlers/express";
|
|
import { AppRouter } from "./app";
|
|
import { Config } from "./config";
|
|
|
|
export const runPlayground = async (appRouter: AppRouter) => {
|
|
const app = express();
|
|
|
|
const trpcApiEndpoint = Config.api_url;
|
|
const playgroundEndpoint = "/";
|
|
|
|
app.use(
|
|
playgroundEndpoint,
|
|
await expressHandler({
|
|
trpcApiEndpoint,
|
|
playgroundEndpoint,
|
|
router: appRouter,
|
|
}),
|
|
);
|
|
|
|
app.listen(3001, () => {
|
|
console.log("listening at http://localhost:3001");
|
|
});
|
|
};
|