@chidchanun/bcp 0.2.1 → 0.2.2

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
@@ -2,36 +2,27 @@
2
2
 
3
3
  BCP Framework is a React full-stack framework for file-based routing, SSR, SPA navigation, server data loading, guarded application flows, API routes, authentication, database access, validation, uploads, storage and standalone Node.js production deployment.
4
4
 
5
- > **Development target:** `0.2.1Documentation Platform`
5
+ > **Development target:** `0.2.2Configuration & Environment v2`
6
6
  >
7
- > `0.2.1` is an unreleased development target until local validation, RC checks, tagging and npm publication complete.
7
+ > `0.2.2` is an unreleased development target until local validation, RC checks, tagging and npm publication complete.
8
8
 
9
9
  ## 0.2 platform
10
10
 
11
- `0.2.0` established the Framework Platform baseline. `0.2.1` builds a machine-readable Documentation Platform on top of that baseline without intentionally removing application runtime public entrypoints.
11
+ `0.2.0` established the Framework Platform baseline, `0.2.1` added the Documentation Platform, and `0.2.2` adds typed application environment validation and configuration diagnostics without intentionally removing public application entrypoints.
12
12
 
13
- The authoritative platform/documentation contracts are:
13
+ Machine-readable platform contracts:
14
14
 
15
15
  ```text
16
16
  docs/platform-manifest.json
17
- -> runtime target, public entrypoints, capabilities and compatibility
17
+ -> runtime target, capabilities and compatibility
18
18
 
19
19
  docs/docs-web-manifest.json
20
- -> docs sections, routes, Markdown sources and releases
20
+ -> documentation navigation, routes and releases
21
21
 
22
22
  docs/api-manifest.json
23
- -> public package entrypoints, source ownership and guide routes
23
+ -> public package entrypoints and guide ownership
24
24
  ```
25
25
 
26
- Authored documentation remains under `docs/*.md`.
27
-
28
- Read more:
29
-
30
- - [Framework Platform Contract](docs/platform-contract.md)
31
- - [Documentation Platform](docs/documentation-platform.md)
32
- - [API Reference](docs/api-reference.md)
33
- - [Migrating to 0.2.x](docs/migration-0.2.md)
34
-
35
26
  ## Current capabilities
36
27
 
37
28
  | Area | Capability |
@@ -50,9 +41,10 @@ Read more:
50
41
  | Uploads | Buffered multipart helpers and production multipart streaming |
51
42
  | Storage | Local + S3-compatible storage, streaming, list/copy/move, metadata, bulk delete and signed URLs |
52
43
  | Caching | Response cache and revalidation primitives |
44
+ | Configuration | Typed `bcp.config.*`, optional `bcp.environment.*`, startup diagnostics and `bcp config check` |
53
45
  | Developer tools | Generators, Doctor/Inspect v2, updater, route inspection and project metadata |
54
46
  | Production | Standalone Node.js build, hardening gateway, graceful shutdown, trusted proxy controls and HTTP timeouts |
55
- | Documentation | Manifest-driven docs navigation, platform metadata and public API entrypoint reference |
47
+ | Documentation | Manifest-driven docs navigation, platform metadata and public API reference |
56
48
 
57
49
  ## Requirements
58
50
 
@@ -60,7 +52,7 @@ Read more:
60
52
  - React `19`
61
53
  - npm
62
54
 
63
- Database framework primitives currently target MySQL. `create-bcp-app` can also scaffold PostgreSQL, SQLite and MongoDB application helpers.
55
+ Database framework primitives currently target MySQL.
64
56
 
65
57
  ## Quick start
66
58
 
@@ -80,45 +72,161 @@ Generated projects normally keep one framework dependency key:
80
72
  }
81
73
  ```
82
74
 
83
- Do not install both `bcp` and a second direct `@chidchanun/bcp` dependency in the same application; duplicate framework copies can create separate React/framework contexts.
75
+ Do not install both `bcp` and a second direct `@chidchanun/bcp` dependency in the same application.
84
76
 
85
- ## Application model
77
+ ## Configuration
78
+
79
+ Framework configuration stays in one of:
86
80
 
87
81
  ```text
88
- Browser
89
-
90
- Security / middleware / cache
91
-
92
- Route guard
93
-
94
- Loader / action / API route
95
-
96
- React SSR
97
-
98
- Hydration / SPA navigation
82
+ bcp.config.ts
83
+ bcp.config.mts
84
+ bcp.config.js
85
+ bcp.config.mjs
99
86
  ```
100
87
 
101
- Typical route structure:
88
+ Example:
89
+
90
+ ```ts
91
+ import {
92
+ defineConfig,
93
+ } from "bcp/config";
94
+
95
+ export default defineConfig({
96
+ server: {
97
+ port: 3000,
98
+ hostname: "0.0.0.0",
99
+ },
100
+ build: {
101
+ minify: true,
102
+ sourceMaps: false,
103
+ },
104
+ security: {
105
+ poweredByHeader: false,
106
+ },
107
+ });
108
+ ```
109
+
110
+ Configuration precedence remains:
102
111
 
103
112
  ```text
104
- app/
105
- ├─ layout.tsx
106
- ├─ page.tsx
107
- ├─ dashboard/
108
- │ ├─ guard.ts
109
- │ └─ users/
110
- │ └─ [id]/
111
- │ ├─ loader.ts
112
- │ ├─ actions.ts
113
- │ └─ page.tsx
114
- └─ api/
115
- └─ upload/
116
- └─ route.ts
113
+ CLI override
114
+
115
+ BCP_* environment
116
+
117
+ bcp.config.*
118
+
119
+ framework defaults
120
+ ```
121
+
122
+ Read more: [Configuration](docs/configuration.md)
123
+
124
+ ## Environment Validation — 0.2.2
125
+
126
+ Application-specific variables can be declared in an optional environment schema:
127
+
128
+ ```text
129
+ bcp.environment.ts
117
130
  ```
118
131
 
132
+ Example:
133
+
134
+ ```ts
135
+ import {
136
+ defineEnvironment,
137
+ } from "bcp/config";
138
+
139
+ export default defineEnvironment({
140
+ DB_HOST: {
141
+ type: "string",
142
+ required: true,
143
+ },
144
+
145
+ DB_PORT: {
146
+ type: "number",
147
+ default: 3306,
148
+ min: 1,
149
+ max: 65535,
150
+ },
151
+
152
+ SESSION_SECRET: {
153
+ type: "string",
154
+ required: true,
155
+ secret: true,
156
+ minLength: 32,
157
+ },
158
+
159
+ FEATURE_ENABLED: {
160
+ type: "boolean",
161
+ default: false,
162
+ },
163
+
164
+ BCP_PUBLIC_API_URL: {
165
+ type: "url",
166
+ required: true,
167
+ },
168
+ });
169
+ ```
170
+
171
+ Supported types:
172
+
173
+ ```text
174
+ string
175
+ number
176
+ boolean
177
+ url
178
+ ```
179
+
180
+ Validate the current project:
181
+
182
+ ```bash
183
+ bcp config check
184
+ ```
185
+
186
+ JSON diagnostics:
187
+
188
+ ```bash
189
+ bcp config check --json
190
+ ```
191
+
192
+ On Windows, where Microsoft SQL Server may provide another `bcp.exe`, prefer:
193
+
194
+ ```powershell
195
+ npm exec -- bcp-framework config check
196
+ npm exec -- bcp-framework config check --json
197
+ ```
198
+
199
+ `bcp dev` and `bcp build` also validate `bcp.environment.*` before startup/build. Invalid required values fail early.
200
+
201
+ The development supervisor watches:
202
+
203
+ ```text
204
+ .env*
205
+ bcp.config.*
206
+ bcp.environment.*
207
+ ```
208
+
209
+ and restarts the worker when one of those files changes.
210
+
211
+ ### Secret safety
212
+
213
+ Variables beginning with `BCP_PUBLIC_` can be embedded into browser bundles.
214
+
215
+ A variable marked:
216
+
217
+ ```ts
218
+ secret: true
219
+ ```
220
+
221
+ must not use `BCP_PUBLIC_`. BCP reports this as a configuration error.
222
+
223
+ `secret: true` is tooling metadata; it does not encrypt environment values.
224
+
225
+ Read more: [Environment Validation](docs/environment-validation.md)
226
+
119
227
  ## Public entrypoints
120
228
 
121
- The `0.2.x` platform contract recognizes:
229
+ The current `0.2.x` platform contract recognizes:
122
230
 
123
231
  ```text
124
232
  bcp
@@ -134,15 +242,14 @@ bcp/server-only
134
242
  bcp/middleware
135
243
  ```
136
244
 
137
- Application code should use these public package entrypoints rather than importing internal framework files under `packages/`.
245
+ Application code should use public entrypoints instead of importing framework internals under `packages/`.
138
246
 
139
- The public list is validated in both:
247
+ See:
140
248
 
249
+ - [API Reference](docs/api-reference.md)
141
250
  - [Platform Manifest](docs/platform-manifest.json)
142
251
  - [API Manifest](docs/api-manifest.json)
143
252
 
144
- See [API Reference](docs/api-reference.md) for ownership and related guides.
145
-
146
253
  ## CLI
147
254
 
148
255
  Core commands:
@@ -153,6 +260,7 @@ bcp build
153
260
  bcp start
154
261
  bcp routes
155
262
  bcp update
263
+ bcp config check
156
264
  bcp doctor
157
265
  bcp inspect
158
266
  bcp version
@@ -178,112 +286,48 @@ bcp generate migration create_users
178
286
 
179
287
  Page/API/middleware generators require `--force` before replacing an existing scaffold target.
180
288
 
181
- On Windows, Microsoft SQL Server may provide another `bcp.exe`. For direct PowerShell usage prefer the project-local collision-free alias:
182
-
183
- ```powershell
184
- npm exec -- bcp-framework doctor
185
- npm exec -- bcp-framework inspect
186
- npm exec -- bcp-framework routes
187
- npm exec -- bcp-framework generate page dashboard/users
188
- ```
189
-
190
- ## Routing, loaders, guards and actions
191
-
192
- BCP discovers pages from `app/**/page.tsx` and API handlers from `app/**/route.ts`.
193
-
194
- ```text
195
- app/page.tsx /
196
- app/users/[id]/page.tsx /users/:id
197
- app/docs/[...slug]/page.tsx /docs/*
198
- app/catalog/[[...slug]]/page.tsx /catalog and /catalog/*
199
- app/(admin)/settings/page.tsx /settings
200
- app/api/users/route.ts /api/users
201
- ```
202
-
203
- Route-owned server features stay colocated:
289
+ ## Application model
204
290
 
205
291
  ```text
206
- page.tsx
207
- loader.ts
208
- guard.ts
209
- actions.ts
210
- ```
211
-
212
- Guides:
213
-
214
- - [Routing](docs/routing.md)
215
- - [Server Data Loaders](docs/server-data-loaders.md)
216
- - [Route Guards](docs/route-guards.md)
217
- - [Form Actions](docs/form-actions.md)
218
-
219
- ## Authentication and server APIs
220
-
221
- ```ts
222
- import {
223
- auth,
224
- requireAuth,
225
- requireRole,
226
- } from "bcp/auth";
227
-
228
- import {
229
- cookies,
230
- headers,
231
- requestId,
232
- requestMethod,
233
- requestUrl,
234
- } from "bcp/server";
235
- ```
236
-
237
- Guides:
238
-
239
- - [Authentication](docs/authentication.md)
240
- - [JWT Sessions](docs/session-auth.md)
241
- - [Server Request APIs](docs/server-request-apis.md)
242
-
243
- ## Database
244
-
245
- ```ts
246
- import {
247
- db,
248
- } from "bcp/database";
292
+ Browser
293
+
294
+ Security / middleware / cache
295
+
296
+ Route guard
297
+
298
+ Loader / action / API route
299
+
300
+ React SSR
301
+
302
+ Hydration / SPA navigation
249
303
  ```
250
304
 
251
- BCP's database layer includes lazy MySQL pool creation, query/execute helpers, transactions and migrations.
252
-
253
- Guides:
254
-
255
- - [Database](docs/database.md)
256
- - [Database Migrations](docs/database-migrations.md)
257
-
258
- ## Storage and uploads
259
-
260
- `create-bcp-app` can scaffold:
305
+ Typical route structure:
261
306
 
262
307
  ```text
263
- None
264
- Local Server
265
- Amazon S3
266
- Cloudflare R2
308
+ app/
309
+ ├─ layout.tsx
310
+ ├─ page.tsx
311
+ ├─ dashboard/
312
+ │ ├─ guard.ts
313
+ │ └─ users/
314
+ │ └─ [id]/
315
+ │ ├─ loader.ts
316
+ │ ├─ actions.ts
317
+ │ └─ page.tsx
318
+ └─ api/
319
+ └─ upload/
320
+ └─ route.ts
267
321
  ```
268
322
 
269
- BCP storage supports local and S3-compatible adapters, streaming reads/writes, ranges, object listing, copy/move, portable metadata, bulk deletion and S3 signed URLs.
270
-
271
- Guides:
272
-
273
- - [File Upload](docs/file-upload.md)
274
- - [Storage & File Delivery](docs/storage.md)
275
- - [Storage Ecosystem](docs/storage-ecosystem.md)
276
- - [S3-Compatible Storage](docs/s3-storage.md)
277
-
278
323
  ## Production build
279
324
 
280
- Build:
281
-
282
325
  ```bash
283
326
  npm run build
327
+ npm run start
284
328
  ```
285
329
 
286
- Output:
330
+ Standalone output:
287
331
 
288
332
  ```text
289
333
  .bcp-framework/build/
@@ -293,81 +337,37 @@ Output:
293
337
  └─ server.mjs
294
338
  ```
295
339
 
296
- Run:
297
-
298
- ```bash
299
- npm run start
300
- ```
301
-
302
- The `0.2.x` production target remains:
340
+ The current production target remains:
303
341
 
304
342
  ```text
305
343
  standalone-node
306
344
  ```
307
345
 
308
- Native `.exe`, desktop and mobile compilation are future roadmap work and are not part of the current platform contract.
346
+ Native `.exe`, desktop and mobile compilation remain later roadmap work.
309
347
 
310
- Production hardening supports configurable request/header/keep-alive/shutdown timeouts, trusted-proxy handling and `SIGTERM` / `SIGINT` graceful shutdown.
348
+ Production hardening includes configurable request/header/keep-alive/shutdown timeouts, trusted-proxy handling and graceful `SIGTERM` / `SIGINT` shutdown.
311
349
 
312
350
  Read more: [Production Hardening](docs/production-hardening.md)
313
351
 
314
- ## Documentation Platform — 0.2.1
352
+ ## Documentation Platform
315
353
 
316
- `0.2.1` makes the framework repository directly consumable by `bcp-docs-web`.
354
+ The framework repository is the documentation source of truth.
317
355
 
318
- Recommended website flow:
356
+ `bcp-docs-web` consumes:
319
357
 
320
358
  ```text
321
- selected framework ref
322
-
323
359
  docs/docs-web-manifest.json
324
360
  docs/platform-manifest.json
325
361
  docs/api-manifest.json
326
-
327
- validate version + release state + public entrypoints
328
-
329
- load referenced Markdown
330
-
331
- sync CMS/search/navigation
332
-
333
- render bcp-docs-web
334
- ```
335
-
336
- `bcp-docs-web` should not maintain a second hard-coded framework page list.
337
-
338
- The manifests provide:
339
-
340
- ```text
341
- sidebar/category order
342
- website routes
343
- Markdown sources
344
- version + release state
345
- release routes
346
- public package entrypoints
347
- API guide ownership
348
362
  ```
349
363
 
350
- The docs sync may target a release ref for historical content:
351
-
352
- ```powershell
353
- npm run docs:sync -- --ref=v0.2.0
354
- ```
364
+ The manifests provide navigation order, routes, Markdown sources, version/release state, public entrypoints and API guide ownership.
355
365
 
356
366
  Read more:
357
367
 
358
- - [Documentation Platform](docs/documentation-platform.md)
359
368
  - [Documentation Source Map](docs/README.md)
360
- - [Docs-Web Manifest](docs/docs-web-manifest.json)
361
- - [Platform Manifest](docs/platform-manifest.json)
362
- - [API Manifest](docs/api-manifest.json)
363
-
364
- ## Updating from 0.1.x / 0.2.x
365
-
366
- `0.2.1` does not intentionally remove application public entrypoints from the `0.2.0` baseline.
367
-
368
- After upgrading, always rebuild the standalone artifact instead of reusing `.bcp-framework/build` from another framework version.
369
-
370
- Read more: [Migrating to 0.2.x](docs/migration-0.2.md)
369
+ - [Documentation Platform](docs/documentation-platform.md)
370
+ - [Environment Validation](docs/environment-validation.md)
371
371
 
372
372
  ## Release validation
373
373
 
@@ -383,9 +383,9 @@ npm run test:e2e
383
383
  npm run rc:check
384
384
  ```
385
385
 
386
- `0.2.1` adds Documentation Platform unit/package checks that validate manifest version parity, docs source existence, API/public-entrypoint parity and prepared npm documentation artifacts.
386
+ `0.2.2` adds Configuration & Environment v2 unit/package checks covering schema parsing, project schema loading, diagnostics, CLI parsing, public `bcp/config` exports and packed-package files.
387
387
 
388
- Do not tag or publish a release until the final release commit passes the complete RC sequence.
388
+ Do not tag or publish until the final release commit passes the complete RC sequence.
389
389
 
390
390
  ## Release history
391
391
 
@@ -399,23 +399,25 @@ Do not tag or publish a release until the final release commit passes the comple
399
399
  | `0.1.29` | Developer Experience |
400
400
  | `0.2.0` | Framework Platform |
401
401
  | `0.2.1` | Documentation Platform |
402
+ | `0.2.2` | Configuration & Environment v2 |
402
403
 
403
404
  ## Roadmap
404
405
 
405
406
  Next planned milestone:
406
407
 
407
408
  ```text
408
- 0.2.2Configuration & Environment v2
409
+ 0.2.3Database Platform v2
409
410
  ```
410
411
 
411
- Focus:
412
+ Planned focus:
412
413
 
413
- - typed production configuration improvements,
414
- - environment validation,
415
- - startup configuration diagnostics,
416
- - configuration schema/inspection tooling.
414
+ - database adapter contract,
415
+ - PostgreSQL support,
416
+ - SQLite support,
417
+ - connection lifecycle improvements,
418
+ - migration consistency across providers.
417
419
 
418
- Application packaging (`bcp package`, native executable experiments) remains later `0.2.x` roadmap work.
420
+ Application packaging remains later `0.2.x` roadmap work.
419
421
 
420
422
  ## License
421
423