894c9e6ab9
optimizations, format releases widget@0.1.38; standalone@2.2.0
911 B
911 B
Elysia checkpoint
Installation
bun add elysia @cap.js/middleware-elysia
[!NOTE] The template just needs to have a widget or hidden solver pointing at the
/__cap_clearanceURL. The sample template is here.
Usage
import { Elysia, file } from "elysia";
import { capMiddleware } from "@cap.js/middleware-elysia";
new Elysia()
.use(
capMiddleware({
token_validity_hours: 32, // how long the token is valid for
tokens_store_path: ".data/tokensList.json",
token_size: 16, // token size in bytes
verification_template_path: join(dirname(fileURLToPath(import.meta.url)), "./index.html"),
scoping: "scoped", // 'global' | 'scoped'
}),
)
.get("/", () => "Hello Elysia!")
.listen(3000);
That's it! You can now use the middleware to protect your routes.