@decohere/core 0.0.1-dev.20261106.224 → 0.0.1-dev.20261107.245

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.
@@ -23,6 +23,17 @@ const DEFAULT_SHUTDOWN_SIGNALS = [
23
23
  ];
24
24
  const DEFAULT_SHUTDOWN_TIMEOUT_MS = 10_000;
25
25
  export class ApiConfiguration {
26
+ static schema = {
27
+ type: "object",
28
+ additionalProperties: false,
29
+ properties: {
30
+ port: {
31
+ type: "integer",
32
+ minimum: 0,
33
+ maximum: 65535
34
+ }
35
+ }
36
+ };
26
37
  port;
27
38
  }
28
39
  export class App {
@@ -21,6 +21,10 @@ export class Builder {
21
21
  this.containerBuilder = containerBuilder;
22
22
  this.applicationName = options?.applicationName;
23
23
  }
24
+ use(plugin) {
25
+ plugin(this);
26
+ return this;
27
+ }
24
28
  withServices(userServices) {
25
29
  this.userServices.push(userServices);
26
30
  return this;
@@ -3,3 +3,10 @@ export const Environments = {
3
3
  development: "development"
4
4
  };
5
5
  export const DefaultEnvironment = Environments.development;
6
+ /**
7
+ * True only when NODE_ENV says development: `development` or `dev`. Anything else, unset, staging or
8
+ * a typo included, isn't. Use it to refuse settings that are unsafe outside development.
9
+ */ export function isDevelopmentEnv(nodeEnv = process.env.NODE_ENV) {
10
+ const env = nodeEnv?.toLowerCase();
11
+ return env === "development" || env === "dev";
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@decohere/core",
3
- "version": "0.0.1-dev.20261106.224",
3
+ "version": "0.0.1-dev.20261107.245",
4
4
  "description": "The runtime base every Decohere package builds on: reflection, composition, configuration types, extensibility, collections, objects, caching on a Map, and basic file IO. No side effects on import.",
5
5
  "keywords": [
6
6
  "typescript",
@@ -68,7 +68,7 @@
68
68
  "test": "echo \"Error: no test specified\" && exit 1"
69
69
  },
70
70
  "dependencies": {
71
- "@decohere/scribe": "0.0.1-dev.20261106.224",
71
+ "@decohere/scribe": "0.0.1-dev.20261107.245",
72
72
  "reflect-metadata": "^0.2.2"
73
73
  },
74
74
  "devDependencies": {}
@@ -2,6 +2,17 @@ import { type LifetimeScope } from "../composition/index.js";
2
2
  import { type IConfigurationService } from "../configuration/index.js";
3
3
  import type { HostedServiceHost } from "./hosted-service-host.js";
4
4
  export declare class ApiConfiguration {
5
+ static schema: {
6
+ type: string;
7
+ additionalProperties: boolean;
8
+ properties: {
9
+ port: {
10
+ type: string;
11
+ minimum: number;
12
+ maximum: number;
13
+ };
14
+ };
15
+ };
5
16
  port: number;
6
17
  }
7
18
  export type AppServerStartOptions = {
@@ -6,6 +6,11 @@ import type { HostedService } from "./hosted-service.js";
6
6
  export type BuilderOptions = {
7
7
  applicationName?: string;
8
8
  };
9
+ /**
10
+ * A feature an app adds with `builder.use(...)`, such as `http(...)` or `config(...)`. A plugin is
11
+ * a plain function: it registers what it needs on the builder it gets.
12
+ */
13
+ export type BuilderPlugin = (builder: Builder) => void;
9
14
  export declare class Builder<T extends App = App> {
10
15
  /**
11
16
  * @param containerBuilder The container the app runs on: `new ServiceContainerBuilder()` from
@@ -20,6 +25,7 @@ export declare class Builder<T extends App = App> {
20
25
  private postBuildSteps;
21
26
  private readonly hostedServices;
22
27
  constructor(containerBuilder: ContainerBuilder, options?: BuilderOptions);
28
+ use(plugin: BuilderPlugin): this;
23
29
  withServices(userServices: (containerBuilder: ContainerBuilder) => void): Builder<T>;
24
30
  /**
25
31
  * Run {@link HostedService}s for the life of the app: started in this order before the
@@ -25,7 +25,7 @@ export interface HostedService {
25
25
  stop?(): Promise<void> | void;
26
26
  /**
27
27
  * Readiness while the service is started but still warming up: throw until it can serve, and
28
- * `GET /ready` answers 503 (`withHealth()`). Optional.
28
+ * `GET /ready` answers 503 (`health()`). Optional.
29
29
  */
30
30
  check?(): Promise<void>;
31
31
  }
@@ -4,3 +4,8 @@ export declare const Environments: {
4
4
  development: "development";
5
5
  };
6
6
  export declare const DefaultEnvironment: "development";
7
+ /**
8
+ * True only when NODE_ENV says development: `development` or `dev`. Anything else, unset, staging or
9
+ * a typo included, isn't. Use it to refuse settings that are unsafe outside development.
10
+ */
11
+ export declare function isDevelopmentEnv(nodeEnv?: string | undefined): boolean;