create-bcp-app 0.2.18 → 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.18` 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.18",
74
+ "frameworkPackage": "npm:@chidchanun/bcp@0.3.0",
75
75
  "createdWith": {
76
76
  "package": "create-bcp-app",
77
- "version": "0.2.18"
77
+ "version": "0.3.0"
78
78
  },
79
79
  "packageManager": "npm",
80
80
  "presets": {
@@ -88,6 +88,59 @@ Example for the `0.2.18` 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,91 +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
- ```
221
+ Tracing supports W3C `traceparent`, correlation IDs, request middleware, explicit carriers and provider-neutral exporters.
184
222
 
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
- ```
223
+ ## Deployment Platform v2
251
224
 
252
- Default signals are `SIGTERM` and `SIGINT`.
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.
253
226
 
254
227
  ## Application packaging
255
228
 
@@ -260,7 +233,7 @@ npm run package
260
233
 
261
234
  The deployment package excludes application `devDependencies` and project `.env` values. Supply secrets through the deployment environment.
262
235
 
263
- BCP `0.2.18` prepared framework packages use compiled ESM runtime files 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.
264
237
 
265
238
  ## Project generators
266
239
 
@@ -288,5 +261,5 @@ npm run generate -- migration create_users
288
261
  For prerelease/local package verification:
289
262
 
290
263
  ```bash
291
- npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.2.18.tgz
264
+ npx create-bcp-app my-app --bcp file:../chidchanun-bcp-0.3.0.tgz
292
265
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-bcp-app",
3
- "version": "0.2.18",
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,81 +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
- ```
155
+ ## Deployment lifecycle
147
156
 
148
- Readiness endpoint:
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.
149
158
 
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:
159
+ Application Platform startup order is:
163
160
 
164
- ```ts
165
- const removeSignals =
166
- deployment.installSignalHandlers();
161
+ ```text
162
+ application setup
163
+ plugins
164
+ resources
165
+ application start
167
166
  ```
168
167
 
169
- Default signals are `SIGTERM` and `SIGINT`.
168
+ Shutdown reverses resource dependencies before disposing the application.
170
169
 
171
- Deployment identity can be supplied through:
170
+ ## API baseline
172
171
 
173
- ```text
174
- BCP_DEPLOYMENT_ID
175
- BCP_INSTANCE_ID
176
- BCP_RELEASE
177
- NODE_ENV
178
- BCP_SHUTDOWN_TIMEOUT_MS
179
- ```
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.
180
173
 
181
174
  ## Production build
182
175
 
@@ -193,7 +186,7 @@ npm run package
193
186
 
194
187
  BCP excludes project `.env` files and application `devDependencies` from the deployment package. Supply secrets through the deployment environment.
195
188
 
196
- BCP 0.2.18 prepared framework packages use 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.
197
190
 
198
191
  ## Direct CLI usage
199
192