Install and wire a module

Requirements#

Node 22 or newer. The package is an ES module.

Install#

Pin a release tag in package.json:

"@exo/kit": "github:eXocriador/exo-kit#v0.29.0"

The built dist/ folder is committed, so installing compiles nothing. Releases are also published under the @exo scope on the exo package registry. Access to the repository or the registry is granted by the project owner.

Then install the peers for the modules you use, for example:

npm install zod pino

Wire a module#

Create one small file per concern, call the factory with explicit configuration, and re-export what it returns.

// src/env.ts
import { defineEnv, str, num } from '@exo/kit/env';

export const env = defineEnv(
  {
    SESSION_SECRET: str({ min: 32, secret: true, describe: 'Long random string.' }),
    PORT: num({ default: 3000 }),
  },
  process.env,
);
// src/log.ts
import { createLogger } from '@exo/kit/log';

export const { logger, logDebug, logInfo, logWarn, logError, logAudit } = createLogger({ service: 'my-api' });
// src/health.ts
import { createHealth } from '@exo/kit/health';

export const health = createHealth({
  version: process.env.APP_VERSION ?? 'dev',
  checks: {},
});

process.env appears once, as the argument to defineEnv. The kit never touches it.

Destructure the factories#

Factories return functions that are already bound to their instance. Destructure them in the wiring file, as createLogger does above, so the rest of the code calls plain functions.

Not configured is a state#

Modules that need an external service, such as the database, Redis, the mailer and the AI client, treat missing configuration as a normal state. They return working objects that answer "unavailable" without errors or network calls. A product can run without a database and decide for itself what that means.

Modules are described in the following pages. Upgrade by changing the tag; the changelog is organised per module, so you can see whether a release touches anything you import.