Website Structure

This commit is contained in:
supalerk-ar66 2026-01-13 10:46:40 +07:00
parent 62812f2090
commit 71f0676a62
22365 changed files with 4265753 additions and 791 deletions

View file

@ -0,0 +1,21 @@
import "#nitro-internal-pollyfills";
import type { Handler } from "aws-lambda";
type StormkitEvent = {
url: string;
path: string;
method: string;
body?: string;
query?: Record<string, Array<string>>;
headers?: Record<string, string>;
rawHeaders?: Array<string>;
};
type StormkitResponse = {
headers?: Record<string, string>;
body?: string;
buffer?: string;
statusCode: number;
errorMessage?: string;
errorStack?: string;
};
export declare const handler: Handler<StormkitEvent, StormkitResponse>;
export {};

View file

@ -0,0 +1,32 @@
import "#nitro-internal-pollyfills";
import { useNitroApp } from "nitropack/runtime";
import { normalizeLambdaOutgoingBody } from "nitropack/runtime/internal";
const nitroApp = useNitroApp();
export const handler = async function(event, context) {
const response = await nitroApp.localCall({
event,
url: event.url,
context,
headers: event.headers,
method: event.method || "GET",
query: event.query,
body: event.body
});
const awsBody = await normalizeLambdaOutgoingBody(
response.body,
response.headers
);
return {
statusCode: response.status,
headers: normalizeOutgoingHeaders(response.headers),
[awsBody.type === "text" ? "body" : "buffer"]: awsBody.body
};
};
function normalizeOutgoingHeaders(headers) {
return Object.fromEntries(
Object.entries(headers).map(([k, v]) => [
k,
Array.isArray(v) ? v.join(",") : String(v)
])
);
}