Skip to content

Repository files navigation

@coderic/api-core

Shared Hono utilities for Cloudflare Pages Functions and Node.

No OIDC userinfo URLs or tenant config embedded. Callers pass endpoints explicitly.

Install

npm install @coderic/api-core @coderic/acl hono

GitHub Packages:

@coderic:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${GITHUB_TOKEN}

Repo: https://github.com/Coderic/coderic-api-core

Exports

ImportSymbols
@coderic/api-corePortalError, error helpers
@coderic/api-core/honoregisterOnError, cacheControlMiddleware, createRequireAuth, getAuthUser, createHealthRoute, createAccountRoute

Usage

import{Hono}from"hono";import{registerOnError,cacheControlMiddleware,createHealthRoute,createAccountRoute,}from"@coderic/api-core/hono";constapp=newHono();registerOnError(app);app.use("*",cacheControlMiddleware);app.route("/health",createHealthRoute());app.route("/account",createAccountRoute("https://auth.example.com/userinfo"));

Auth middleware

import{createRequireAuth,getAuthUser}from"@coderic/api-core/hono";constrequireAuth=createRequireAuth({resolveUser: async(c)=>{/* AuthPrincipal | null */},});app.get("/me",requireAuth,(c)=>c.json(getAuthUser(c)));

Or use @coderic/acl/honocreateRequireAuth when you only need ACL integration.

Coderic portals

  • Root package.json: @coderic/api-core + @coderic/acl for functions/api/**.
  • Portal-specificOIDC_USERINFO_URL (e.g. https://auth.coderic.org/userinfo) stays in each portal's functions/api/auth/resolve-user.ts — not in this package.
  • Do not expect OIDC_USERINFO_URL export from @coderic/api-core.

License

MIT

About

@coderic/api-core library (MIT)

Resources

Code of conduct

Contributing

Security policy

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages