2023-09-27 09:56:32 +00:00
|
|
|
import * as trpcExpress from '@trpc/server/adapters/express';
|
2023-09-28 10:01:04 +00:00
|
|
|
import { createContext, router } from './trpc';
|
2023-09-27 12:27:46 +00:00
|
|
|
import { notificationRouter } from './routers/notification';
|
2023-09-28 10:01:04 +00:00
|
|
|
import { websiteRouter } from './routers/website';
|
2023-09-29 09:12:06 +00:00
|
|
|
import { monitorRouter } from './routers/monitor';
|
2023-09-27 09:56:32 +00:00
|
|
|
|
|
|
|
const appRouter = router({
|
2023-09-28 10:01:04 +00:00
|
|
|
website: websiteRouter,
|
2023-09-27 12:27:46 +00:00
|
|
|
notification: notificationRouter,
|
2023-09-29 09:12:06 +00:00
|
|
|
monitor: monitorRouter,
|
2023-09-27 09:56:32 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
export type AppRouter = typeof appRouter;
|
|
|
|
|
|
|
|
export const trpcExpressMiddleware = trpcExpress.createExpressMiddleware({
|
|
|
|
router: appRouter,
|
|
|
|
createContext,
|
2023-09-27 12:27:46 +00:00
|
|
|
onError: ({ path, error }) => {
|
|
|
|
console.error('Error:', path, error);
|
|
|
|
},
|
2023-09-27 09:56:32 +00:00
|
|
|
});
|