fix: try to address loading typescript from a compiled binary to no avail: https://github.com/denoland/deno/issues/18327#issuecomment-2989449015
This commit is contained in:
parent
62761723d4
commit
b0548f05cc
3 changed files with 11 additions and 5 deletions
|
@ -69,10 +69,15 @@ export default async function handle_typescript(request: Request): Promise<Respo
|
||||||
'/';
|
'/';
|
||||||
|
|
||||||
const import_path = new URL('file://' + entry.path, import.meta.url).toString();
|
const import_path = new URL('file://' + entry.path, import.meta.url).toString();
|
||||||
|
|
||||||
|
try {
|
||||||
const module: ROUTE_HANDLER = await import(import_path) as ROUTE_HANDLER;
|
const module: ROUTE_HANDLER = await import(import_path) as ROUTE_HANDLER;
|
||||||
|
|
||||||
const pattern = new URLPattern({ pathname: route_path });
|
const pattern = new URLPattern({ pathname: route_path });
|
||||||
routes.set(pattern, module);
|
routes.set(pattern, module);
|
||||||
|
} catch (error) {
|
||||||
|
console.error(`Error mounting module ${import_path} at ${route_path}\n\n${error}\n`);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,7 @@ export class SERVER {
|
||||||
port: this.options.port ?? DEFAULT_SERVER_OPTIONS.port,
|
port: this.options.port ?? DEFAULT_SERVER_OPTIONS.port,
|
||||||
hostname: this.options.hostname ?? DEFAULT_SERVER_OPTIONS.hostname,
|
hostname: this.options.hostname ?? DEFAULT_SERVER_OPTIONS.hostname,
|
||||||
onError: (error: unknown) => {
|
onError: (error: unknown) => {
|
||||||
|
console.error(error);
|
||||||
return Response.json({ error: { message: (error as Error).message } }, { status: 500 });
|
return Response.json({ error: { message: (error as Error).message } }, { status: 500 });
|
||||||
},
|
},
|
||||||
signal
|
signal
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
export const PRECHECKS: Record<string, (req: Request, meta: Record<string, any>) => Promise<Response | undefined> | Response | undefined> =
|
type PRECHECK = (req: Request, meta: Record<string, any>) => Promise<Response | undefined> | Response | undefined;
|
||||||
{};
|
export const PRECHECKS: Record<string, PRECHECK> = {};
|
||||||
|
|
||||||
PRECHECKS.GET = (request: Request, _meta: Record<string, any>): Response | undefined => {
|
PRECHECKS.GET = (request: Request, _meta: Record<string, any>): Response | undefined => {
|
||||||
const secret = request.headers.get('x-secret');
|
const secret = request.headers.get('x-secret');
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue