Skip to Content
Senri
API reference

@senrijs/senri

@senrijs/senri: The app, routes, Context, errors, validation and the built-in middleware

The app, routes, Context, errors, validation and the built-in middleware.

import { ... } from "@senrijs/senri";

Functions and classes

NameWhat it does
createApp(options?)Creates an app
createRouter(prefix)Creates a group of routes under a prefix
defineRoutes(table)Creates a typed route table
endpoint(options, handler)Creates a route with schemas or middleware
mergeRoutes(...tables)Merges route tables
ContextThe c that handlers and middleware receive
HttpErrorAn error with a status and a message
ValidationErrorThe error when a value does not pass a schema
logger(), showRoutes()Logging and printing the routes
health()/healthz and /readyz
cors()CORS
csrf()CSRF
secureHeaders()Security headers
basicAuth(), bearerAuth()Basic and Bearer auth
rateLimit()Rate limiting
ipRestriction()IP restriction
bodyLimit()Body size limit
uploadLimit(), safeFileName()Upload limit and safe file names
timeout()Timeout
compress()Compression
etag()ETag
cache()Cache-Control
prettyJSON()Pretty JSON
requestId()Request ID
trailingSlash()Trailing slash
methodOverride(app)Method override
languageDetector()Language detection

Types

AppOptions

Prop

Type

Main types: App, Handler, Middleware, HandlerResult, RouteTable, TypedResponse, StandardSchemaV1, InferInput and InferOutput. The option types of each middleware are on its page.

Source: src/index.ts

On this page