23 lines
630 B
TypeScript
23 lines
630 B
TypeScript
|
export const PRECHECKS: Record<string, (req: Request, meta: Record<string, any>) => Promise<Response | undefined> | Response | undefined> =
|
||
|
{};
|
||
|
|
||
|
PRECHECKS.GET = (request: Request, _meta: Record<string, any>): Response | undefined => {
|
||
|
const secret = request.headers.get('x-secret');
|
||
|
if (secret !== 'very secret') {
|
||
|
return new Response('Permission Denied', {
|
||
|
status: 400,
|
||
|
headers: {
|
||
|
'Content-Type': 'text/plain'
|
||
|
}
|
||
|
});
|
||
|
}
|
||
|
};
|
||
|
export function GET(_req: Request, _meta: Record<string, any>): Response {
|
||
|
return new Response('this is secret', {
|
||
|
status: 200,
|
||
|
headers: {
|
||
|
'Content-Type': 'text/plain'
|
||
|
}
|
||
|
});
|
||
|
}
|