Documents injecute 1.x · Migrating from 0.x
Skip to content

Frameworks ​

injecute doesn't replace your framework. The framework handles requests; the container builds the services behind them, wires them, and releases them when the app stops. Every page in this section follows the same shape:

  1. One composition root. The app is built in one chain: configuration, connections, feature modules. A missing service is a compile error, not a crash on the first request.
  2. Handlers close over their services. A module's route factory receives the services it needs, and its handlers use them. Handlers never see the container.
  3. Routes come from modules. The HTTP module declares an extension point; each feature module contributes its routes to it. The HTTP module doesn't import the features.
  4. Request data through a context accessor. The framework's middleware runs each request in storage.run(); services read the trace id, tenant or user when they need it. See Request context.
  5. Listening is a lifecycle hook. startLifecycle() starts the server, and running.stop() stops accepting requests, waits for open ones, then closes the connections. See Startup and shutdown.
  6. Tests use an isolated fork. Replace the database in a fork, build the server from it and send it requests with the framework's own test helper, without listening on a port.

These pages put the framework in the container: routes are services, and the server is a lifecycle hook. For most apps, keeping the framework out of the core is the better default; see Keep the web framework out of the core.

The UI frameworks are different: the container builds the core behind the components, and the framework's context passes it down. See React, Vue and Solid.

Your services import neither the framework nor injecute, so the same modules run under an HTTP server, a queue worker, a cron job or a CLI.

PageFor
ExpressExpress 5 apps
FastifyFastify 5 apps: plugins for HTTP, the container for services
HonoHono on Node.js, Bun, Deno and Cloudflare Workers
Next.jsThe App Router: server components, route handlers and server actions
GraphQLGraphQL Yoga and Apollo Server, with a DataLoader per request
React, Vue and SolidWhen a UI app needs a container; the core behind the UI, TanStack Query, state management
Coming from NestJSMoving from NestJS's dependency injection, all at once or step by step

Released under the MIT License.