create-bcp-app 0.2.6 → 0.2.8

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.8",
96
96
  "createdWith": {
97
97
  "package": "create-bcp-app",
98
- "version": "0.2.6"
98
+ "version": "0.2.8"
99
99
  },
100
100
  "packageManager": "npm",
101
101
  "presets": {
@@ -326,6 +326,74 @@ 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
+
360
+ ## Background jobs — 0.2.8+
361
+
362
+ Generated projects can create a server-only background job queue without adding another package:
363
+
364
+ ```ts
365
+ import {
366
+ createJobQueue,
367
+ } from "bcp/jobs";
368
+
369
+ export const jobs =
370
+ createJobQueue();
371
+ ```
372
+
373
+ Register handlers and enqueue work:
374
+
375
+ ```ts
376
+ jobs.register(
377
+ "email.welcome",
378
+ async ({ payload }) => {
379
+ await sendWelcomeEmail(
380
+ payload.userId
381
+ );
382
+ }
383
+ );
384
+
385
+ await jobs.enqueue(
386
+ "email.welcome",
387
+ {
388
+ userId: 42,
389
+ }
390
+ );
391
+ ```
392
+
393
+ Workers support concurrency, delayed jobs, retry/backoff and cancellation. The default memory adapter is process-local and should be replaced with a durable `JobQueueAdapter` for multi-process/container production workloads that must survive restarts.
394
+
395
+ `bcp/jobs` is server-only and must not be imported into page/client bundles.
396
+
329
397
  ## Application Packaging — 0.2.4+
330
398
 
331
399
  Generated projects include:
@@ -407,5 +475,5 @@ npx create-bcp-app my-app --yes
407
475
  The `--bcp` option is mainly for prerelease/local package verification:
408
476
 
409
477
  ```bash
410
- npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.6.tgz
478
+ npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.8.tgz
411
479
  ```
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.8",
4
4
  "description": "Create a new BCP Framework application.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -94,6 +94,76 @@ 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
+
128
+ ## Background jobs — BCP 0.2.8+
129
+
130
+ Create a server-only background queue:
131
+
132
+ ```ts
133
+ import {
134
+ createJobQueue,
135
+ } from "bcp/jobs";
136
+
137
+ export const jobs =
138
+ createJobQueue();
139
+ ```
140
+
141
+ Register and enqueue work:
142
+
143
+ ```ts
144
+ jobs.register(
145
+ "email.welcome",
146
+ async ({ payload }) => {
147
+ await sendWelcomeEmail(
148
+ payload.userId
149
+ );
150
+ }
151
+ );
152
+
153
+ await jobs.enqueue(
154
+ "email.welcome",
155
+ {
156
+ userId: 42,
157
+ }
158
+ );
159
+ ```
160
+
161
+ Workers support delayed jobs, retry/backoff, cancellation and configurable concurrency.
162
+
163
+ The default memory adapter is process-local and not durable. For production jobs that must survive restarts or run across multiple processes/containers, implement `JobQueueAdapter` with shared durable infrastructure.
164
+
165
+ `bcp/jobs` is server-only and cannot be imported into page/client bundles.
166
+
97
167
  ## Generate framework files
98
168
 
99
169
  BCP can generate common project files: