create-bcp-app 0.2.6 → 0.2.7

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/README.md CHANGED
@@ -92,10 +92,10 @@ Example:
92
92
  "schemaVersion": 1,
93
93
  "framework": "bcp",
94
94
  "projectName": "my-app",
95
- "frameworkPackage": "npm:@chidchanun/bcp@0.2.6",
95
+ "frameworkPackage": "npm:@chidchanun/bcp@0.2.7",
96
96
  "createdWith": {
97
97
  "package": "create-bcp-app",
98
- "version": "0.2.6"
98
+ "version": "0.2.7"
99
99
  },
100
100
  "packageManager": "npm",
101
101
  "presets": {
@@ -326,6 +326,37 @@ import {
326
326
 
327
327
  Authorization and CSRF checks must remain on the server; hiding UI controls in client code is not an authorization boundary.
328
328
 
329
+ ## Observability — 0.2.7+
330
+
331
+ Generated projects can opt into process-local metrics and health/readiness without adding another dependency:
332
+
333
+ ```ts
334
+ import {
335
+ createHealthRegistry,
336
+ createMetricsRegistry,
337
+ createRequestMetricsMiddleware,
338
+ } from "bcp/observability";
339
+
340
+ export const metrics =
341
+ createMetricsRegistry();
342
+
343
+ export const health =
344
+ createHealthRegistry();
345
+
346
+ export const requestMetrics =
347
+ createRequestMetricsMiddleware(
348
+ metrics
349
+ );
350
+ ```
351
+
352
+ Expose metrics from an application API route with `createMetricsResponse(metrics)`. The response uses Prometheus-compatible text format.
353
+
354
+ Health endpoints can return `health.response()`, which uses HTTP `200` when all checks pass and `503` when any dependency check fails or times out.
355
+
356
+ The default HTTP request metrics use `method` and `status` labels only. Raw paths are intentionally excluded to avoid high-cardinality metric series.
357
+
358
+ `bcp/observability` is server-only. Protect metrics and operational health detail with an appropriate network or authorization boundary when needed.
359
+
329
360
  ## Application Packaging — 0.2.4+
330
361
 
331
362
  Generated projects include:
@@ -407,5 +438,5 @@ npx create-bcp-app my-app --yes
407
438
  The `--bcp` option is mainly for prerelease/local package verification:
408
439
 
409
440
  ```bash
410
- npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.6.tgz
441
+ npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.7.tgz
411
442
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bcp-app",
3
- "version": "0.2.6",
3
+ "version": "0.2.7",
4
4
  "description": "Create a new BCP Framework application.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -94,6 +94,37 @@ import {
94
94
 
95
95
  Authorization must always be enforced server-side. Client UI visibility is not a security boundary.
96
96
 
97
+ ## Observability — BCP 0.2.7+
98
+
99
+ Create process-local metrics and health/readiness registries:
100
+
101
+ ```ts
102
+ import {
103
+ createHealthRegistry,
104
+ createMetricsRegistry,
105
+ createRequestMetricsMiddleware,
106
+ } from "bcp/observability";
107
+
108
+ export const metrics =
109
+ createMetricsRegistry();
110
+
111
+ export const health =
112
+ createHealthRegistry();
113
+
114
+ export const requestMetrics =
115
+ createRequestMetricsMiddleware(
116
+ metrics
117
+ );
118
+ ```
119
+
120
+ Expose Prometheus-compatible metrics with `createMetricsResponse(metrics)` from a server API route.
121
+
122
+ Use `health.response()` for readiness endpoints. It returns HTTP `200` when all checks pass and `503` when a check fails or times out.
123
+
124
+ The default request metrics use bounded `method` and `status` labels and do not include raw paths.
125
+
126
+ Protect operational endpoints when their contents should not be public.
127
+
97
128
  ## Generate framework files
98
129
 
99
130
  BCP can generate common project files: