mirror of
https://github.com/seemueller-io/cluster.git
synced 2025-09-08 22:56:46 +00:00
36 lines
1.1 KiB
TypeScript
36 lines
1.1 KiB
TypeScript
import {parse} from "cookie";
|
|
|
|
export default {
|
|
async fetch(request): Promise<Response> {
|
|
// The name of the cookie
|
|
const COOKIE_NAME = "session";
|
|
const cookie = parse(request.headers.get("Cookie") || "");
|
|
if (cookie[COOKIE_NAME] != null) {
|
|
// Respond with the cookie value
|
|
return new Response(`
|
|
<html>
|
|
<body>
|
|
<h1>Cookie Status</h1>
|
|
<p>Cookie '${COOKIE_NAME}' exists with value: ${cookie[COOKIE_NAME]}</p>
|
|
</body>
|
|
</html>
|
|
`, {
|
|
headers: {
|
|
"Content-Type": "text/html"
|
|
}
|
|
});
|
|
}
|
|
return new Response(`
|
|
<html>
|
|
<body>
|
|
<h1>Cookie Status</h1>
|
|
<p>No cookie found <w></w>ith name: ${COOKIE_NAME}</p>
|
|
</body>
|
|
</html>
|
|
`, {
|
|
headers: {
|
|
"Content-Type": "text/html"
|
|
}
|
|
});
|
|
},
|
|
} satisfies ExportedHandler; |