@ontrails/http 1.0.0-beta.12 → 1.0.0-beta.14

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,19 +1,19 @@
1
1
  /**
2
- * Hono adapter for Trails HTTP routes.
2
+ * Hono connector for Trails HTTP routes.
3
3
  *
4
4
  * Takes framework-agnostic HttpRouteDefinition[] and wires them into a
5
5
  * Hono application, handling request parsing, response mapping, and errors.
6
6
  *
7
7
  * ```ts
8
8
  * const app = topo("myapp", entity);
9
- * await blaze(app, { port: 3000 });
9
+ * await trailhead(app, { port: 3000 });
10
10
  * ```
11
11
  */
12
12
 
13
- import { isTrailsError, statusCodeMap, validateTopo } from '@ontrails/core';
13
+ import { isTrailsError, statusCodeMap } from '@ontrails/core';
14
14
  import type {
15
- Layer,
16
- ServiceOverrideMap,
15
+ Gate,
16
+ ProvisionOverrideMap,
17
17
  Topo,
18
18
  TrailContextInit,
19
19
  } from '@ontrails/core';
@@ -29,9 +29,9 @@ import { buildHttpRoutes } from '../build.js';
29
29
  // Options
30
30
  // ---------------------------------------------------------------------------
31
31
 
32
- export interface BlazeHttpOptions {
32
+ export interface TrailheadHttpOptions {
33
33
  readonly basePath?: string | undefined;
34
- /** Config values for services that declare a `config` schema, keyed by service ID. */
34
+ /** Config values for provisions that declare a `config` schema, keyed by provision ID. */
35
35
  readonly configValues?:
36
36
  | Readonly<Record<string, Record<string, unknown>>>
37
37
  | undefined;
@@ -39,10 +39,10 @@ export interface BlazeHttpOptions {
39
39
  | (() => TrailContextInit | Promise<TrailContextInit>)
40
40
  | undefined;
41
41
  readonly hostname?: string | undefined;
42
- readonly layers?: readonly Layer[] | undefined;
42
+ readonly gates?: readonly Gate[] | undefined;
43
43
  readonly name?: string | undefined;
44
44
  readonly port?: number | undefined;
45
- readonly services?: ServiceOverrideMap | undefined;
45
+ readonly provisions?: ProvisionOverrideMap | undefined;
46
46
  /** Set false to return the Hono app without starting a server. */
47
47
  readonly serve?: boolean | undefined;
48
48
  /** Set to `false` to skip topo validation at startup. Defaults to `true`. */
@@ -233,10 +233,10 @@ const createHonoHandler =
233
233
  }
234
234
 
235
235
  const requestId = c.req.header('X-Request-ID') ?? undefined;
236
- const { signal } = c.req.raw;
236
+ const { signal: abortSignal } = c.req.raw;
237
237
 
238
238
  try {
239
- const result = await route.execute(rawInput, requestId, signal);
239
+ const result = await route.execute(rawInput, requestId, abortSignal);
240
240
  return mapResultToResponse(result, c);
241
241
  } catch (error: unknown) {
242
242
  return handleCaughtError(error, c);
@@ -294,34 +294,21 @@ const registerErrorHandler = (hono: Hono): void => {
294
294
  // Validation
295
295
  // ---------------------------------------------------------------------------
296
296
 
297
- /**
298
- * Throw a ValidationError if the topo has structural issues.
299
- * Pass `skip: true` to bypass validation (e.g. when `validate: false` is set).
300
- */
301
- const assertValidTopo = (app: Topo, skip = false): void => {
302
- if (skip) {
303
- return;
304
- }
305
- const validated = validateTopo(app);
306
- if (validated.isErr()) {
307
- throw validated.error;
308
- }
309
- };
310
-
311
297
  // ---------------------------------------------------------------------------
312
- // blaze
298
+ // trailhead
313
299
  // ---------------------------------------------------------------------------
314
300
 
315
301
  /**
316
302
  * Build HTTP routes from a topo, create a Hono app, and optionally start serving.
303
+ *
304
+ * Topo validation runs before route construction — pass `validate: false`
305
+ * to skip it (e.g. during hot-reload or progressive startup).
317
306
  */
318
- // oxlint-disable-next-line require-await -- async for consistency with other blaze() surfaces
319
- export const blaze = async (
307
+ // oxlint-disable-next-line require-await -- async for consistency with other trailhead() entrypoints
308
+ export const trailhead = async (
320
309
  app: Topo,
321
- options: BlazeHttpOptions = {}
310
+ options: TrailheadHttpOptions = {}
322
311
  ): Promise<Hono> => {
323
- assertValidTopo(app, options.validate === false);
324
-
325
312
  const hono = new Hono();
326
313
 
327
314
  registerErrorHandler(hono);
@@ -330,8 +317,9 @@ export const blaze = async (
330
317
  basePath: options.basePath,
331
318
  configValues: options.configValues,
332
319
  createContext: options.createContext,
333
- layers: options.layers,
334
- services: options.services,
320
+ gates: options.gates,
321
+ provisions: options.provisions,
322
+ validate: options.validate,
335
323
  });
336
324
 
337
325
  if (routesResult.isErr()) {
@@ -1 +1 @@
1
- {"root":["./src/build.ts","./src/index.ts","./src/hono/blaze.ts","./src/hono/index.ts"],"version":"5.9.3"}
1
+ {"root":["./src/build.ts","./src/index.ts","./src/hono/index.ts","./src/hono/trailhead.ts"],"version":"5.9.3"}