Initial boiler plate project

This commit is contained in:
2024-09-24 03:52:46 +00:00
parent 6120b2d6c3
commit 154b93e267
10034 changed files with 2079352 additions and 2 deletions

View File

@ -0,0 +1 @@
export * from './module'

View File

@ -0,0 +1,14 @@
"use strict";
if (process.env.NEXT_RUNTIME === "edge") {
module.exports = require("next/dist/server/future/route-modules/pages-api/module.js");
} else {
if (process.env.NODE_ENV === "development") {
module.exports = require("next/dist/compiled/next-server/pages-api.runtime.dev.js");
} else if (process.env.TURBOPACK) {
module.exports = require("next/dist/compiled/next-server/pages-api-turbo.runtime.prod.js");
} else {
module.exports = require("next/dist/compiled/next-server/pages-api.runtime.prod.js");
}
}
//# sourceMappingURL=module.compiled.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/route-modules/pages-api/module.compiled.js"],"names":["process","env","NEXT_RUNTIME","module","exports","require","NODE_ENV","TURBOPACK"],"mappings":";AAAA,IAAIA,QAAQC,GAAG,CAACC,YAAY,KAAK,QAAQ;IACvCC,OAAOC,OAAO,GAAGC,QAAQ;AAC3B,OAAO;IACL,IAAIL,QAAQC,GAAG,CAACK,QAAQ,KAAK,eAAe;QAC1CH,OAAOC,OAAO,GAAGC,QAAQ;IAC3B,OAAO,IAAIL,QAAQC,GAAG,CAACM,SAAS,EAAE;QAChCJ,OAAOC,OAAO,GAAGC,QAAQ;IAC3B,OAAO;QACLF,OAAOC,OAAO,GAAGC,QAAQ;IAC3B;AACF"}

View File

@ -0,0 +1,98 @@
/// <reference types="node" />
/// <reference types="node" />
import type { IncomingMessage, ServerResponse } from 'http';
import type { PagesAPIRouteDefinition } from '../../route-definitions/pages-api-route-definition';
import type { PageConfig } from '../../../../../types';
import type { ParsedUrlQuery } from 'querystring';
import { type __ApiPreviewProps } from '../../../api-utils';
import type { RouteModuleOptions } from '../route-module';
import { RouteModule, type RouteModuleHandleContext } from '../route-module';
type PagesAPIHandleFn = (req: IncomingMessage, res: ServerResponse) => Promise<void>;
/**
* The PagesAPIModule is the type of the module exported by the bundled Pages
* API module.
*/
export type PagesAPIModule = typeof import('../../../../build/templates/pages-api');
type PagesAPIUserlandModule = {
/**
* The exported handler method.
*/
readonly default: PagesAPIHandleFn;
/**
* The exported page config.
*/
readonly config?: PageConfig;
};
type PagesAPIRouteHandlerContext = RouteModuleHandleContext & {
/**
* The incoming server request in non-edge runtime.
*/
req?: IncomingMessage;
/**
* The outgoing server response in non-edge runtime.
*/
res?: ServerResponse;
/**
* The revalidate method used by the `revalidate` API.
*
* @param config the configuration for the revalidation
*/
revalidate: (config: {
urlPath: string;
revalidateHeaders: {
[key: string]: string | string[];
};
opts: {
unstable_onlyGenerated?: boolean;
};
}) => Promise<void>;
/**
* The hostname for the request.
*/
hostname?: string;
/**
* Keys allowed in the revalidate call.
*/
allowedRevalidateHeaderKeys?: string[];
/**
* Whether to trust the host header.
*/
trustHostHeader?: boolean;
/**
* The query for the request.
*/
query: ParsedUrlQuery;
/**
* The preview props used by the `preview` API.
*/
previewProps: __ApiPreviewProps;
/**
* True if the server is in development mode.
*/
dev: boolean;
/**
* True if the server is in minimal mode.
*/
minimalMode: boolean;
/**
* The page that's being rendered.
*/
page: string;
/**
* whether multi-zone flag is enabled for draft mode
*/
multiZoneDraftMode?: boolean;
};
export type PagesAPIRouteModuleOptions = RouteModuleOptions<PagesAPIRouteDefinition, PagesAPIUserlandModule>;
export declare class PagesAPIRouteModule extends RouteModule<PagesAPIRouteDefinition, PagesAPIUserlandModule> {
private apiResolverWrapped;
constructor(options: PagesAPIRouteModuleOptions);
/**
*
* @param req the incoming server request
* @param res the outgoing server response
* @param context the context for the render
*/
render(req: IncomingMessage, res: ServerResponse, context: PagesAPIRouteHandlerContext): Promise<void>;
}
export default PagesAPIRouteModule;

View File

@ -0,0 +1,53 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
0 && (module.exports = {
PagesAPIRouteModule: null,
default: null
});
function _export(target, all) {
for(var name in all)Object.defineProperty(target, name, {
enumerable: true,
get: all[name]
});
}
_export(exports, {
PagesAPIRouteModule: function() {
return PagesAPIRouteModule;
},
default: function() {
return _default;
}
});
const _apiutils = require("../../../api-utils");
const _routemodule = require("../route-module");
const _apiresolver = require("../../../api-utils/node/api-resolver");
class PagesAPIRouteModule extends _routemodule.RouteModule {
constructor(options){
super(options);
if (typeof options.userland.default !== "function") {
throw new Error(`Page ${options.definition.page} does not export a default function.`);
}
this.apiResolverWrapped = (0, _apiutils.wrapApiHandler)(options.definition.page, _apiresolver.apiResolver);
}
/**
*
* @param req the incoming server request
* @param res the outgoing server response
* @param context the context for the render
*/ async render(req, res, context) {
const { apiResolverWrapped } = this;
await apiResolverWrapped(req, res, context.query, this.userland, {
...context.previewProps,
revalidate: context.revalidate,
trustHostHeader: context.trustHostHeader,
allowedRevalidateHeaderKeys: context.allowedRevalidateHeaderKeys,
hostname: context.hostname,
multiZoneDraftMode: context.multiZoneDraftMode
}, context.minimalMode, context.dev, context.page);
}
}
const _default = PagesAPIRouteModule;
//# sourceMappingURL=module.js.map

View File

@ -0,0 +1 @@
{"version":3,"sources":["../../../../../src/server/future/route-modules/pages-api/module.ts"],"names":["PagesAPIRouteModule","RouteModule","constructor","options","userland","default","Error","definition","page","apiResolverWrapped","wrapApiHandler","apiResolver","render","req","res","context","query","previewProps","revalidate","trustHostHeader","allowedRevalidateHeaderKeys","hostname","multiZoneDraftMode","minimalMode","dev"],"mappings":";;;;;;;;;;;;;;;IA2GaA,mBAAmB;eAAnBA;;IAqDb,OAAkC;eAAlC;;;0BA5JuD;6BAGI;6BAC/B;AAmGrB,MAAMA,4BAA4BC,wBAAW;IAMlDC,YAAYC,OAAmC,CAAE;QAC/C,KAAK,CAACA;QAEN,IAAI,OAAOA,QAAQC,QAAQ,CAACC,OAAO,KAAK,YAAY;YAClD,MAAM,IAAIC,MACR,CAAC,KAAK,EAAEH,QAAQI,UAAU,CAACC,IAAI,CAAC,oCAAoC,CAAC;QAEzE;QAEA,IAAI,CAACC,kBAAkB,GAAGC,IAAAA,wBAAc,EACtCP,QAAQI,UAAU,CAACC,IAAI,EACvBG,wBAAW;IAEf;IAEA;;;;;GAKC,GACD,MAAaC,OACXC,GAAoB,EACpBC,GAAmB,EACnBC,OAAoC,EACrB;QACf,MAAM,EAAEN,kBAAkB,EAAE,GAAG,IAAI;QACnC,MAAMA,mBACJI,KACAC,KACAC,QAAQC,KAAK,EACb,IAAI,CAACZ,QAAQ,EACb;YACE,GAAGW,QAAQE,YAAY;YACvBC,YAAYH,QAAQG,UAAU;YAC9BC,iBAAiBJ,QAAQI,eAAe;YACxCC,6BAA6BL,QAAQK,2BAA2B;YAChEC,UAAUN,QAAQM,QAAQ;YAC1BC,oBAAoBP,QAAQO,kBAAkB;QAChD,GACAP,QAAQQ,WAAW,EACnBR,QAAQS,GAAG,EACXT,QAAQP,IAAI;IAEhB;AACF;MAEA,WAAeR"}