Routes
Layeron supports these route methods:
app.get(path, handler)app.get(path, options, handler)app.post(path, handler)app.post(path, options, handler)app.put(path, handler)app.put(path, options, handler)app.patch(path, handler)app.patch(path, options, handler)app.delete(path, handler)app.delete(path, options, handler)app.head(path, handler)app.head(path, options, handler)app.routeOptions(path, handler)app.routeOptions(path, options, handler)
Example:
app.get("/api/health", () => { return { ok: true }})
app.post("/signup", { use: [signupCaptcha] }, async () => { return { accepted: true }})Route options
Section titled “Route options”| Field | Type | Description |
|---|---|---|
auth | RouteAuthPolicy | Route access policy. |
use | BackendRouteGuard[] | Route guards, such as Captcha modules. |
inputSchemaId | string | Input schema reference. |
outputSchemaId | string | Output schema reference. |
observability | object | Route-level observability policy. |
metadata | object | Extra route metadata. |
Public routes are handled by the Gateway runtime.