create-bcp-app 0.2.19 → 0.3.0

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
@@ -10,7 +10,7 @@ npm run dev
10
10
 
11
11
  ## Project-local BCP CLI
12
12
 
13
- `create-bcp-app` installs BCP Framework as a project-local dependency. Generated npm scripts use the local CLI:
13
+ Generated npm scripts use the project-local framework CLI:
14
14
 
15
15
  ```json
16
16
  {
@@ -64,17 +64,17 @@ Select storage provider:
64
64
 
65
65
  New projects include `bcp.project.json`.
66
66
 
67
- Example for the `0.2.19` target:
67
+ Example for the `0.3.0` target:
68
68
 
69
69
  ```json
70
70
  {
71
71
  "schemaVersion": 1,
72
72
  "framework": "bcp",
73
73
  "projectName": "my-app",
74
- "frameworkPackage": "npm:@chidchanun/bcp@0.2.19",
74
+ "frameworkPackage": "npm:@chidchanun/bcp@0.3.0",
75
75
  "createdWith": {
76
76
  "package": "create-bcp-app",
77
- "version": "0.2.19"
77
+ "version": "0.3.0"
78
78
  },
79
79
  "packageManager": "npm",
80
80
  "presets": {
@@ -88,6 +88,59 @@ Example for the `0.2.19` target:
88
88
 
89
89
  This manifest records scaffold identity only. Do not place secrets in it.
90
90
 
91
+ ## BCP Application Platform — 0.3.0+
92
+
93
+ Applications can optionally centralize server infrastructure through `bcp/application`:
94
+
95
+ ```ts
96
+ import {
97
+ createApp,
98
+ } from "bcp/application";
99
+
100
+ export const app =
101
+ createApp({
102
+ name: "my-app",
103
+ });
104
+ ```
105
+
106
+ Register existing provider-native services:
107
+
108
+ ```ts
109
+ app.provide(
110
+ "database",
111
+ database
112
+ );
113
+
114
+ app.provide(
115
+ "cache",
116
+ cache
117
+ );
118
+ ```
119
+
120
+ Register long-running lifecycle resources:
121
+
122
+ ```ts
123
+ app.addResource({
124
+ name: "database",
125
+
126
+ start() {
127
+ return database.connect();
128
+ },
129
+
130
+ ready() {
131
+ return database.ready;
132
+ },
133
+
134
+ stop() {
135
+ return database.close();
136
+ },
137
+ });
138
+ ```
139
+
140
+ Application startup orders plugins before infrastructure resources and the application start hook. Shutdown reverses dependency order.
141
+
142
+ Existing `bcp/database`, `bcp/jobs`, `bcp/workflow`, `bcp/events`, `bcp/realtime`, `bcp/cache`, `bcp/plugins`, `bcp/observability` and `bcp/deployment` APIs remain usable independently.
143
+
91
144
  ## Database presets
92
145
 
93
146
  Database choices add starter configuration and the matching driver:
@@ -137,7 +190,7 @@ BCP does not install a WebSocket server library. Applications adapt their provid
137
190
 
138
191
  ## Plugins
139
192
 
140
- `bcp/plugins` provides dependency ordering, module composition, lifecycle hooks, config parsing, shared services and async hooks.
193
+ `bcp/plugins` provides dependency ordering, module composition, lifecycle hooks, config parsing, shared services and async hooks. Plugin definitions/modules can be passed directly to `createApp()`.
141
194
 
142
195
  ## Cache Platform v2
143
196
 
@@ -165,104 +218,11 @@ export const tracer =
165
218
  });
166
219
  ```
167
220
 
168
- Tracing supports W3C `traceparent`, correlation IDs, request middleware, explicit carriers for jobs/workflows/events/realtime and provider-neutral exporters.
169
-
170
- ## Deployment Platform v2 — 0.2.18+
171
-
172
- Use `bcp/deployment` to coordinate application resources in production:
173
-
174
- ```ts
175
- import {
176
- createDeploymentRuntime,
177
- } from "bcp/deployment";
178
-
179
- export const deployment =
180
- createDeploymentRuntime({
181
- serviceName: "my-app",
182
- });
183
- ```
184
-
185
- Register shared dependencies before components that use them:
186
-
187
- ```ts
188
- deployment.addResource({
189
- name: "database",
190
-
191
- async start() {
192
- await db.connect();
193
- },
194
-
195
- ready() {
196
- return db.status === "ready";
197
- },
198
-
199
- async stop() {
200
- await db.close();
201
- },
202
- });
203
-
204
- deployment.addResource({
205
- name: "workers",
206
-
207
- start() {
208
- worker = jobs.startWorker();
209
- },
210
-
211
- async stop() {
212
- await worker.stop();
213
- },
214
- });
215
-
216
- await deployment.start();
217
- ```
218
-
219
- Startup follows registration order and shutdown reverses it. This naturally stops workers before database/cache/Redis connections.
220
-
221
- Readiness endpoint:
222
-
223
- ```ts
224
- import {
225
- createDeploymentReadinessResponse,
226
- } from "bcp/deployment";
227
-
228
- export function GET() {
229
- return createDeploymentReadinessResponse(
230
- deployment
231
- );
232
- }
233
- ```
234
-
235
- Runtime identity can use:
236
-
237
- ```text
238
- BCP_DEPLOYMENT_ID
239
- BCP_INSTANCE_ID
240
- BCP_RELEASE
241
- NODE_ENV
242
- BCP_SHUTDOWN_TIMEOUT_MS
243
- ```
244
-
245
- Install graceful signal handling with:
246
-
247
- ```ts
248
- const removeSignals =
249
- deployment.installSignalHandlers();
250
- ```
251
-
252
- Default signals are `SIGTERM` and `SIGINT`.
221
+ Tracing supports W3C `traceparent`, correlation IDs, request middleware, explicit carriers and provider-neutral exporters.
253
222
 
254
- ## Stability & API Freeze — 0.2.19
255
-
256
- `0.2.19` keeps the `0.2.x` public package surface stable before the next platform baseline.
257
-
258
- Framework maintainers can validate the frozen contract with:
259
-
260
- ```bash
261
- npm run api:check
262
- npm run release:readiness
263
- ```
223
+ ## Deployment Platform v2
264
224
 
265
- Generated applications do not need to run these framework-repository release commands. Application code should continue importing documented `bcp/*` entrypoints rather than private framework source paths.
225
+ `bcp/deployment` remains available for applications that want to own resource lifecycle directly. `bcp/application` reuses the same resource/readiness/diagnostics model when using the Application Platform.
266
226
 
267
227
  ## Application packaging
268
228
 
@@ -273,7 +233,7 @@ npm run package
273
233
 
274
234
  The deployment package excludes application `devDependencies` and project `.env` values. Supply secrets through the deployment environment.
275
235
 
276
- BCP `0.2.19` prepared framework packages preserve the compiled ESM runtime map introduced by Deployment Platform v2 for the main server entrypoints including config, auth, observability, deployment, server and middleware.
236
+ BCP `0.3.0` prepared framework packages add compiled `application.mjs` to the compiled ESM server-runtime set.
277
237
 
278
238
  ## Project generators
279
239
 
@@ -301,5 +261,5 @@ npm run generate -- migration create_users
301
261
  For prerelease/local package verification:
302
262
 
303
263
  ```bash
304
- npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.19.tgz
264
+ npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.3.0.tgz
305
265
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bcp-app",
3
- "version": "0.2.19",
3
+ "version": "0.3.0",
4
4
  "description": "Create a new BCP Framework application.",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -27,6 +27,56 @@ npm run update
27
27
 
28
28
  Generated projects include `bcp.project.json` with non-secret scaffold metadata. Commit it with the project, but never put passwords, tokens or access keys in it.
29
29
 
30
+ ## Application Platform — BCP 0.3.0+
31
+
32
+ For applications with several server subsystems, `bcp/application` provides one optional composition root:
33
+
34
+ ```ts
35
+ import {
36
+ createApp,
37
+ } from "bcp/application";
38
+
39
+ export const app =
40
+ createApp({
41
+ name: "bcp-app",
42
+ });
43
+ ```
44
+
45
+ Register shared service instances before startup:
46
+
47
+ ```ts
48
+ app.provide("database", database);
49
+ app.provide("cache", cache);
50
+ ```
51
+
52
+ Register lifecycle-owned resources:
53
+
54
+ ```ts
55
+ app.addResource({
56
+ name: "database",
57
+
58
+ start() {
59
+ return database.connect();
60
+ },
61
+
62
+ ready() {
63
+ return database.ready;
64
+ },
65
+
66
+ stop() {
67
+ return database.close();
68
+ },
69
+ });
70
+ ```
71
+
72
+ Then start the application runtime from your server/bootstrap composition code:
73
+
74
+ ```ts
75
+ await app.start();
76
+ ```
77
+
78
+ Existing plugin modules can be passed directly to `createApp()`. Existing subsystem APIs remain available independently when a centralized application runtime is unnecessary.
79
+
30
80
  ## Authentication and authorization
31
81
 
32
82
  JWT Cookie projects can use `createAuth()` and optional `AuthSessionStore` revocation. Permission guards/resource policies live in `bcp/auth`; same-origin/CSRF helpers live in `bcp/server`.
@@ -72,7 +122,7 @@ BCP does not install a WebSocket server library. Adapt the selected provider thr
72
122
 
73
123
  ## Plugins
74
124
 
75
- `bcp/plugins` provides reusable server-side plugins/modules, dependency ordering, lifecycle hooks, config parsing, shared services and awaited hooks.
125
+ `bcp/plugins` provides reusable server-side plugins/modules, dependency ordering, lifecycle hooks, config parsing, shared services and awaited hooks. Plugin definitions/modules can also be composed by `bcp/application`.
76
126
 
77
127
  ## Cache Platform v2
78
128
 
@@ -102,87 +152,24 @@ export const tracer =
102
152
 
103
153
  Tracing supports AsyncLocalStorage context, W3C `traceparent`, correlation IDs, request tracing, trace carriers and provider-neutral exporters.
104
154
 
105
- ## Deployment Platform v2 — BCP 0.2.18+
106
-
107
- Use `bcp/deployment` to manage production resource lifecycle:
108
-
109
- ```ts
110
- import {
111
- createDeploymentRuntime,
112
- } from "bcp/deployment";
113
-
114
- export const deployment =
115
- createDeploymentRuntime({
116
- serviceName: "bcp-app",
117
- });
118
- ```
119
-
120
- Register dependencies first:
121
-
122
- ```ts
123
- deployment.addResource({
124
- name: "database",
125
-
126
- async start() {
127
- await db.connect();
128
- },
129
-
130
- ready() {
131
- return db.status === "ready";
132
- },
133
-
134
- async stop() {
135
- await db.close();
136
- },
137
- });
138
- ```
139
-
140
- Register workers/realtime services afterward so reverse-order shutdown stops them before their shared database/cache/Redis dependencies.
141
-
142
- Start runtime:
143
-
144
- ```ts
145
- await deployment.start();
146
- ```
147
-
148
- Readiness endpoint:
149
-
150
- ```ts
151
- import {
152
- createDeploymentReadinessResponse,
153
- } from "bcp/deployment";
154
-
155
- export function GET() {
156
- return createDeploymentReadinessResponse(
157
- deployment
158
- );
159
- }
160
- ```
161
-
162
- Install graceful signal handling when the app owns process signals:
163
-
164
- ```ts
165
- const removeSignals =
166
- deployment.installSignalHandlers();
167
- ```
155
+ ## Deployment lifecycle
168
156
 
169
- Default signals are `SIGTERM` and `SIGINT`.
157
+ `bcp/deployment` remains available when the project wants direct lifecycle ownership. `bcp/application` reuses the same resource/readiness/diagnostics model and adds application/plugin composition around it.
170
158
 
171
- Deployment identity can be supplied through:
159
+ Application Platform startup order is:
172
160
 
173
161
  ```text
174
- BCP_DEPLOYMENT_ID
175
- BCP_INSTANCE_ID
176
- BCP_RELEASE
177
- NODE_ENV
178
- BCP_SHUTDOWN_TIMEOUT_MS
162
+ application setup
163
+ plugins
164
+ resources
165
+ application start
179
166
  ```
180
167
 
181
- ## Stability baseline BCP 0.2.19
168
+ Shutdown reverses resource dependencies before disposing the application.
182
169
 
183
- BCP `0.2.19` freezes the documented `0.2.x` public `bcp/*` entrypoints and prepared package-resolution contract before the next `0.3.0` baseline.
170
+ ## API baseline
184
171
 
185
- Application code should import documented public entrypoints and avoid private framework `packages/*` paths. This keeps applications compatible with the frozen `0.2.19` surface.
172
+ BCP `0.3.0` preserves the public `0.2.19` entrypoints and adds `bcp/application`. Application code should import documented public `bcp/*` entrypoints and avoid private framework `packages/*` paths.
186
173
 
187
174
  ## Production build
188
175
 
@@ -199,7 +186,7 @@ npm run package
199
186
 
200
187
  BCP excludes project `.env` files and application `devDependencies` from the deployment package. Supply secrets through the deployment environment.
201
188
 
202
- BCP 0.2.19 preserves compiled `.mjs` runtimes for the main server entrypoints, including config, auth, observability, deployment, server and middleware.
189
+ BCP 0.3.0 adds compiled `application.mjs` to the main compiled server-runtime entrypoints.
203
190
 
204
191
  ## Direct CLI usage
205
192