feat: init

This commit is contained in:
2026-02-13 22:02:30 +01:00
commit 8f9ff830fb
16711 changed files with 3307340 additions and 0 deletions

View File

@@ -0,0 +1 @@
Object.assign(process.env, Deno.env.toObject());

View File

@@ -0,0 +1,2 @@
import "#nitro-internal-pollyfills";
export declare const handler: (event: any, context: any, callback?: any) => any;

View File

@@ -0,0 +1,41 @@
import "#nitro-internal-pollyfills";
import { lambda } from "./netlify-lambda.mjs";
export const handler = wrapHandler(lambda);
const BUILDER_FUNCTIONS_FLAG = true;
const HTTP_STATUS_METHOD_NOT_ALLOWED = 405;
const METADATA_VERSION = 1;
const augmentResponse = (response) => {
if (!response) {
return response;
}
const metadata = {
version: METADATA_VERSION,
builder_function: BUILDER_FUNCTIONS_FLAG,
ttl: response.ttl || 0
};
return {
...response,
metadata
};
};
function wrapHandler(handler2) {
return (event, context, callback) => {
if (event.httpMethod !== "GET" && event.httpMethod !== "HEAD") {
return Promise.resolve({
body: "Method Not Allowed",
statusCode: HTTP_STATUS_METHOD_NOT_ALLOWED
});
}
const modifiedEvent = {
...event,
multiValueQueryStringParameters: {},
queryStringParameters: {}
};
const wrappedCallback = (error, response) => callback ? callback(error, augmentResponse(response)) : null;
const execution = handler2(modifiedEvent, context, wrappedCallback);
if (typeof execution === "object" && typeof execution.then === "function") {
return execution.then(augmentResponse);
}
return execution;
};
}

View File

@@ -0,0 +1,3 @@
import "#nitro-internal-pollyfills";
import "./_deno-env-polyfill";
export default function netlifyEdge(request: Request, _context: any): Promise<any>;

View File

@@ -0,0 +1,26 @@
import "#nitro-internal-pollyfills";
import "./_deno-env-polyfill";
import { useNitroApp } from "nitropack/runtime";
import { isPublicAssetURL } from "#nitro-internal-virtual/public-assets";
const nitroApp = useNitroApp();
export default async function netlifyEdge(request, _context) {
const url = new URL(request.url);
if (isPublicAssetURL(url.pathname)) {
return;
}
if (!request.headers.has("x-forwarded-proto") && url.protocol === "https:") {
request.headers.set("x-forwarded-proto", "https");
}
let body;
if (request.body) {
body = await request.arrayBuffer();
}
return nitroApp.localFetch(url.pathname + url.search, {
host: url.hostname,
protocol: url.protocol,
headers: request.headers,
method: request.method,
redirect: request.redirect,
body
});
}

View File

@@ -0,0 +1,3 @@
import "#nitro-internal-pollyfills";
import type { HandlerContext, HandlerEvent, HandlerResponse } from "@netlify/functions";
export declare function lambda(event: HandlerEvent, context: HandlerContext): Promise<HandlerResponse>;

View File

@@ -0,0 +1,38 @@
import "#nitro-internal-pollyfills";
import { useNitroApp } from "nitropack/runtime";
import {
normalizeCookieHeader,
normalizeLambdaIncomingHeaders,
normalizeLambdaOutgoingBody,
normalizeLambdaOutgoingHeaders
} from "nitropack/runtime/internal";
import { withQuery } from "ufo";
const nitroApp = useNitroApp();
export async function lambda(event, context) {
const query = {
...event.queryStringParameters,
...event.multiValueQueryStringParameters
};
const url = withQuery(event.path, query);
const method = event.httpMethod || "get";
const r = await nitroApp.localCall({
event,
url,
context,
headers: normalizeLambdaIncomingHeaders(event.headers),
method,
query,
body: event.isBase64Encoded ? Buffer.from(event.body || "", "base64") : event.body
});
const cookies = normalizeCookieHeader(String(r.headers["set-cookie"]));
const awsBody = await normalizeLambdaOutgoingBody(r.body, r.headers);
return {
statusCode: r.status,
headers: normalizeLambdaOutgoingHeaders(r.headers, true),
body: awsBody.body,
isBase64Encoded: awsBody.type === "binary",
...cookies.length > 0 && {
multiValueHeaders: { "set-cookie": cookies }
}
};
}

View File

@@ -0,0 +1,3 @@
import "#nitro-internal-pollyfills";
import type { Handler } from "@netlify/functions";
export declare const handler: Handler;

View File

@@ -0,0 +1,21 @@
import "#nitro-internal-pollyfills";
import { getRouteRulesForPath } from "nitropack/runtime/internal";
import { withQuery } from "ufo";
import { lambda } from "./netlify-lambda.mjs";
export const handler = async function handler2(event, context) {
const query = {
...event.queryStringParameters,
...event.multiValueQueryStringParameters
};
const url = withQuery(event.path, query);
const routeRules = getRouteRulesForPath(url);
if (routeRules.isr) {
const builder = await import("@netlify/functions").then(
(r) => r.builder || r.default.builder
);
const ttl = typeof routeRules.isr === "number" ? routeRules.isr : false;
const builderHandler = ttl ? ((event2, context2) => lambda(event2, context2).then((r) => ({ ...r, ttl }))) : lambda;
return builder(builderHandler)(event, context);
}
return lambda(event, context);
};