Readme

See @pomdtr/lastlogin for more informations about the middleware

Example

/** @jsxImportSource npm:hono@3/jsx */ import { lastlogin } from "https://esm.town/v/pomdtr/lastloginHono"; import { Hono } from "npm:hono"; const app = new Hono(); const lastloginMiddleware = lastlogin({ allowSignup: true, }); // required for the auth pages to work app.use("/auth/*", lastloginMiddleware); // this page is public app.get("/", async (c) => { return c.html( <div> There is a secret message for you if you{" "}<a href="/secret">login</a> </div>, ); }); // this page requires the user to signup 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;
1
2
3
4
5
6
7
8
import { lastlogin as lastlogin2, type LastLoginOptions } from "https://esm.town/v/pomdtr/lastlogin";
import type { MiddlewareHandler } from "npm:hono";
export function lastlogin(options?: LastLoginOptions): MiddlewareHandler {
return async (c, next) => {
return lastlogin2(next, options)(c.req.raw);
};
}
Val Town is a social website to write and deploy JavaScript.
Build APIs and schedule functions from your browser.
Comments
Nobody has commented on this val yet: be the first!
v9
June 6, 2024