cal.pub0.org/pages/api/trpc/[trpc].ts

37 lines
783 B
TypeScript
Raw Normal View History

/**
* This file contains tRPC's HTTP response handler
*/
import * as trpcNext from "@trpc/server/adapters/next";
import { createContext } from "@server/createContext";
import { appRouter } from "@server/routers/_app";
export default trpcNext.createNextApiHandler({
router: appRouter,
/**
* @link https://trpc.io/docs/context
*/
createContext,
/**
* @link https://trpc.io/docs/error-handling
*/
onError({ error }) {
if (error.code === "INTERNAL_SERVER_ERROR") {
// send to bug reporting
console.error("Something went wrong", error);
}
},
/**
* Enable query batching
*/
batching: {
enabled: true,
},
/**
* @link https://trpc.io/docs/caching#api-response-caching
*/
// responseMeta() {
// // ...
// },
});