skeld Get started

skeld in practice

Pick a case. See what skeld does.

Each scenario shows an input, what skeld does with it, the code that causes it, and what it does not guarantee. They are illustrations checked against the documentation; nothing is sent anywhere.

Requests

Will this request reach your handler?

A short string reaches the handler.

Incoming JSON
{ "name": "polar" }
  1. Request arrivesPOST /projects

    A JSON body enters the route.

  2. Validate inputstring · maxLength: 24

    “polar” is a string with 5 characters, within the 24-character limit.

  3. Route handlercreateProject(name)

    Called with the validated name.

Response body201 · The handler runs.
{ "name": "polar" }
201 Created · application/json

“polar” is a string with 5 characters, within the 24-character limit.

The code that causes it
body: t.object({
  name: t.string({ maxLength: 24 })
})

Why this happens

The body schema is checked before the normal route handler receives it. A required string must be present, have the right type and satisfy its declared bounds.

What this does not guarantee

Validation checks data, not identity or permission. Early onRequest hooks run before body validation and must treat input as untrusted.

Read every scenario · 29

Requests

Within the limit

201 · The handler runs. “polar” is a string with 5 characters, within the 24-character limit.

Validation checks data, not identity or permission. Early onRequest hooks run before body validation and must treat input as untrusted.

Documentation

Too long

400 · Rejected before the handler. The name has 31 characters. The contract permits at most 24.

Validation checks data, not identity or permission. Early onRequest hooks run before body validation and must treat input as untrusted.

Documentation

Wrong type

400 · Rejected before the handler. The name is a number. skeld rejects it instead of coercing it into a string.

Validation checks data, not identity or permission. Early onRequest hooks run before body validation and must treat input as untrusted.

Documentation

Missing required field

400 · Rejected before the handler. The required name field is missing. An optional field would need an explicit optional schema.

Validation checks data, not identity or permission. Early onRequest hooks run before body validation and must treat input as untrusted.

Documentation

Access

Route with no access rule

Startup refused · ACCESS_UNDECLARED The server uses @skeld/auth and this route declares no access, so listen rejects and names the route.

The check shows that a rule was declared, not that it is the right rule. Deciding who may read which record is yours.

Documentation

No credential

401 · CREDENTIAL_MISSING The route is protected by a policy and the request carries no credential, so the gate answers before the handler runs.

This shows that a credential is required, not that any credential is enough. The policy still decides each request.

Documentation

Signed in, not allowed

403 · ACCESS_DENIED The session is valid, and the policy's action refuses this caller. The handler does not run.

skeld enforces the rule you wrote. Whether user u_2 should be able to read this note is your rule to get right.

Documentation

Not a member of the tenant

404 · NOT_FOUND The policy's tenant rule answers false, so the reply is the same as for a project that does not exist.

skeld applies the tenant rule you wrote. Which users belong to which tenant is yours to get right.

Documentation

Responses

Extra field returned

200 · The extra field is omitted. The handler returned two fields. The response contract declares only name, so internalId is absent from the serialized body.

This applies to declared normal responses. Early raw hook replies and errors you write have different disclosure rules.

Documentation

Response has the wrong type

500 · The invalid body is not sent. The handler already ran, but its result violates the response contract. skeld sends the fixed internal error instead of that body.

A serialization failure cannot undo side effects the handler already performed.

Documentation

Explicit secret exposure

200 · The secret value is sent. t.exposed(schema, reason) records an explicit disclosure decision. This response is allowed to contain the synthetic token.

Exposure does not authorize the recipient. The application must decide who may receive this value.

Documentation

Logging

Secret in a classified log

The log contains a marker, not the token. Passing the body through request.classified('body') carries its schema classification into the log projection.

This does not scan arbitrary messages for secrets. Raw strings and exposed values need separate care.

Documentation

Personal data in a classified log

The email is masked in this log field. The classified body carries the personal label to the logger, which writes [personal] in place of the email.

Personal classification does not automatically hide a value in an HTTP response or a directly logged scalar.

Documentation

Personal data logged directly

The email appears in the log. The logger does not infer that an arbitrary string is personal data. The direct scalar field keeps its value.

Secret wrappers have their own masking behavior. This example concerns an ordinary personal string, not a Secret object.

Documentation

Database

A value that looks like SQL

The query text is unchanged. Query text comes only from the literal parts of the sql tag. The value reaches the database as a parameter and is compared, not executed.

Two calls take SQL as a string: script(text) and query(text) through toPgPool. A request value joined into those is still injection.

Documentation

A row with an extra column

The undeclared column is dropped. The query names a row schema. Each row keeps only the declared columns, and each kept value is checked.

The check applies where a query names a row schema.

Documentation

The pool is full

503 · Service unavailable The pool has no free connection and its queue of waiters is full, so the call fails at once with POOL_FULL.

The pool bounds waiting, not the work. A slow statement still holds its connection until it ends or its request is aborted.

Documentation

Startup

Secret response without exposure

Startup refused · SECRET_IN_RESPONSE skeld refuses the declaration when listen inspects the routes. No request is needed to discover this problem.

Wrapping the field in t.exposed permits disclosure; it does not establish that disclosure is appropriate for a caller.

Documentation

String without a bound

Startup refused · UNBOUNDED_FIELD The route cannot start with this string declaration. Supply maxLength or an explicit unbounded reason.

A field bound is one control. Body limits, aggregate traffic and downstream resource use still need their own limits.

Documentation

Errors

Unexpected exception

500 · A fixed error reaches the caller. The default response does not repeat the arbitrary exception message.

Logs and diagnostics are separate outputs. A custom error handler or deliberate HttpError can change what the caller receives.

Documentation

Intentional HTTP error

409 · The intended message is sent. An HttpError deliberately supplies a status, code and caller-facing message. Write that message for the recipient.

Do not put private values in this message. Response-schema classification does not automatically redact the text of an HttpError you write.

Documentation

Request lifetime

Async work exceeds its deadline

503 · The request times out. The request signal aborts and the late result is discarded. Work that ignores cancellation can still continue.

It cannot preempt synchronous JavaScript or undo side effects. Timer delivery can be late if the event loop is blocked.

Documentation

The caller disconnects

Disconnected · No guaranteed response. The request signal lets your work react to the lost caller. In this example, the work checks that signal and stops.

Disconnecting does not roll back a write or forcibly terminate arbitrary application code.

Documentation

Browser policies

Origin outside the CORS list

The handler runs; no CORS read grant is sent. An unlisted origin receives no Access-Control-Allow-Origin header. That controls browser reading, not application authorization.

CORS does not authenticate callers. POST, PUT, PATCH and DELETE also face the separate cross-site mutation policy.

Documentation

Untrusted cross-site mutation

403 · The mutation is refused. A foreign origin with cross-site evidence does not pass the configured mutation policy.

Non-browser callers can forge these headers. Passing this policy is not authentication, and GET/HEAD do not undergo this check.

Documentation

Typed client

Server reply breaks the contract

Client rejects · INVALID_RESPONSE A success status alone does not establish that the response matches the declared body schema.

An undeclared response status has an unknown body. Contract validation does not establish the remote service’s identity or business correctness.

Documentation

Remote response is too large

Client rejects · RESPONSE_TOO_LARGE The configured response byte limit is exceeded. The client stops reading and rejects the call.

A byte limit does not replace a request deadline or validate the business meaning of the response.

Documentation

API document

A secret field in a response

Generation refused · INVALID_SCHEMA The response would send a field declared secret, and nothing marks it as exposed. The call throws and its location names the route.

The document describes the contract, not the running service, and it publishes the data class of each field.

Documentation

A rule OpenAPI cannot express

Document returned, with a diagnostic. The bound is written as x-skeld-maxLengthUtf16 and never as maxLength, and a UTF16_LENGTH diagnostic gives its location.

A tool that ignores the extensions validates less than core does. It never validates more.

Documentation