Skip to content

covenix / apiKey

Function: apiKey() ​

apiKey(location, handler): SecurityScheme

Defined in: src/security.ts:78

Builds an API key security scheme read from a header, query param, or cookie.

Parameters ​

location ​

Where the key is sent (in) and under what name.

in ​

"query" | "header" | "cookie"

name ​

string

handler ​

SecurityHandler

Resolves the request to a principal, or null for 401.

Returns ​

SecurityScheme

Example ​

ts
apiKey({ in: 'header', name: 'X-API-Key' }, (req) => lookupKey(req));