25 lines
1.0 KiB
JavaScript
25 lines
1.0 KiB
JavaScript
import { AsyncLocalStorage } from 'node:async_hooks';
|
|
import { createRequestScope } from '../runtime';
|
|
import { createRequestHandler as createExpoHandler } from './abstract';
|
|
import { createWorkerdEnv } from './environment/workerd';
|
|
export { ExpoError } from './abstract';
|
|
const STORE = new AsyncLocalStorage();
|
|
/**
|
|
* Returns a request handler for EAS Hosting deployments.
|
|
*/
|
|
export function createRequestHandler(params, setup) {
|
|
const makeRequestAPISetup = (request, _env, ctx) => ({
|
|
origin: request.headers.get('Origin') || null,
|
|
environment: request.headers.get('eas-environment') || null,
|
|
waitUntil: ctx.waitUntil?.bind(ctx),
|
|
});
|
|
const run = createRequestScope(STORE, makeRequestAPISetup);
|
|
const common = createWorkerdEnv(params);
|
|
const onRequest = createExpoHandler({ ...common, ...setup });
|
|
function handler(request, env, ctx) {
|
|
return run(onRequest, request, env, ctx);
|
|
}
|
|
handler.preload = common.preload;
|
|
return handler;
|
|
}
|
|
//# sourceMappingURL=eas.js.map
|