mirror of
https://github.com/different-ai/openwork
synced 2026-04-25 17:15:34 +02:00
* feat(den-api): migrate den controller to hono * fix(den-api): align worker listing with current build setup * fix(den-api): avoid duplicate org role seeding --------- Co-authored-by: src-opn <src-opn@users.noreply.github.com>
1.4 KiB
1.4 KiB
Middleware
This folder contains reusable Hono middleware that route areas can compose as needed.
Files
index.ts: public export surface for all shared middlewareadmin.ts: requires an authenticated allowlisted admincurrent-user.ts: requires an authenticated useruser-organizations.ts: loads the orgs the current user belongs toorganization-context.ts: loads org + current member context for:orgSlugroutesmember-teams.ts: loads the teams the current org member belongs tovalidation.ts: shared Hono Zod validator wrappers for JSON, query, and params
Available context
c.get("user"): current authenticated userc.get("session"): current Better Auth sessionc.get("userOrganizations"): orgs for the current userc.get("activeOrganizationId")c.get("activeOrganizationSlug")c.get("organizationContext"): org record, current member, members, invites, rolesc.get("memberTeams"): teams for the current org member
Usage pattern
Import from src/middleware/index.ts:
import {
jsonValidator,
paramValidator,
requireUserMiddleware,
resolveOrganizationContextMiddleware,
} from "../../middleware/index.js"
Then compose only what a route needs.
Rule of thumb
- If a value is broadly useful across multiple route areas, put it here
- If a helper only exists for one route area, keep it in that route folder instead