main
|
Last change
on this file since ee1fa4e was c30935a, checked in by Tome <gjorgievtome@…>, 7 months ago |
|
fix config
|
-
Property mode
set to
100644
|
|
File size:
1.0 KB
|
| Line | |
|---|
| 1 | import type { Database } from "../database/drizzle/db";
|
|---|
| 2 | import { enhance, type UniversalHandler } from "@universal-middleware/core";
|
|---|
| 3 | import { telefunc } from "telefunc";
|
|---|
| 4 | import type { Session } from "@auth/core/types";
|
|---|
| 5 |
|
|---|
| 6 | const 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 | );
|
|---|
| 34 | export default telefuncHandler
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.