# @x12i/core-service

> Thin HTTP service compliance kit — zone ports, /health, /_live, correlation-id, startup banner.

Latest version **1.0.1** (published 2026-09-14) · exellix-license license · 0 weekly downloads

## Install

```sh
npm install @x12i/core-service
pnpm add @x12i/core-service
yarn add @x12i/core-service
bun add @x12i/core-service
```

## Health

**Score 70/100 (B)** — status: active.

Positive: has types; esm support; no vulnerabilities; recently updated; high maintenance score; high quality score.

Warnings: low downloads.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2026-09-14 |
| First published | 2026-07-23 |
| Weekly downloads | 0 |
| License | exellix-license |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.0.0 |
| Dependencies | 2 |
| Unpacked size | 34.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | x12i |
| Keywords | x12i, core-service, health, live-view, ports |

## Links

- npm: https://www.npmjs.com/package/@x12i/core-service
- Repository: https://github.com/x12i/memorix-mono-repo
- Homepage: https://github.com/x12i/memorix-mono-repo#readme
- Issues: https://github.com/x12i/memorix-mono-repo/issues
- npm.io page: https://npm.io/package/@x12i/core-service

## Dependencies (2)

- [@x12i/api-live-view](https://npm.io/package/@x12i/api-live-view.md) ^1.1.0
- [@x12i/ports-manager](https://npm.io/package/@x12i/ports-manager.md) ^1.0.2

## Recent versions

- 1.0.1 (latest) — 2026-09-14
- 1.0.0 — 2026-07-23

## README

# `@x12i/core-service`

Thin **HTTP compliance kit** for x12i / exellix services.

Depends on:
- [`@x12i/ports-manager`](../ports-manager/) — zone ports
- [`@x12i/api-live-view`](../api-live-view/) — `/_live`

**Rule:** any process that binds an HTTP port should use this package.

## Install

```bash
npm install @x12i/core-service
```

Peer (Fastify adapter): `fastify@^5` · optional `@fastify/cors`.

## Compliance contract

1. Port from zone map (env override OK; avoid/quarantine enforced)
2. `GET /health` → `{ ok, service, … }`
3. `/_live` (+ traffic APIs)
4. `x-correlation-id` on request/response
5. Startup banner: origin · health · live

## Fastify

```ts
import Fastify from "fastify";
import { attachCoreFastify } from "@x12i/core-service/fastify";

const app = Fastify();
const core = await attachCoreFastify(app, {
  identity: {
    id: "@x12i/my-service",
    title: "My Service",
    zoneId: "memorix",
    portKey: "service",
    portEnv: "MEMORIX_SERVICE_PORT",
    docsPath: "/api/openapi.json",
  },
  getHealth: async () => ({ ok: true, service: "@x12i/my-service" }),
});

await app.listen({ port: core.port, host: "127.0.0.1" });
```

## Node http

```js
import http from "node:http";
import { createCoreNodeHttp, listenAndAnnounce } from "@x12i/core-service";

const core = createCoreNodeHttp({
  identity: {
    id: "opx-source",
    title: "Ops Source",
    zoneId: "memorix",
    portKey: "opxSource",
    portEnv: "OPX_SOURCE_PORT",
    docsPath: "/openapi.json",
  },
});

const server = http.createServer(async (req, res) => {
  if (await core.tryHandleCore(req, res)) return;
  core.withInboundTiming(req, res, "/", req.method ?? "GET", () => {
    res.writeHead(200, { "content-type": "application/json" });
    res.end(JSON.stringify({ ok: true }));
  });
});

await listenAndAnnounce({
  server,
  port: core.port,
  label: "opx-source",
  docsPath: "/openapi.json",
});
```

## Ports helper

```ts
import { resolveServicePorts } from "@x12i/core-service";

const p = resolveServicePorts({
  zoneId: "narrix",
  portKey: "api",
  portEnv: "NARRIX_PORT",
});
p.assertApiPort(); // even + in-zone + not avoided
```

## License

`exellix-license`

---
_Source: https://npm.io/package/@x12i/core-service · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
