create-strata 2.2.9 → 2.2.10
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 +39 -11
- package/dist/templates/package.json +3 -3
- package/package.json +1 -1
package/dist/cli.js
CHANGED
|
@@ -3174,9 +3174,9 @@ function renderPackageJson(projectName, options = {}) {
|
|
|
3174
3174
|
"@getstrata/cli": "workspace:*",
|
|
3175
3175
|
"@getstrata/core": "workspace:*"
|
|
3176
3176
|
} : {
|
|
3177
|
-
"@getstrata/bootstrap": "^2.2.
|
|
3178
|
-
"@getstrata/cli": "^2.2.
|
|
3179
|
-
"@getstrata/core": "^2.2.
|
|
3177
|
+
"@getstrata/bootstrap": "^2.2.10",
|
|
3178
|
+
"@getstrata/cli": "^2.2.10",
|
|
3179
|
+
"@getstrata/core": "^2.2.10"
|
|
3180
3180
|
};
|
|
3181
3181
|
coreDeps.eta = "^4.6.0";
|
|
3182
3182
|
if (options.layers?.database === "mysql") {
|
|
@@ -3480,6 +3480,24 @@ Opaque token login: \`POST /api/v1/auth/login\` with \`{ "email", "password" }\`
|
|
|
3480
3480
|
JWT mint: \`POST /api/auth/token\` with email and password. Short-lived. Do not use JWT as an HTML cookie session.
|
|
3481
3481
|
` : ""}${layers.extras.metrics ? `
|
|
3482
3482
|
Prometheus scrape: \`GET /metrics\`. Production requires \`Authorization: Bearer <METRICS_TOKEN>\`.
|
|
3483
|
+
|
|
3484
|
+
Metrics default to HTTP-only. In \`src/bootstrap/server.ts\`, pass explicit \`runtimeMetrics\` options to \`bootstrapApp\`:
|
|
3485
|
+
|
|
3486
|
+
\`\`\`ts
|
|
3487
|
+
const redisUrl = process.env.REDIS_URL;
|
|
3488
|
+
if (!redisUrl) throw new Error("REDIS_URL is required for queue observations");
|
|
3489
|
+
const { routes, config, context } = await bootstrapApp({
|
|
3490
|
+
runtimeMetrics: {
|
|
3491
|
+
// Match the deployed Redis queue transport; this does not convert queues.
|
|
3492
|
+
queue: { redisUrl, transport: "streams", timeoutMs: 1000 },
|
|
3493
|
+
// Enable only on Postgres after explicitly installing the corresponding schema.
|
|
3494
|
+
// outbox: { sampleLimit: 500, timeoutMs: 1000 },
|
|
3495
|
+
// failedJobs: { sampleLimit: 500, timeoutMs: 1000 },
|
|
3496
|
+
},
|
|
3497
|
+
});
|
|
3498
|
+
\`\`\`
|
|
3499
|
+
|
|
3500
|
+
The generated provider drains owned SQL collectors through \`context.drain()\` before database closure, including workers and startup-failure cleanup. Keep the generated HTTP admission/drain and provider lifecycle order. Observation factories never migrate, seed, start a worker, or enable durable delivery. Missing schemas/unsupported SQL dialects produce collector failures on scrape; PostgreSQL collector schema requirements still apply. Tracing and selected-transaction acquisition collectors can be injected as borrowed options; their existing owners retain lifecycle/instrumentation responsibility. Shared queue/outbox/failed-job gauges use a designated target or max across replicas; never sum them. See the framework runtime metrics guide for semantics and operational qualification.
|
|
3483
3501
|
` : ""}${needsFrontendBuild(layers.frontend) ? `
|
|
3484
3502
|
## Frontend
|
|
3485
3503
|
|
|
@@ -4633,10 +4651,10 @@ export { starterProviders };
|
|
|
4633
4651
|
function renderCreateAppTs(layers) {
|
|
4634
4652
|
const ensureLine = needsEnsure(layers) ? `import { ensureAppDatabase } from "./ensureDatabase.ts";
|
|
4635
4653
|
` : "";
|
|
4636
|
-
const metricsImport = layers.extras.metrics ? `import { createMetricsRoutes } from "@getstrata/bootstrap/metricsRoutes";
|
|
4654
|
+
const metricsImport = layers.extras.metrics ? `import { createMetricsRoutes, createMetricsRuntime, type MetricsRuntime, type MetricsRuntimeOptions } from "@getstrata/bootstrap/metricsRoutes";
|
|
4637
4655
|
` : "";
|
|
4638
4656
|
const metricsSpread = layers.extras.metrics ? `
|
|
4639
|
-
...createMetricsRoutes(),` : "";
|
|
4657
|
+
...createMetricsRoutes(metricsRuntime?.options),` : "";
|
|
4640
4658
|
return `import { join } from "node:path";
|
|
4641
4659
|
import "./preload.ts";
|
|
4642
4660
|
import { createAppContext as createProviderAppContext, type InitializedAppContext } from "@getstrata/bootstrap/context";
|
|
@@ -4661,7 +4679,9 @@ import { closeDatabase, getSql, pingDatabase } from "./database.ts";
|
|
|
4661
4679
|
${ensureLine}import { starterProviders } from "./providers/index.ts";
|
|
4662
4680
|
|
|
4663
4681
|
export interface BootstrapOptions {
|
|
4664
|
-
migrate?: boolean
|
|
4682
|
+
migrate?: boolean;${layers.extras.metrics ? `
|
|
4683
|
+
/** Explicit opt-in; HTTP-only metrics remain the default. */
|
|
4684
|
+
runtimeMetrics?: MetricsRuntimeOptions;` : ""}
|
|
4665
4685
|
}
|
|
4666
4686
|
|
|
4667
4687
|
export interface BootstrappedApp {
|
|
@@ -4670,14 +4690,21 @@ export interface BootstrappedApp {
|
|
|
4670
4690
|
config: ReturnType<typeof loadConfig>;
|
|
4671
4691
|
}
|
|
4672
4692
|
|
|
4673
|
-
async function createAppContext(): Promise<InitializedAppContext> {
|
|
4693
|
+
async function createAppContext(${layers.extras.metrics ? "metricsRuntime?: MetricsRuntime" : ""}): Promise<InitializedAppContext> {
|
|
4674
4694
|
await ensureModulesLoaded();
|
|
4675
4695
|
const moduleProviders = discoverModules().flatMap((module) => module.providers ?? []);
|
|
4676
|
-
|
|
4696
|
+
${layers.extras.metrics ? ` const metricsProviders = metricsRuntime ? [{
|
|
4697
|
+
name: "starter.runtime-metrics",
|
|
4698
|
+
register({ onCleanup }: import("@getstrata/core/contracts/di").ProviderContext) {
|
|
4699
|
+
onCleanup(() => metricsRuntime.close(), "drain");
|
|
4700
|
+
},
|
|
4701
|
+
}] : [];
|
|
4702
|
+
` : ""} return createProviderAppContext([...starterProviders, ...moduleProviders${layers.extras.metrics ? ", ...metricsProviders" : ""}]);
|
|
4677
4703
|
}
|
|
4678
4704
|
|
|
4679
4705
|
export async function bootstrapApp(options: BootstrapOptions = {}): Promise<BootstrappedApp> {
|
|
4680
|
-
let context: InitializedAppContext | undefined
|
|
4706
|
+
let context: InitializedAppContext | undefined;${layers.extras.metrics ? `
|
|
4707
|
+
let metricsRuntime: MetricsRuntime | undefined;` : ""}
|
|
4681
4708
|
try {
|
|
4682
4709
|
const isProduction = isProductionEnv();
|
|
4683
4710
|
// Dev boots migrate for convenience. Production must not mutate schema on
|
|
@@ -4697,7 +4724,8 @@ ${needsEnsure(layers) ? ` await ensureAppDatabase({ provision: !isProduction
|
|
|
4697
4724
|
}
|
|
4698
4725
|
configureModulesDirectory(join(import.meta.dir, "../modules"));
|
|
4699
4726
|
await ensureModulesLoaded();
|
|
4700
|
-
|
|
4727
|
+
${layers.extras.metrics ? ` metricsRuntime = createMetricsRuntime(options.runtimeMetrics);
|
|
4728
|
+
` : ""} context = await createAppContext(${layers.extras.metrics ? "metricsRuntime" : ""});
|
|
4701
4729
|
|
|
4702
4730
|
if (runMigrate) {
|
|
4703
4731
|
await migrate();
|
|
@@ -4721,7 +4749,7 @@ ${needsEnsure(layers) ? ` await ensureAppDatabase({ provision: !isProduction
|
|
|
4721
4749
|
return { context, routes, config: appConfig };
|
|
4722
4750
|
} catch (error) {
|
|
4723
4751
|
const failures: unknown[] = [];
|
|
4724
|
-
for (const cleanup of [() => context?.dispose(), closeDatabase]) {
|
|
4752
|
+
for (const cleanup of [() => context?.dispose(), ${layers.extras.metrics ? "() => metricsRuntime?.close(), " : ""}closeDatabase]) {
|
|
4725
4753
|
try { await cleanup(); } catch (failure) { failures.push(failure); }
|
|
4726
4754
|
}
|
|
4727
4755
|
if (failures.length) throw new AggregateError([error, ...failures], "Application startup and cleanup failed.", { cause: error });
|
|
@@ -12,9 +12,9 @@
|
|
|
12
12
|
"check": "tsc --noEmit"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
-
"@getstrata/bootstrap": "^2.2.
|
|
16
|
-
"@getstrata/cli": "^2.2.
|
|
17
|
-
"@getstrata/core": "^2.2.
|
|
15
|
+
"@getstrata/bootstrap": "^2.2.10",
|
|
16
|
+
"@getstrata/cli": "^2.2.10",
|
|
17
|
+
"@getstrata/core": "^2.2.10",
|
|
18
18
|
"eta": "^4.6.0"
|
|
19
19
|
},
|
|
20
20
|
"devDependencies": {
|