@getstrata/starter 2.2.36 → 2.2.38

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.
package/dist/cli.js CHANGED
@@ -2877,6 +2877,8 @@ function renderEnvExample(projectName, layers) {
2877
2877
  `APP_KEY_PREFIX=${projectName}`,
2878
2878
  "APP_ENV=local",
2879
2879
  "PORT=3000",
2880
+ "# Optional TCP listen address, separate from public APP_URL / tenant hosts.",
2881
+ "# HOST=0.0.0.0",
2880
2882
  "# Total graceful shutdown budget in milliseconds; keep deployment grace longer.",
2881
2883
  "SHUTDOWN_TIMEOUT_MS=30000",
2882
2884
  "APP_URL=http://localhost:3000",
@@ -3177,9 +3179,9 @@ function renderPackageJson(projectName, options = {}) {
3177
3179
  "@getstrata/cli": "workspace:*",
3178
3180
  "@getstrata/core": "workspace:*"
3179
3181
  } : {
3180
- "@getstrata/bootstrap": "^2.2.36",
3181
- "@getstrata/cli": "^2.2.36",
3182
- "@getstrata/core": "^2.2.36"
3182
+ "@getstrata/bootstrap": "^2.2.38",
3183
+ "@getstrata/cli": "^2.2.38",
3184
+ "@getstrata/core": "^2.2.38"
3183
3185
  };
3184
3186
  coreDeps.eta = "^4.6.0";
3185
3187
  if (options.layers?.database === "mysql") {
@@ -4419,6 +4421,8 @@ configureModulesDirectory(join(import.meta.dir, "../modules"));
4419
4421
  function renderConfigTs() {
4420
4422
  return `export interface AppConfig {
4421
4423
  port: number;
4424
+ /** Optional listen address; independent of the trusted public APP_URL. */
4425
+ hostname?: string;
4422
4426
  appUrl: string;
4423
4427
  databaseUrl: string;
4424
4428
  }
@@ -4431,6 +4435,7 @@ export function loadConfig(): AppConfig {
4431
4435
 
4432
4436
  return {
4433
4437
  port: Number(process.env.PORT ?? 3000),
4438
+ hostname: process.env.HOST?.trim() || undefined,
4434
4439
  appUrl: process.env.APP_URL ?? "http://localhost:3000",
4435
4440
  databaseUrl,
4436
4441
  };
@@ -4686,7 +4691,7 @@ import {
4686
4691
  } from "@getstrata/bootstrap/discoverModules";
4687
4692
  import { createHealthRoutes } from "@getstrata/bootstrap/health";
4688
4693
  ${metricsImport}import { assertProductionSecrets, assertRlsLiveDatabaseRole } from "@getstrata/bootstrap/secretsGuard";
4689
- import { createWebServer } from "@getstrata/bootstrap/web/server";
4694
+ import { createWebServer, type NativeServerOptions } from "@getstrata/bootstrap/web/server";
4690
4695
  import type { LifecycleCoordinator } from "@getstrata/core/lifecycle/gracefulShutdown";
4691
4696
  import { isProductionEnv } from "@getstrata/core/runtime/appEnv";
4692
4697
  import { isRlsTenancy } from "@getstrata/core/tenant/tenancyConfig";
@@ -4698,6 +4703,7 @@ import { closeDatabase, getSql, pingDatabase } from "./database.ts";
4698
4703
  ${ensureLine}import { starterProviders } from "./providers/index.ts";
4699
4704
 
4700
4705
  export interface BootstrapOptions {
4706
+ /** Automatic migrations and local database provisioning; false uses existing infrastructure. */
4701
4707
  migrate?: boolean;${layers.extras.metrics ? `
4702
4708
  /** Explicit opt-in; HTTP-only metrics remain the default. */
4703
4709
  runtimeMetrics?: MetricsRuntimeOptions;` : ""}
@@ -4734,7 +4740,7 @@ export async function bootstrapApp(options: BootstrapOptions = {}): Promise<Boot
4734
4740
  assertProductionSecrets();
4735
4741
  }
4736
4742
 
4737
- ${needsEnsure(layers) ? ` await ensureAppDatabase({ provision: !isProduction });
4743
+ ${needsEnsure(layers) ? ` await ensureAppDatabase({ provision: !isProduction && runMigrate });
4738
4744
  ` : ""} const appConfig = loadConfig();
4739
4745
  getSql();
4740
4746
  if (!(await pingDatabase())) throw new Error("Database is not ready.");
@@ -4780,11 +4786,12 @@ export async function createApp(options: BootstrapOptions = {}) {
4780
4786
  return bootstrapApp({ migrate: false, ...options });
4781
4787
  }
4782
4788
 
4783
- export function createAppServer(routes: AppRouteMap, port = 0, lifecycle?: LifecycleCoordinator) {
4789
+ export function createAppServer(routes: AppRouteMap, port = 0, lifecycle?: LifecycleCoordinator, native?: NativeServerOptions) {
4784
4790
  return createWebServer({
4785
4791
  port,
4786
4792
  publicDir: "./public",
4787
4793
  lifecycle,
4794
+ native,
4788
4795
  routes,
4789
4796
  });
4790
4797
  }
@@ -4916,48 +4923,45 @@ export default createOutboxMigration("0005_outbox", "${driver}", { rls: ${rls} }
4916
4923
  `;
4917
4924
  }
4918
4925
  function renderCliQueueFailedTs() {
4919
- return `async function bootApp(): Promise<void> {
4920
- const { bootstrapApp } = await import("../bootstrap/createApp.ts");
4921
- await bootstrapApp({ migrate: false });
4922
- }
4923
-
4924
- async function queueFailedCommand(): Promise<void> {
4925
- const { queueFailedCommand: run } = await import("@getstrata/cli/queueFailed");
4926
- await run(bootApp);
4927
- }
4928
-
4929
- async function queueRetryCommand(id?: string): Promise<void> {
4930
- const { queueRetryCommand: run } = await import("@getstrata/cli/queueFailed");
4931
- await run(id, bootApp);
4932
- }
4926
+ return `import { createQueueFailedCommands } from "@getstrata/cli/queueFailed";
4927
+ import { bootstrapApp } from "../bootstrap/createApp.ts";
4928
+ import { closeDatabase } from "../bootstrap/database.ts";
4933
4929
 
4934
- async function queueFlushFailedCommand(): Promise<void> {
4935
- const { queueFlushFailedCommand: run } = await import("@getstrata/cli/queueFailed");
4936
- await run(bootApp);
4937
- }
4930
+ let app: Awaited<ReturnType<typeof bootstrapApp>> | undefined;
4931
+ const { queueFailedCommand, queueFlushFailedCommand, queueRetryCommand } = createQueueFailedCommands(
4932
+ async () => { app = await bootstrapApp({ migrate: false }); },
4933
+ async () => { try { await app?.context.dispose(); } finally { app = undefined; await closeDatabase(); } },
4934
+ );
4938
4935
 
4939
4936
  export { queueFailedCommand, queueFlushFailedCommand, queueRetryCommand };
4940
4937
  `;
4941
4938
  }
4942
4939
  function renderCliOpenApiTs() {
4943
- return `async function bootstrap() {
4944
- const { createApp } = await import("../bootstrap/createApp.ts");
4945
- return createApp({ migrate: false });
4940
+ return `import { createApp } from "../bootstrap/createApp.ts";
4941
+ import { closeDatabase } from "../bootstrap/database.ts";
4942
+
4943
+ let app: Awaited<ReturnType<typeof createApp>> | undefined;
4944
+ async function bootstrap() {
4945
+ app = await createApp({ migrate: false });
4946
+ return app;
4947
+ }
4948
+ async function close() {
4949
+ try { await app?.context.dispose(); } finally { app = undefined; await closeDatabase(); }
4946
4950
  }
4947
4951
 
4948
4952
  async function openapiGenerateCommand(): Promise<void> {
4949
4953
  const { createOpenApiGenerateCommand } = await import("@getstrata/cli/openapi");
4950
- await createOpenApiGenerateCommand(bootstrap)();
4954
+ await createOpenApiGenerateCommand(bootstrap, close)();
4951
4955
  }
4952
4956
 
4953
4957
  async function openapiValidateCommand(): Promise<void> {
4954
4958
  const { createOpenApiValidateCommand } = await import("@getstrata/cli/openapi");
4955
- await createOpenApiValidateCommand(bootstrap)();
4959
+ await createOpenApiValidateCommand(bootstrap, close)();
4956
4960
  }
4957
4961
 
4958
4962
  async function openapiCheckCommand(): Promise<void> {
4959
4963
  const { createOpenApiCheckCommand } = await import("@getstrata/cli/openapi");
4960
- await createOpenApiCheckCommand(bootstrap)();
4964
+ await createOpenApiCheckCommand(bootstrap, close)();
4961
4965
  }
4962
4966
 
4963
4967
  export { openapiCheckCommand, openapiGenerateCommand, openapiValidateCommand };
@@ -12,9 +12,9 @@
12
12
  "check": "tsc --noEmit"
13
13
  },
14
14
  "dependencies": {
15
- "@getstrata/bootstrap": "^2.2.36",
16
- "@getstrata/cli": "^2.2.36",
17
- "@getstrata/core": "^2.2.36",
15
+ "@getstrata/bootstrap": "^2.2.38",
16
+ "@getstrata/cli": "^2.2.38",
17
+ "@getstrata/core": "^2.2.38",
18
18
  "eta": "^4.6.0"
19
19
  },
20
20
  "devDependencies": {
@@ -1,5 +1,6 @@
1
1
  export interface AppConfig {
2
2
  port: number;
3
+ hostname?: string;
3
4
  appUrl: string;
4
5
  databaseUrl: string;
5
6
  }
@@ -12,6 +13,7 @@ export function loadConfig(): AppConfig {
12
13
 
13
14
  return {
14
15
  port: Number(process.env.PORT ?? 3000),
16
+ hostname: process.env.HOST?.trim() || undefined,
15
17
  appUrl: process.env.APP_URL ?? "http://localhost:3000",
16
18
  databaseUrl,
17
19
  };
@@ -10,7 +10,12 @@ const { routes, config, context } = await bootstrapApp();
10
10
  const lifecycle = new LifecycleCoordinator();
11
11
  let server: ReturnType<typeof createAppServer>;
12
12
  try {
13
- server = createAppServer(routes, config.port, lifecycle);
13
+ server = createAppServer(
14
+ routes,
15
+ config.port,
16
+ lifecycle,
17
+ config.hostname ? { hostname: config.hostname } : undefined,
18
+ );
14
19
  } catch (error) {
15
20
  try {
16
21
  await context.dispose();
@@ -19,7 +24,7 @@ try {
19
24
  }
20
25
  throw error;
21
26
  }
22
- console.log(`Listening on http://localhost:${server.port} (APP_URL ${config.appUrl})`);
27
+ console.log(`Listening on ${server.url.origin} (APP_URL ${config.appUrl})`);
23
28
 
24
29
  lifecycle.register("providers:drain", () => context.drain(), "drain");
25
30
  lifecycle.register("providers:flush", () => context.flush(), "flush");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@getstrata/starter",
3
- "version": "2.2.36",
3
+ "version": "2.2.38",
4
4
  "description": "Interactive create-strata wizard. Choose each layer; one database engine.",
5
5
  "type": "module",
6
6
  "license": "MIT",