@chidchanun/bcp 0.1.24 → 0.1.26
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 +587 -202
- package/docs/README.md +278 -86
- package/docs/file-upload.md +194 -32
- package/docs/releases/0.1.25.md +132 -0
- package/docs/releases/0.1.26.md +281 -0
- package/docs/s3-storage.md +276 -0
- package/docs/storage.md +401 -0
- package/package.json +5 -2
- package/packages/client/src/database.mjs +236 -0
- package/packages/client/src/server.ts +46 -0
- package/packages/server/src/file-delivery.ts +613 -0
- package/packages/server/src/storage-s3.ts +1159 -0
- package/packages/server/src/storage.ts +1515 -0
- package/packages/server/src/upload-stream.ts +846 -0
package/docs/README.md
CHANGED
|
@@ -1,89 +1,169 @@
|
|
|
1
1
|
# BCP Framework Documentation Source
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The `docs/` directory is the documentation source of truth for BCP Framework and is intentionally organized for the future **`bcp-docs-web`** website.
|
|
4
4
|
|
|
5
|
-
> Documentation target
|
|
5
|
+
> **Documentation target:** BCP Framework `0.1.26`
|
|
6
|
+
>
|
|
7
|
+
> **Release state:** release-candidate source. Do not label `0.1.26` as published until RC validation and npm publication complete.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
## Documentation flow
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
```text
|
|
12
|
+
BCP Framework source/tests
|
|
13
|
+
↓
|
|
14
|
+
docs/
|
|
15
|
+
↓
|
|
16
|
+
bcp-docs-web
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
Framework source and tests are authoritative for behavior. Markdown under `docs/` is the authored documentation layer. `bcp-docs-web` should render, organize and search these sources instead of becoming a competing source of truth.
|
|
20
|
+
|
|
21
|
+
## Update rule
|
|
22
|
+
|
|
23
|
+
When framework behavior changes:
|
|
24
|
+
|
|
25
|
+
1. Update framework source.
|
|
26
|
+
2. Add/update regression tests.
|
|
27
|
+
3. Update the matching file under `docs/`.
|
|
28
|
+
4. Update `docs/releases/<version>.md`.
|
|
29
|
+
5. Change release state to published only after npm publication succeeds.
|
|
30
|
+
|
|
31
|
+
## Recommended `bcp-docs-web` navigation
|
|
32
|
+
|
|
33
|
+
```text
|
|
34
|
+
Getting Started
|
|
35
|
+
Routing & Data
|
|
36
|
+
Authentication
|
|
37
|
+
Database
|
|
38
|
+
Runtime & Infrastructure
|
|
39
|
+
Storage & Uploads
|
|
40
|
+
API Reference
|
|
41
|
+
Releases
|
|
42
|
+
```
|
|
10
43
|
|
|
11
44
|
### Getting Started
|
|
12
45
|
|
|
13
|
-
|
|
|
46
|
+
| Website route | Markdown source | Purpose |
|
|
14
47
|
| --- | --- | --- |
|
|
15
48
|
| `/docs/getting-started` | `getting-started.md` | Create and run a BCP application |
|
|
16
|
-
| `/docs/configuration` | `configuration.md` | Framework configuration |
|
|
49
|
+
| `/docs/configuration` | `configuration.md` | Framework configuration/environment |
|
|
17
50
|
| `/docs/application-modules` | `application-modules.md` | Client/server boundaries |
|
|
18
|
-
| `/docs/deployment` | `deployment.md` |
|
|
51
|
+
| `/docs/deployment` | `deployment.md` | Standalone production deployment |
|
|
19
52
|
| `/docs/updating` | `updating.md` | Framework upgrades |
|
|
20
53
|
|
|
21
|
-
### Routing
|
|
54
|
+
### Routing & Data
|
|
22
55
|
|
|
23
|
-
|
|
|
56
|
+
| Website route | Markdown source | Purpose |
|
|
24
57
|
| --- | --- | --- |
|
|
25
|
-
| `/docs/routing` | `routing.md` | File-based routing |
|
|
58
|
+
| `/docs/routing` | `routing.md` | File-based page/API routing |
|
|
26
59
|
| `/docs/server-data-loaders` | `server-data-loaders.md` | Server-side page data |
|
|
27
60
|
| `/docs/route-guards` | `route-guards.md` | Scoped route authorization |
|
|
28
61
|
| `/docs/form-actions` | `form-actions.md` | Server mutations/forms |
|
|
29
62
|
| `/docs/server-request-apis` | `server-request-apis.md` | Request/cookie/response APIs |
|
|
30
63
|
| `/docs/validation` | `validation.md` | Typed validation |
|
|
31
64
|
| `/docs/error-handling` | `error-handling.md` | Structured HTTP errors |
|
|
32
|
-
| `/docs/file-upload` | `file-upload.md` | Multipart parsing, validation and local file storage |
|
|
33
65
|
|
|
34
66
|
### Authentication
|
|
35
67
|
|
|
36
|
-
|
|
|
68
|
+
| Website route | Markdown source | Purpose |
|
|
37
69
|
| --- | --- | --- |
|
|
38
70
|
| `/docs/authentication` | `authentication.md` | Authentication Core |
|
|
39
|
-
| `/docs/auth-route-guards` | `auth-route-guards.md` | Auth-aware guards |
|
|
71
|
+
| `/docs/auth-route-guards` | `auth-route-guards.md` | Auth-aware route guards |
|
|
40
72
|
| `/docs/session-auth` | `session-auth.md` | JWT cookie sessions |
|
|
41
73
|
|
|
42
74
|
### Database
|
|
43
75
|
|
|
44
|
-
|
|
|
76
|
+
| Website route | Markdown source | Purpose |
|
|
45
77
|
| --- | --- | --- |
|
|
46
78
|
| `/docs/database` | `database.md` | MySQL database primitives |
|
|
47
|
-
| `/docs/database-migrations` | `database-migrations.md` | Migration CLI
|
|
79
|
+
| `/docs/database-migrations` | `database-migrations.md` | Migration CLI/files |
|
|
48
80
|
|
|
49
|
-
### Runtime
|
|
81
|
+
### Runtime & Infrastructure
|
|
50
82
|
|
|
51
|
-
|
|
|
83
|
+
| Website route | Markdown source | Purpose |
|
|
52
84
|
| --- | --- | --- |
|
|
53
85
|
| `/docs/middleware` | `middleware.md` | Middleware System v2 |
|
|
54
86
|
| `/docs/hydration` | `hydration.md` | SSR/client hydration parity |
|
|
55
|
-
| `/docs/developer-tools` | `developer-tools.md` | `doctor` / `inspect`
|
|
56
|
-
| `/docs/development-logging` | `development-logging.md` |
|
|
87
|
+
| `/docs/developer-tools` | `developer-tools.md` | `doctor` / `inspect` |
|
|
88
|
+
| `/docs/development-logging` | `development-logging.md` | Logging/observability |
|
|
57
89
|
| `/docs/caching` | `caching.md` | Cache/revalidation |
|
|
58
|
-
| `/docs/security` | `security.md` | Security
|
|
90
|
+
| `/docs/security` | `security.md` | Security/body limits |
|
|
91
|
+
|
|
92
|
+
### Storage & Uploads
|
|
93
|
+
|
|
94
|
+
| Website route | Markdown source | Purpose |
|
|
95
|
+
| --- | --- | --- |
|
|
96
|
+
| `/docs/file-upload` | `file-upload.md` | Buffered + streaming multipart uploads |
|
|
97
|
+
| `/docs/storage` | `storage.md` | StorageAdapter, streaming and file delivery |
|
|
98
|
+
| `/docs/s3-storage` | `s3-storage.md` | S3-compatible adapter/configuration |
|
|
99
|
+
|
|
100
|
+
## API Reference ownership
|
|
101
|
+
|
|
102
|
+
Recommended entrypoint groups:
|
|
103
|
+
|
|
104
|
+
```text
|
|
105
|
+
bcp
|
|
106
|
+
bcp/server
|
|
107
|
+
bcp/auth
|
|
108
|
+
bcp/database
|
|
109
|
+
bcp/validation
|
|
110
|
+
bcp/error
|
|
111
|
+
bcp/cache
|
|
112
|
+
bcp/config
|
|
113
|
+
bcp/middleware
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
| Entrypoint | Primary guide |
|
|
117
|
+
| --- | --- |
|
|
118
|
+
| `bcp` | `routing.md`, `server-data-loaders.md`, `form-actions.md` |
|
|
119
|
+
| `bcp/server` | `server-request-apis.md`, `file-upload.md`, `storage.md`, `s3-storage.md`, `development-logging.md` |
|
|
120
|
+
| `bcp/auth` | `authentication.md`, `auth-route-guards.md` |
|
|
121
|
+
| `bcp/database` | `database.md`, `database-migrations.md` |
|
|
122
|
+
| `bcp/validation` | `validation.md` |
|
|
123
|
+
| `bcp/error` | `error-handling.md` |
|
|
124
|
+
| `bcp/cache` | `caching.md` |
|
|
125
|
+
| `bcp/config` | `configuration.md` |
|
|
126
|
+
| `bcp/middleware` | `middleware.md` |
|
|
59
127
|
|
|
60
128
|
## Current capability groups
|
|
61
129
|
|
|
62
130
|
### Application
|
|
63
131
|
|
|
64
|
-
- React SSR
|
|
132
|
+
- React SSR/hydration
|
|
65
133
|
- file-based page/API routing
|
|
66
|
-
- dynamic/catch-all routes
|
|
67
|
-
- layouts
|
|
134
|
+
- static/dynamic/catch-all/optional-catch-all routes
|
|
135
|
+
- route groups/layouts/metadata
|
|
68
136
|
- SPA navigation
|
|
69
|
-
- loaders
|
|
137
|
+
- loaders/guards/form actions
|
|
70
138
|
- client islands / partial hydration
|
|
71
|
-
- Fast Refresh
|
|
139
|
+
- Fast Refresh
|
|
72
140
|
|
|
73
141
|
### Server
|
|
74
142
|
|
|
75
|
-
- request-scoped
|
|
76
|
-
-
|
|
77
|
-
- JWT sessions and authentication
|
|
143
|
+
- request-scoped APIs/cookies/redirects/request IDs
|
|
144
|
+
- JWT sessions/authentication
|
|
78
145
|
- Middleware System v2
|
|
79
|
-
-
|
|
80
|
-
- structured logging
|
|
81
|
-
-
|
|
146
|
+
- validation/structured errors
|
|
147
|
+
- structured logging
|
|
148
|
+
- response caching/security gateway
|
|
149
|
+
|
|
150
|
+
### Storage & Uploads
|
|
151
|
+
|
|
152
|
+
- buffered multipart `FormData` upload APIs
|
|
153
|
+
- production streaming multipart upload (`storeMultipartFile()`)
|
|
154
|
+
- `StorageAdapter` contract
|
|
155
|
+
- local filesystem adapter
|
|
156
|
+
- S3-compatible adapter
|
|
157
|
+
- streaming reads/writes
|
|
158
|
+
- byte ranges
|
|
159
|
+
- ETag/Last-Modified file delivery
|
|
160
|
+
- upload/storage limits and abort cleanup
|
|
82
161
|
|
|
83
162
|
### Database
|
|
84
163
|
|
|
85
164
|
- `bcp/database`
|
|
86
|
-
- MySQL pool
|
|
165
|
+
- lazy MySQL pool
|
|
166
|
+
- prepared execution/query helpers
|
|
87
167
|
- transactions
|
|
88
168
|
- migrations/status/rollback
|
|
89
169
|
|
|
@@ -93,69 +173,70 @@ When framework behavior changes, update framework source/tests first, then the m
|
|
|
93
173
|
- `bcp update`
|
|
94
174
|
- `bcp doctor`
|
|
95
175
|
- `bcp inspect`
|
|
96
|
-
- `bcp-framework`
|
|
176
|
+
- Windows-safe `bcp-framework` alias
|
|
97
177
|
- standalone production build
|
|
98
|
-
-
|
|
178
|
+
- unit/integration/E2E/package/RC checks
|
|
99
179
|
|
|
100
|
-
## BCP 0.1.
|
|
180
|
+
## BCP 0.1.26 documentation focus
|
|
101
181
|
|
|
102
|
-
###
|
|
182
|
+
### Storage streaming
|
|
103
183
|
|
|
104
|
-
|
|
184
|
+
Public additions include:
|
|
105
185
|
|
|
106
186
|
```ts
|
|
107
187
|
import {
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
validateUploadedFile,
|
|
112
|
-
saveUploadedFile,
|
|
113
|
-
sanitizeUploadFileName,
|
|
114
|
-
UploadError,
|
|
188
|
+
getStorageCapabilities,
|
|
189
|
+
putStorageStream,
|
|
190
|
+
readStorageStream,
|
|
115
191
|
} from "bcp/server";
|
|
116
192
|
```
|
|
117
193
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
- `server.bodyLimit` / `BCP_BODY_LIMIT` is the outer request-size limit enforced by the security gateway.
|
|
121
|
-
- multipart and individual file limits can be stricter than the global body limit.
|
|
122
|
-
- MIME type and extension are metadata checks, not file-signature verification.
|
|
123
|
-
- default storage names are UUID based.
|
|
124
|
-
- existing files are not overwritten unless explicitly requested.
|
|
125
|
-
- saved metadata includes SHA-256 checksum.
|
|
126
|
-
- local filesystem storage is the initial foundation; distributed/object storage requires a later adapter layer.
|
|
127
|
-
|
|
128
|
-
See `file-upload.md`.
|
|
129
|
-
|
|
130
|
-
### Dev route/client bundle synchronization
|
|
194
|
+
Streaming methods remain optional on custom adapters for `0.1.25` compatibility.
|
|
131
195
|
|
|
132
|
-
|
|
196
|
+
### S3-compatible storage
|
|
133
197
|
|
|
134
|
-
```
|
|
135
|
-
|
|
198
|
+
```ts
|
|
199
|
+
import {
|
|
200
|
+
createS3Storage,
|
|
201
|
+
} from "bcp/server";
|
|
136
202
|
```
|
|
137
203
|
|
|
138
|
-
|
|
204
|
+
Document:
|
|
139
205
|
|
|
140
|
-
|
|
206
|
+
- bucket/region/endpoint setup,
|
|
207
|
+
- optional explicit credentials,
|
|
208
|
+
- AWS default credential chain behavior,
|
|
209
|
+
- `forcePathStyle` for compatible services such as MinIO,
|
|
210
|
+
- prefix handling,
|
|
211
|
+
- multipart streaming,
|
|
212
|
+
- ranges/ETag metadata,
|
|
213
|
+
- overwrite limitations for concurrent multipart writers,
|
|
214
|
+
- server-only credential/security requirements.
|
|
141
215
|
|
|
142
|
-
|
|
216
|
+
See `s3-storage.md`.
|
|
143
217
|
|
|
144
|
-
|
|
145
|
-
- request-scoped `requestLogger()`
|
|
146
|
-
- log levels and JSON format
|
|
147
|
-
- `X-Request-Id` helpers
|
|
148
|
-
- structured development request/SSR timing
|
|
218
|
+
### Production multipart streaming
|
|
149
219
|
|
|
150
|
-
|
|
220
|
+
```ts
|
|
221
|
+
import {
|
|
222
|
+
storeMultipartFile,
|
|
223
|
+
} from "bcp/server";
|
|
224
|
+
```
|
|
151
225
|
|
|
152
|
-
|
|
226
|
+
Document:
|
|
153
227
|
|
|
154
|
-
|
|
228
|
+
- one named streamed file field per operation,
|
|
229
|
+
- total request limit,
|
|
230
|
+
- per-file limit,
|
|
231
|
+
- MIME/extension validation,
|
|
232
|
+
- fixed/callback storage keys,
|
|
233
|
+
- AbortSignal behavior,
|
|
234
|
+
- direct local/S3 streaming,
|
|
235
|
+
- difference from `request.formData()` / buffered APIs.
|
|
155
236
|
|
|
156
|
-
See `
|
|
237
|
+
See `file-upload.md`.
|
|
157
238
|
|
|
158
|
-
##
|
|
239
|
+
## CLI commands
|
|
159
240
|
|
|
160
241
|
```bash
|
|
161
242
|
bcp dev
|
|
@@ -175,40 +256,151 @@ bcp db status
|
|
|
175
256
|
bcp db rollback
|
|
176
257
|
```
|
|
177
258
|
|
|
178
|
-
On Windows
|
|
259
|
+
On Windows, direct project-local commands should prefer:
|
|
179
260
|
|
|
180
261
|
```powershell
|
|
181
|
-
bcp-framework doctor
|
|
182
|
-
bcp-framework inspect
|
|
183
|
-
bcp-framework dev
|
|
262
|
+
npm exec -- bcp-framework doctor
|
|
263
|
+
npm exec -- bcp-framework inspect
|
|
264
|
+
npm exec -- bcp-framework dev
|
|
265
|
+
npm exec -- bcp-framework build
|
|
184
266
|
```
|
|
185
267
|
|
|
268
|
+
Inside npm scripts, `bcp` is safe because npm prepends `node_modules/.bin` to `PATH`.
|
|
269
|
+
|
|
186
270
|
## Releases
|
|
187
271
|
|
|
188
|
-
|
|
272
|
+
Release notes live under:
|
|
189
273
|
|
|
190
274
|
```text
|
|
275
|
+
docs/releases/
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
Recommended routes:
|
|
279
|
+
|
|
280
|
+
```text
|
|
281
|
+
/releases/0.1.26
|
|
282
|
+
/releases/0.1.25
|
|
191
283
|
/releases/0.1.24
|
|
192
284
|
/releases/0.1.23
|
|
193
285
|
/releases/0.1.22
|
|
194
|
-
/releases/0.1.21
|
|
195
|
-
/releases/0.1.20
|
|
196
286
|
```
|
|
197
287
|
|
|
198
|
-
|
|
288
|
+
Use one of these release states:
|
|
289
|
+
|
|
290
|
+
```text
|
|
291
|
+
published
|
|
292
|
+
release candidate
|
|
293
|
+
unreleased development target
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
The existence of a release note alone does not mean the npm version is published.
|
|
297
|
+
|
|
298
|
+
## Suggested website model
|
|
299
|
+
|
|
300
|
+
```ts
|
|
301
|
+
interface DocPage {
|
|
302
|
+
title: string;
|
|
303
|
+
slug: string;
|
|
304
|
+
section: string;
|
|
305
|
+
sourceFile: string;
|
|
306
|
+
versionTarget?: string;
|
|
307
|
+
releaseState?:
|
|
308
|
+
| "published"
|
|
309
|
+
| "rc"
|
|
310
|
+
| "unreleased";
|
|
311
|
+
}
|
|
312
|
+
```
|
|
313
|
+
|
|
314
|
+
The first `bcp-docs-web` implementation can keep this mapping in a route manifest and consume Markdown directly.
|
|
315
|
+
|
|
316
|
+
## Suggested website features
|
|
317
|
+
|
|
318
|
+
1. Sidebar navigation from this source map.
|
|
319
|
+
2. Markdown rendering + syntax highlighting.
|
|
320
|
+
3. Previous/next navigation.
|
|
321
|
+
4. Version/release-state banner.
|
|
322
|
+
5. Release pages.
|
|
323
|
+
6. Full-text search.
|
|
324
|
+
7. Copy buttons for code blocks.
|
|
325
|
+
8. Mobile navigation.
|
|
326
|
+
9. GitHub source/edit links.
|
|
327
|
+
|
|
328
|
+
Later:
|
|
329
|
+
|
|
330
|
+
- generated symbol reference,
|
|
331
|
+
- versioned snapshots,
|
|
332
|
+
- interactive examples/playgrounds,
|
|
333
|
+
- release comparison pages.
|
|
199
334
|
|
|
200
|
-
##
|
|
335
|
+
## Source conventions
|
|
201
336
|
|
|
202
|
-
|
|
337
|
+
- one H1 per page,
|
|
338
|
+
- stable heading hierarchy,
|
|
339
|
+
- fenced code blocks with language tags,
|
|
340
|
+
- relative links between docs,
|
|
341
|
+
- exact public API names,
|
|
342
|
+
- clear stable/RC/roadmap labels,
|
|
343
|
+
- security limitations next to affected APIs,
|
|
344
|
+
- runnable examples where possible,
|
|
345
|
+
- no private/internal modules presented as public API.
|
|
346
|
+
|
|
347
|
+
## Release validation
|
|
348
|
+
|
|
349
|
+
Before publishing:
|
|
203
350
|
|
|
204
351
|
```bash
|
|
205
352
|
npm run typecheck
|
|
206
353
|
npm run test:unit
|
|
354
|
+
npm run test:integration
|
|
355
|
+
npm run test:e2e
|
|
356
|
+
npm run test:package
|
|
207
357
|
npm run rc:check
|
|
208
358
|
```
|
|
209
359
|
|
|
210
|
-
|
|
360
|
+
For `0.1.26`, package validation must also confirm the staged npm artifact contains:
|
|
361
|
+
|
|
362
|
+
```text
|
|
363
|
+
@aws-sdk/client-s3
|
|
364
|
+
@aws-sdk/lib-storage
|
|
365
|
+
busboy
|
|
366
|
+
```
|
|
367
|
+
|
|
368
|
+
and the S3/multipart streaming source files/public exports.
|
|
369
|
+
|
|
370
|
+
## Documentation QA checklist
|
|
371
|
+
|
|
372
|
+
- linked Markdown files exist,
|
|
373
|
+
- examples use public exports,
|
|
374
|
+
- version/release states are current,
|
|
375
|
+
- Windows direct CLI examples use `npm exec -- bcp-framework`,
|
|
376
|
+
- upload/storage/auth security caveats are present,
|
|
377
|
+
- route names match the current router,
|
|
378
|
+
- release notes match the framework version,
|
|
379
|
+
- S3 credentials are never shown as public browser variables,
|
|
380
|
+
- roadmap APIs are not presented as published guarantees.
|
|
211
381
|
|
|
212
|
-
## Next
|
|
382
|
+
## Next direction after 0.1.26
|
|
383
|
+
|
|
384
|
+
Recommended `0.1.27` direction:
|
|
385
|
+
|
|
386
|
+
- signed URLs where needed,
|
|
387
|
+
- object listing/copy/move capabilities,
|
|
388
|
+
- broader production hardening,
|
|
389
|
+
- graceful shutdown/resource cleanup,
|
|
390
|
+
- stronger storage/provider diagnostics.
|
|
391
|
+
|
|
392
|
+
These are roadmap items, not `0.1.26` guarantees.
|
|
393
|
+
|
|
394
|
+
## Repository authority
|
|
395
|
+
|
|
396
|
+
The framework repository remains authoritative for:
|
|
397
|
+
|
|
398
|
+
```text
|
|
399
|
+
source
|
|
400
|
+
public exports
|
|
401
|
+
tests
|
|
402
|
+
docs
|
|
403
|
+
release notes
|
|
404
|
+
```
|
|
213
405
|
|
|
214
|
-
|
|
406
|
+
`bcp-docs-web` is the presentation/search/navigation layer for this content.
|