Menu

Inside KickJS Adapters — Lifecycle, Composition, and Custom Patterns
📰
0

Inside KickJS Adapters — Lifecycle, Composition, and Custom Patterns

DEV Community·Orinda Felix Ochieng·about 1 month ago
#hPpmRcRi
Reading 0:00
15s threshold

If you have written an Express app, you already know the shape of a middleware : a function that gets (req, res, next) and runs once per request. You probably also know what a plugin looks like — a side-effecting register(app) call that mutates a global at boot. KickJS gives you a third primitive sitting between those two, and most of the framework's interesting behaviour lives there: the adapter . An adapter is not per-request like middleware, and it is not a one-shot side-effect like a plugin. It is a typed object with a lifecycle , composed in order, orchestrated by the framework so your app can stand long-lived infrastructure up and tear it down deterministically. What an adapter is An adapter is a unit of composable infrastructure plugged into the KickJS bootstrap pipeline. You reach for one whenever a concern needs more than a single request handler can give you: It owns a long-lived resource — a database pool, a tracer SDK, a queue client, a mailer transport.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More