source: server/telefunc-handler.ts@ 6196d60

main
Last change on this file since 6196d60 was c30935a, checked in by Tome <gjorgievtome@…>, 7 months ago

fix config

  • Property mode set to 100644
File size: 1.0 KB
Line 
1import type { Database } from "../database/drizzle/db";
2import { enhance, type UniversalHandler } from "@universal-middleware/core";
3import { telefunc } from "telefunc";
4import type { Session } from "@auth/core/types";
5
6const telefuncHandler: UniversalHandler = enhance(
7 async (request, context, runtime) => {
8 const httpResponse = await telefunc({
9 url: request.url.toString(),
10 method: request.method,
11 body: await request.text(),
12 context: {
13 ...(context as { db: Database; session?: Session | null }),
14 ...runtime,
15 session: (context as { session?: Session | null }).session ?? null,
16 request,
17 }
18 });
19 const { body, statusCode, contentType } = httpResponse;
20 return new Response(body, {
21 status: statusCode,
22 headers: {
23 "content-type": contentType,
24 },
25 });
26 },
27 {
28 name: "pc-forge:telefunc-handler",
29 path: `/_telefunc`,
30 method: ["GET", "POST"],
31 immutable: false,
32 },
33);
34export default telefuncHandler
Note: See TracBrowser for help on using the repository browser.