@vperms/hono
v0.0.6
Published
Hono integration for VeguiPerms.
Maintainers
Readme
VeguiPerms Hono
@vperms/hono adds typed request context, permission guards and optional
resolved-permission exports to Hono applications.
Hono guide · API reference · GitHub
Install
npm install @vperms/hono vperms honoProtect a route
import { Hono } from "hono";
import { hasPermission, vpermsMiddleware, type VPermsVariables } from "@vperms/hono";
import { createVPerms, VeguiPermsMemoryAdapter } from "vperms";
const app = new Hono<{ Variables: VPermsVariables }>();
const adapter = new VeguiPermsMemoryAdapter();
const perms = createVPerms({ adapter });
app.use(vpermsMiddleware({
adapter,
workspace: perms.workspaceId,
resolver: () => null, // anonymous; replace with your authenticated subject ID
}));
app.get("/posts", hasPermission("posts.read"), (c) => c.json({ message: "Allowed" }));Grant permissions through perms.setPermission(subject, permission, value).
The facade and middleware use the same adapter and default root workspace. Without a
matching grant, the route is denied. Read hydrated state with c.get("ability"),
c.get("subject") and c.get("kind").
hasPermission() requires every permission; hasAnyPermission() requires one.
See the guide to wire authentication and enable permission exports.
Build and coverage badges describe the whole VeguiPerms repository. License: MIT.
