See @pomdtr/lastlogin for more informations about the middleware
import { lastlogin }
from "https://esm.town/v/pomdtr/lastloginHono";
import { verifyUserEmail }
from "https://esm.town/v/pomdtr/verifyUserEmail"
import {
Hono }
from "npm:hono";
const app =
new Hono();
const lastloginMiddleware =
lastlogin({
verifyEmail: verifyUserEmail
});
app.
use(
"/auth/*", lastloginMiddleware);
app.
get(
"/",
async (c) => {
return c.
html(
<div>
There is a secret message for you if you{" "}<a href="/secret">login</a>
</div>,
);
});
app.
get(
"/secret", lastloginMiddleware,
async (c) => {
const email = c.
req.
header(
"X-User-Email");
return c.
html(
<div>
I think {email} is a really silly email address, actually.
</div>,
);
});
export default app.
fetch;