mirror of
https://github.com/cloudflare/wrangler-action.git
synced 2024-11-25 03:14:46 +01:00
27 lines
527 B
TypeScript
27 lines
527 B
TypeScript
|
type Env = {
|
||
|
SECRET1?: string;
|
||
|
SECRET2?: string;
|
||
|
};
|
||
|
|
||
|
export default {
|
||
|
fetch(request: Request, env: Env) {
|
||
|
const url = new URL(request.url);
|
||
|
|
||
|
if (url.pathname === "/secret-health-check") {
|
||
|
const { SECRET1, SECRET2 } = env;
|
||
|
|
||
|
if (SECRET1 !== "SECRET_1_VALUE" || SECRET2 !== "SECRET_2_VALUE") {
|
||
|
throw new Error("SECRET1 or SECRET2 is not defined");
|
||
|
}
|
||
|
|
||
|
return new Response("OK");
|
||
|
}
|
||
|
|
||
|
// @ts-expect-error
|
||
|
return Response.json({
|
||
|
...request,
|
||
|
headers: Object.fromEntries(request.headers),
|
||
|
});
|
||
|
},
|
||
|
};
|