refactor: make PRECHECKs an array again
This commit is contained in:
parent
5ee654f280
commit
62eba8612b
4 changed files with 30 additions and 21 deletions
|
@ -1,17 +1,19 @@
|
|||
type PRECHECK = (req: Request, meta: Record<string, any>) => Promise<Response | undefined> | Response | undefined;
|
||||
export const PRECHECKS: Record<string, PRECHECK> = {};
|
||||
export const PRECHECKS: Record<string, PRECHECK[]> = {};
|
||||
|
||||
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'
|
||||
}
|
||||
});
|
||||
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,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue