source: server/telefunc-handler.ts@ 8ee4553

main
Last change on this file since 8ee4553 was 8ee4553, checked in by Bati <no-reply@…>, 7 months ago

scaffold Vike app with Bati

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