Boltzmann: A JS HTTP Framework

Route handlers

2 minute read

Route handlers are functions with a route field. The route field is a find-my-way route with a little sugar. The handler is a function that takes a context object and returns a plain old Javascript object or throws an error.

Context

1 minute read

When Boltzmann receives an HTTP request, it wraps the incoming [Http Request] in a [Context] object. This object is open for extension by your application: feel free to add properties to it in your handlers and middleware.

Responses

1 minute read

Of course, one of the most important functions of an HTTP framework is providing affordances for responding to incoming requests.

Body parsing

1 minute read

all about body parsing

Validators

1 minute read

Boltzmann provides three validator decorators that rely on the ajv schema validator for you to enforce a schema for your route parameters, query params, and body.

Middleware

7 minute read

Middleware allows you to intercept, modify, or add behavior to your application's request handling. You attach middleware to Boltzmann either to your application, or to individual handlers. This allows you to modify request handling for all, or a subset of, your handlers.

Testing

1 minute read

Boltzmann uses tap for testing. It provides some convenience wrappers to make testing your route handlers easier. It provides shot as a way to inject requests into your service. If you're using postgres, it wraps each test in a transaction so you can exercise your db code without changing state in your underlying database. We feel that databases are not behavior we want to replicate in mocks. It's more useful to test use of the db directly.