@guren/server 2.14.0 → 2.16.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/dist/{DocsViewerServiceProvider-qFCaeiUv.js → DocsViewerServiceProvider-D2cuVgtN.js} +7 -12
- package/dist/{Hash-CzrwKeDp.js → Hash-D2DFd8xX.js} +12 -57
- package/dist/{HttpException-BkS3euNG.js → HttpException-BlQ2yEmT.js} +2 -79
- package/dist/{Job-BVT813DO.js → Job-DxQK8h3P.js} +24 -179
- package/dist/{McpServiceProvider-BawsYjgN.js → McpServiceProvider-nNcbCIQX.js} +11 -20
- package/dist/{Random-DbIJ22KQ.js → Random-S0OvCuR8.js} +9 -106
- package/dist/agent/AgentApprovalRequested.d.ts +31 -0
- package/dist/agent/approval.d.ts +184 -0
- package/dist/agent/audit-emitter.d.ts +36 -0
- package/dist/agent/audit.d.ts +67 -0
- package/dist/agent/derive.d.ts +32 -66
- package/dist/agent/dispatch.d.ts +53 -63
- package/dist/agent/events.d.ts +11 -19
- package/dist/agent/meta-tools.d.ts +34 -0
- package/dist/agent/public.d.ts +14 -0
- package/dist/agent/public.js +2 -0
- package/dist/agent/redact.d.ts +16 -38
- package/dist/agent/scopes.d.ts +23 -69
- package/dist/auth/AuthManager.d.ts +19 -40
- package/dist/auth/AuthenticatableModel.d.ts +2 -2
- package/dist/auth/SessionGuard.d.ts +0 -1
- package/dist/auth/TokenGuard.d.ts +6 -26
- package/dist/auth/api-token.d.ts +16 -148
- package/dist/auth/context.d.ts +5 -10
- package/dist/auth/email-verification.d.ts +29 -127
- package/dist/auth/index.js +1 -1
- package/dist/auth/oauth/index.d.ts +35 -57
- package/dist/auth/password/DefaultHasher.d.ts +9 -5
- package/dist/auth/password/PasswordHasher.d.ts +7 -0
- package/dist/auth/password/hash-format.d.ts +11 -0
- package/dist/auth/password-reset.d.ts +16 -42
- package/dist/auth/providers/ModelUserProvider.d.ts +3 -4
- package/dist/auth/providers/UserProvider.d.ts +4 -4
- package/dist/auth/signed-token.d.ts +18 -0
- package/dist/auth/types.d.ts +9 -32
- package/dist/auth/utils.d.ts +6 -27
- package/dist/{auth-BSUc14CD.js → auth-CbdPH4Cd.js} +252 -496
- package/dist/authorization/Gate.d.ts +9 -145
- package/dist/authorization/Policy.d.ts +6 -53
- package/dist/authorization/index.js +1 -1
- package/dist/authorization/middleware.d.ts +16 -62
- package/dist/authorization/types.d.ts +8 -64
- package/dist/{authorization-CdfbCj8J.js → authorization-CdEWZZw3.js} +44 -309
- package/dist/broadcasting/BroadcastManager.d.ts +29 -149
- package/dist/broadcasting/channels/Channel.d.ts +1 -19
- package/dist/broadcasting/channels/PresenceChannel.d.ts +1 -55
- package/dist/broadcasting/channels/PrivateChannel.d.ts +1 -23
- package/dist/broadcasting/drivers/MemoryDriver.d.ts +18 -70
- package/dist/broadcasting/drivers/RedisDriver.d.ts +3 -80
- package/dist/broadcasting/drivers/index.d.ts +1 -1
- package/dist/broadcasting/index.d.ts +1 -1
- package/dist/broadcasting/index.js +1 -1
- package/dist/broadcasting/types.d.ts +7 -88
- package/dist/{broadcasting-BxU-LIfF.js → broadcasting-B5RzB0A2.js} +87 -414
- package/dist/cache/CacheManager.d.ts +8 -62
- package/dist/cache/TaggedCache.d.ts +2 -35
- package/dist/cache/index.js +1 -1
- package/dist/cache/stores/FileStore.d.ts +2 -36
- package/dist/cache/stores/MemoryStore.d.ts +2 -26
- package/dist/cache/stores/RedisStore.d.ts +1 -29
- package/dist/cache/types.d.ts +21 -128
- package/dist/{cache-BYnZf2FR.js → cache-BOOIr324.js} +19 -198
- package/dist/client-C4TEr_Dd.js +9 -0
- package/dist/console/Command.d.ts +17 -126
- package/dist/console/ConsoleKernel.d.ts +2 -74
- package/dist/console/Input.d.ts +5 -113
- package/dist/console/Output.d.ts +3 -99
- package/dist/console/types.d.ts +3 -33
- package/dist/container/Container.d.ts +12 -103
- package/dist/container/ServiceProvider.d.ts +17 -61
- package/dist/container/bindings.d.ts +10 -12
- package/dist/container/defineModule.d.ts +16 -54
- package/dist/container/definePlugin.d.ts +12 -45
- package/dist/container/types.d.ts +2 -34
- package/dist/context-CXk_umpT.js +21 -0
- package/dist/database/Factory.d.ts +4 -57
- package/dist/database/Seeder.d.ts +8 -46
- package/dist/database/SeederRunner.d.ts +3 -33
- package/dist/database/types.d.ts +3 -24
- package/dist/discovery/AutoDiscovery.d.ts +10 -82
- package/dist/dispatch-BAwzftws.js +238 -0
- package/dist/docs-viewer/DocsViewerServiceProvider.d.ts +2 -5
- package/dist/docs-viewer/endpoint.d.ts +5 -11
- package/dist/encryption/Encrypter.d.ts +5 -71
- package/dist/encryption/Hash.d.ts +7 -57
- package/dist/encryption/Random.d.ts +6 -99
- package/dist/encryption/index.js +3 -3
- package/dist/encryption/types.d.ts +10 -72
- package/dist/{encryption-DJtkkhiw.js → encryption-uwP3Di4D.js} +13 -79
- package/dist/{endpoint-D6GIqOpe.js → endpoint-BXipU2Jj.js} +6 -12
- package/dist/endpoint-Dsw3Acvq.js +26 -0
- package/dist/errors/ExceptionHandler.d.ts +3 -90
- package/dist/errors/HttpException.d.ts +2 -79
- package/dist/errors/debug-page.d.ts +3 -17
- package/dist/errors/error-page.d.ts +1 -0
- package/dist/errors/exceptions/AuthenticationException.d.ts +2 -24
- package/dist/errors/exceptions/AuthorizationException.d.ts +1 -24
- package/dist/errors/exceptions/MethodNotAllowedException.d.ts +1 -23
- package/dist/errors/exceptions/NotFoundHttpException.d.ts +1 -27
- package/dist/errors/exceptions/ValidationException.d.ts +2 -43
- package/dist/errors/types.d.ts +1 -25
- package/dist/{errors-BgeOl_DC.js → errors-JpkcCjjn.js} +3 -41
- package/dist/events/Event.d.ts +1 -28
- package/dist/events/EventManager.d.ts +5 -107
- package/dist/events/Listener.d.ts +7 -55
- package/dist/events/builtin.d.ts +0 -24
- package/dist/events/index.js +1 -1
- package/dist/events/types.d.ts +4 -22
- package/dist/{events-aIH_bWRx.js → events-DOmAHDeP.js} +11 -191
- package/dist/facades/index.d.ts +2 -14
- package/dist/health/HealthCheck.d.ts +0 -24
- package/dist/health/HealthManager.d.ts +0 -36
- package/dist/health/checks/CacheCheck.d.ts +2 -17
- package/dist/health/checks/CustomCheck.d.ts +0 -9
- package/dist/health/checks/DatabaseCheck.d.ts +2 -17
- package/dist/health/checks/MemoryCheck.d.ts +3 -12
- package/dist/health/checks/RedisCheck.d.ts +1 -13
- package/dist/health/checks/StorageCheck.d.ts +2 -17
- package/dist/health/index.js +1 -1
- package/dist/health/types.d.ts +4 -24
- package/dist/{health-VWdWXRwh.js → health-DQSvUplL.js} +1 -76
- package/dist/hot-disposables-B5BXqaIH.js +167 -0
- package/dist/hot-reload/hot-disposables.d.ts +22 -74
- package/dist/hot-reload/testing.d.ts +4 -9
- package/dist/http/Application.d.ts +62 -208
- package/dist/http/FormRequest.d.ts +4 -55
- package/dist/http/dev-assets.d.ts +16 -18
- package/dist/http/dev-banner.d.ts +2 -5
- package/dist/http/inertia-assets.d.ts +3 -6
- package/dist/http/middleware/capabilities.d.ts +27 -50
- package/dist/http/middleware/cors.d.ts +4 -29
- package/dist/http/middleware/csp.d.ts +2 -25
- package/dist/http/middleware/csrf.d.ts +20 -95
- package/dist/http/middleware/detect-locale.d.ts +7 -27
- package/dist/http/middleware/force-https.d.ts +6 -24
- package/dist/http/middleware/host-authorization.d.ts +2 -12
- package/dist/http/middleware/loopback-guard.d.ts +15 -33
- package/dist/http/middleware/rate-limit.d.ts +29 -126
- package/dist/http/middleware/redirect-safety.d.ts +2 -20
- package/dist/http/middleware/request-id.d.ts +1 -14
- package/dist/http/middleware/request-logging.d.ts +2 -13
- package/dist/http/middleware/response-headers.d.ts +5 -13
- package/dist/http/middleware/security-headers.d.ts +2 -16
- package/dist/http/middleware/session.d.ts +15 -34
- package/dist/http/middleware/validation-errors-cookie.d.ts +7 -18
- package/dist/http/middleware/validation.d.ts +8 -63
- package/dist/http/public-assets.d.ts +14 -0
- package/dist/http/request.d.ts +49 -48
- package/dist/http/resources/CursorPaginator.d.ts +5 -64
- package/dist/http/resources/Paginator.d.ts +7 -84
- package/dist/http/resources/Resource.d.ts +9 -65
- package/dist/http/resources/ResourceCollection.d.ts +5 -39
- package/dist/http/resources/types.d.ts +10 -30
- package/dist/http/static-documents.d.ts +21 -0
- package/dist/http/validation/Validator.d.ts +25 -85
- package/dist/http/validation/rules.d.ts +48 -147
- package/dist/http/validation/types.d.ts +16 -61
- package/dist/http/vite-assets.d.ts +5 -28
- package/dist/http/vite-dev-server.d.ts +6 -9
- package/dist/http/vite-manifest.d.ts +19 -33
- package/dist/i18n/I18nManager.d.ts +12 -78
- package/dist/i18n/Translator.d.ts +3 -54
- package/dist/i18n/index.js +1 -1
- package/dist/i18n/loaders/JsonLoader.d.ts +4 -31
- package/dist/i18n/loaders/MemoryLoader.d.ts +1 -21
- package/dist/i18n/pluralization.d.ts +4 -13
- package/dist/i18n/types.d.ts +17 -69
- package/dist/{i18n-mcWi7LCd.js → i18n-Cg1aajRP.js} +31 -225
- package/dist/index.d.ts +13 -4
- package/dist/index.js +1036 -3080
- package/dist/internal/agent-preflight.d.ts +9 -21
- package/dist/internal/request.d.ts +10 -17
- package/dist/internal/request.js +2 -2
- package/dist/internal/route-path.d.ts +9 -21
- package/dist/internal/route-path.js +9 -21
- package/dist/internal/zod-compat.d.ts +55 -122
- package/dist/internal/zod-compat.js +39 -70
- package/dist/internal/zod-json-schema.d.ts +18 -54
- package/dist/internal/zod-json-schema.js +46 -123
- package/dist/jsx-runtime.d.ts +3 -8
- package/dist/lambda/index.d.ts +17 -79
- package/dist/lambda/index.js +11 -59
- package/dist/logging/LogManager.d.ts +1 -51
- package/dist/logging/Logger.d.ts +8 -47
- package/dist/logging/channels/ConsoleChannel.d.ts +1 -3
- package/dist/logging/channels/DailyFileChannel.d.ts +1 -5
- package/dist/logging/channels/FileChannel.d.ts +1 -3
- package/dist/logging/daily-file-path.d.ts +15 -0
- package/dist/logging/index.d.ts +1 -0
- package/dist/logging/index.js +2 -2
- package/dist/logging/types.d.ts +13 -45
- package/dist/{logging-CPaRMuPP.js → logging-zOY1XCtq.js} +83 -129
- package/dist/{loopback-guard-D0Kc7-xc.js → loopback-guard-DT9gHF0F.js} +41 -92
- package/dist/mail/Mail.d.ts +10 -106
- package/dist/mail/MailManager.d.ts +2 -60
- package/dist/mail/index.js +1 -1
- package/dist/mail/transports/LogTransport.d.ts +1 -4
- package/dist/mail/transports/MemoryTransport.d.ts +1 -63
- package/dist/mail/transports/ResendTransport.d.ts +1 -23
- package/dist/mail/transports/SmtpTransport.d.ts +1 -31
- package/dist/mail/types.d.ts +28 -150
- package/dist/{mail-DfEfSQEr.js → mail-76DWy9lj.js} +31 -289
- package/dist/mcp/McpServiceProvider.d.ts +4 -10
- package/dist/mcp/create-mcp-server.d.ts +25 -57
- package/dist/mcp/endpoint.d.ts +12 -36
- package/dist/mcp/index.js +1 -1
- package/dist/mvc/Controller.d.ts +46 -253
- package/dist/mvc/Router.d.ts +50 -129
- package/dist/mvc/inertia/InertiaEngine.d.ts +18 -48
- package/dist/mvc/inertia/shared.d.ts +6 -19
- package/dist/mvc/mount-route.d.ts +2 -6
- package/dist/mvc/view.d.ts +1 -2
- package/dist/notifications/Notification.d.ts +8 -75
- package/dist/notifications/NotificationManager.d.ts +15 -88
- package/dist/notifications/channels/DatabaseChannel.d.ts +1 -41
- package/dist/notifications/channels/MailChannel.d.ts +2 -31
- package/dist/notifications/channels/MemoryChannel.d.ts +2 -62
- package/dist/notifications/channels/SlackChannel.d.ts +3 -48
- package/dist/notifications/index.js +1 -1
- package/dist/notifications/notifiable-type.d.ts +3 -6
- package/dist/notifications/registry.d.ts +8 -27
- package/dist/notifications/types.d.ts +16 -53
- package/dist/{notifications-BGqmUNZ8.js → notifications-okWFs9ly.js} +37 -335
- package/dist/providers/AuthServiceProvider.d.ts +1 -3
- package/dist/providers/AuthorizationServiceProvider.d.ts +2 -3
- package/dist/providers/BroadcastServiceProvider.d.ts +1 -3
- package/dist/providers/CacheServiceProvider.d.ts +1 -3
- package/dist/providers/EncryptionServiceProvider.d.ts +1 -3
- package/dist/providers/ErrorServiceProvider.d.ts +1 -4
- package/dist/providers/EventServiceProvider.d.ts +1 -3
- package/dist/providers/HealthServiceProvider.d.ts +1 -3
- package/dist/providers/I18nServiceProvider.d.ts +6 -10
- package/dist/providers/InertiaServiceProvider.d.ts +1 -4
- package/dist/providers/LogServiceProvider.d.ts +1 -3
- package/dist/providers/MailServiceProvider.d.ts +1 -3
- package/dist/providers/NotificationServiceProvider.d.ts +1 -3
- package/dist/providers/OAuthServiceProvider.d.ts +1 -3
- package/dist/providers/QueueServiceProvider.d.ts +1 -3
- package/dist/providers/SchedulingServiceProvider.d.ts +1 -3
- package/dist/providers/StorageServiceProvider.d.ts +1 -3
- package/dist/queue/FailedJobReporter.d.ts +1 -24
- package/dist/queue/Job.d.ts +12 -99
- package/dist/queue/QueueManager.d.ts +6 -57
- package/dist/queue/Worker.d.ts +4 -65
- package/dist/queue/drivers/MemoryDriver.d.ts +3 -44
- package/dist/queue/drivers/RedisDriver.d.ts +7 -65
- package/dist/queue/drivers/SqsDriver.d.ts +6 -57
- package/dist/queue/drivers/SyncDriver.d.ts +10 -13
- package/dist/queue/index.js +2 -2
- package/dist/queue/types.d.ts +10 -92
- package/dist/{queue-CXrRK85G.js → queue-CcXCjuJI.js} +32 -260
- package/dist/redis/RedisApiTokenStore.d.ts +4 -56
- package/dist/redis/RedisEmailVerificationStore.d.ts +4 -37
- package/dist/redis/RedisOAuthStateStore.d.ts +2 -10
- package/dist/redis/RedisPasswordResetStore.d.ts +4 -37
- package/dist/redis/RedisRateLimitStore.d.ts +16 -49
- package/dist/redis/RedisSessionStore.d.ts +3 -44
- package/dist/redis/client.d.ts +2 -32
- package/dist/redis/index.js +47 -232
- package/dist/redis/redis-values.d.ts +6 -12
- package/dist/redis/scan-keys.d.ts +1 -4
- package/dist/request-CLOYytGP.js +68 -0
- package/dist/runtime/index.d.ts +2 -0
- package/dist/runtime/index.js +108 -74
- package/dist/scheduling/CronParser.d.ts +0 -29
- package/dist/scheduling/Schedule.d.ts +1 -153
- package/dist/scheduling/ScheduledTask.d.ts +0 -31
- package/dist/scheduling/Scheduler.d.ts +0 -70
- package/dist/scheduling/index.js +1 -1
- package/dist/scheduling/types.d.ts +4 -65
- package/dist/{scheduling-CPiEdtQd.js → scheduling-C6tcOtUl.js} +2 -287
- package/dist/storage/StorageManager.d.ts +0 -48
- package/dist/storage/drivers/LocalDriver.d.ts +1 -25
- package/dist/storage/drivers/MemoryDriver.d.ts +5 -35
- package/dist/storage/drivers/S3Driver.d.ts +6 -36
- package/dist/storage/drivers/s3-acl.d.ts +5 -10
- package/dist/storage/index.js +1 -1
- package/dist/storage/types.d.ts +27 -265
- package/dist/{storage-TLD9t0Q2.js → storage-BB59f07j.js} +17 -157
- package/dist/support/contained-path.d.ts +10 -20
- package/dist/support/error-polyfill.d.ts +4 -6
- package/dist/support/expiry.d.ts +17 -33
- package/dist/support/expiry.js +17 -33
- package/dist/support/import-map.d.ts +3 -7
- package/dist/support/inertia-defaults.d.ts +5 -10
- package/dist/support/redirect-target.d.ts +4 -6
- package/dist/support/stack-frames.d.ts +11 -50
- package/dist/support/trim-slashes.d.ts +4 -7
- package/dist/support/warn-once.d.ts +2 -6
- package/dist/{trim-slashes-ZJ_VsY5s.js → trim-slashes-BLY9hKAa.js} +4 -7
- package/dist/{vite-manifest-BGfWbPYp.js → vite-manifest-CTQp-SOo.js} +34 -58
- package/package.json +6 -2
- package/dist/client-Dd7vLcqp.js +0 -27
- package/dist/context-DoD0c7J_.js +0 -26
- package/dist/endpoint-D-20PiHY.js +0 -46
- package/dist/hot-disposables-WsTX2ySN.js +0 -281
- package/dist/request-CRVuIiQr.js +0 -78
|
@@ -1,48 +1,12 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Stops the timers a previous module evaluation left running
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
* `globalThis` survives re-evaluation, so it is where the previous owner's
|
|
11
|
-
* teardown is parked — the same storage `Application.listen()` uses for the Bun
|
|
12
|
-
* and Vite dev servers, and the same approach `@guren/orm` uses for database
|
|
13
|
-
* connections. Bun does not expose `import.meta.hot` to `bun --hot` (checked on
|
|
14
|
-
* 1.3.14), so there is no reload hook to register with instead.
|
|
15
|
-
*
|
|
16
|
-
* This is deliberately not the ORM's registry with the names changed. Closing a
|
|
17
|
-
* connection is an async operation that can hang on a wedged socket, which is
|
|
18
|
-
* what forces that module's serialized claims and teardown timeout. Every
|
|
19
|
-
* teardown here is synchronous — `clearInterval`, and the `destroy()`/`stop()`
|
|
20
|
-
* methods wrapping it — so a claim can simply run the previous teardown inline
|
|
21
|
-
* and be done. Sharing the registries would buy machinery neither side needs in
|
|
22
|
-
* the same shape.
|
|
23
|
-
*
|
|
24
|
-
* Its twin is `packages/orm/src/active-connections.ts`. `parseFrameLocation` and
|
|
25
|
-
* `describeCallerFile`'s walk past a synthetic frame follow the same rule in
|
|
26
|
-
* both — a fix to either has to be carried to the other by hand. That has
|
|
27
|
-
* already failed once: this walk predates the ORM's, and the ORM kept keying
|
|
28
|
-
* handles to `unknown` in the meantime. Nothing forces the duplication —
|
|
29
|
-
* `@guren/server` already depends on `@guren/orm`, so this layer could live
|
|
30
|
-
* there and be imported here — it is only that the shared part is small next to
|
|
31
|
-
* the two packages' very different teardown semantics (see above). Extract the
|
|
32
|
-
* rest if it drifts again.
|
|
33
|
-
*
|
|
34
|
-
* One piece already went that way, for a reason worth recording: the debug error
|
|
35
|
-
* page turned out to read frames too, and had written its own, wrong version of
|
|
36
|
-
* the paren rule. That scan now lives in `../support/stack-frames`, imported by
|
|
37
|
-
* both readers in this package — the ORM's copy of it is still hand-synced like
|
|
38
|
-
* everything else here.
|
|
39
|
-
*
|
|
40
|
-
* An owner is identified by the file that built it plus a discriminator, so it
|
|
41
|
-
* is replaced only by a later evaluation of that same file. Keying on the exact
|
|
42
|
-
* line would be more precise, but a line number changes the moment anything
|
|
43
|
-
* above it does — adding an import would orphan the previous entry and leak the
|
|
44
|
-
* timer it was holding, during the very workflow this exists to fix. The file is
|
|
45
|
-
* stable across every edit that isn't a rename.
|
|
2
|
+
* Stops the timers a previous module evaluation left running: `bun --hot`
|
|
3
|
+
* re-runs the module graph in-process and a `setInterval` callback keeps its
|
|
4
|
+
* owner reachable, so each reload leaks a timer and the dead graph behind it.
|
|
5
|
+
* Teardown is parked on `globalThis`, which survives re-evaluation — Bun
|
|
6
|
+
* exposes no `import.meta.hot` to `bun --hot` (1.3.14). Owners are keyed on
|
|
7
|
+
* file + discriminator, never line: a line moves whenever anything above it
|
|
8
|
+
* does. Twin of `packages/orm/src/active-connections.ts` — the frame-walk rule
|
|
9
|
+
* is the same in both and must be carried across by hand.
|
|
46
10
|
*/
|
|
47
11
|
type Dispose = () => void;
|
|
48
12
|
/** Frees the slot an owner claimed, unless a newer owner has since taken it. */
|
|
@@ -50,47 +14,31 @@ export interface HotDisposableClaim {
|
|
|
50
14
|
release(): void;
|
|
51
15
|
}
|
|
52
16
|
/**
|
|
53
|
-
* Whether modules can be re-evaluated in this process.
|
|
54
|
-
*
|
|
55
|
-
*
|
|
56
|
-
*
|
|
57
|
-
* CLI commands, serverless — nothing is ever torn down automatically.
|
|
58
|
-
*
|
|
59
|
-
* Exported so callers can skip building the `Error` whose stack identifies them:
|
|
60
|
-
* capturing one formats the whole stack into a string, and outside `--hot` it
|
|
61
|
-
* would only be thrown away.
|
|
17
|
+
* Whether modules can be re-evaluated in this process. `bun --watch` restarts
|
|
18
|
+
* instead, dropping every timer with it, so `--hot` is the only mode that leaks.
|
|
19
|
+
* Exported so callers can skip building the `Error` whose stack identifies them
|
|
20
|
+
* — capturing one formats the whole stack into a string.
|
|
62
21
|
*/
|
|
63
22
|
export declare function isHotReloadRuntime(): boolean;
|
|
64
23
|
/**
|
|
65
|
-
* The file that built the timer owner.
|
|
66
|
-
*
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
* is the caller — or the first frame after it that names a real file, since the
|
|
70
|
-
* engine may have synthesized the frames in between. Only the path is kept: a
|
|
71
|
-
* reload re-runs the same file, but not necessarily at the same line.
|
|
24
|
+
* The file that built the timer owner. `stack` must come from an `Error`
|
|
25
|
+
* constructed inside the constructor or factory itself, so frame 2 is the
|
|
26
|
+
* caller — or the first frame after it naming a real file, since the engine may
|
|
27
|
+
* have synthesized the ones in between.
|
|
72
28
|
*/
|
|
73
29
|
export declare function describeCallerFile(stack: string | undefined): string | undefined;
|
|
74
30
|
/**
|
|
75
31
|
* Identity for a timer owner across hot reloads, or `undefined` when the owner
|
|
76
|
-
* must be left alone.
|
|
77
|
-
*
|
|
78
|
-
* `target` separates owners that share a call site — the name of a cache store,
|
|
79
|
-
* say — so one module building several does not collapse them into a slot where
|
|
80
|
-
* each new one stops the last.
|
|
32
|
+
* must be left alone. `target` separates owners sharing a call site, so one
|
|
33
|
+
* module building several does not collapse them into a single slot.
|
|
81
34
|
*/
|
|
82
35
|
export declare function hotReloadKey(scope: string, stack: string | undefined, target: string): string | undefined;
|
|
83
36
|
/**
|
|
84
37
|
* Records `dispose` as the live owner for this identity, stops whichever owner
|
|
85
|
-
* held it before, and
|
|
86
|
-
*
|
|
87
|
-
*
|
|
88
|
-
*
|
|
89
|
-
* registry existed.
|
|
90
|
-
*
|
|
91
|
-
* A teardown that throws is reported and swallowed: the replacement has already
|
|
92
|
-
* been built by the time this runs, and refusing to register it would leak the
|
|
93
|
-
* very timer this is here to stop.
|
|
38
|
+
* held it before, and returns the claim. `undefined` outside `--hot`, or when
|
|
39
|
+
* the stack names no caller — the owner is then left alone. A teardown that
|
|
40
|
+
* throws is reported and swallowed, since refusing to register the replacement
|
|
41
|
+
* would leak the very timer this exists to stop.
|
|
94
42
|
*/
|
|
95
43
|
export declare function claimHotDisposable(scope: string, stack: string | undefined, target: string, dispose: Dispose): HotDisposableClaim | undefined;
|
|
96
44
|
export {};
|
|
@@ -1,14 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Test-only helpers for the hot-reload registry.
|
|
3
|
-
*
|
|
4
|
-
* Not reachable from any tsdown entry point, so it never ships — it lives beside
|
|
5
|
-
* the code it exercises because both test files in this directory need it and
|
|
6
|
-
* `@guren/server` has no shared test-support module.
|
|
2
|
+
* Test-only helpers for the hot-reload registry. Not reachable from any tsdown
|
|
3
|
+
* entry point, so it never ships.
|
|
7
4
|
*/
|
|
8
5
|
/**
|
|
9
|
-
* Runs `callback` with the registry's `--hot` guard satisfied.
|
|
10
|
-
*
|
|
11
|
-
* The guard reads `process.execArgv`, which is also how the real thing detects
|
|
12
|
-
* `bun --hot`; there is no flag or injection seam to prefer over it.
|
|
6
|
+
* Runs `callback` with the registry's `--hot` guard satisfied. The guard reads
|
|
7
|
+
* `process.execArgv`, which is also how the real thing detects `bun --hot`.
|
|
13
8
|
*/
|
|
14
9
|
export declare function withHotRuntime<T>(callback: () => T): T;
|
|
@@ -21,44 +21,32 @@ type BunServer = {
|
|
|
21
21
|
};
|
|
22
22
|
type ViteServer = Awaited<ReturnType<typeof startViteDevServer>>['server'];
|
|
23
23
|
/**
|
|
24
|
-
* The one managed Vite dev server this process runs, and who owns it.
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
28
|
-
* rather than restarting it, and both applications then hold the same object.
|
|
29
|
-
* Instance identity cannot tell those two apart — it is the same server — so
|
|
30
|
-
* "may I close this?" is answered here instead, by the slot naming exactly one
|
|
31
|
-
* owner at a time.
|
|
24
|
+
* The one managed Vite dev server this process runs, and who owns it. A server
|
|
25
|
+
* outlives the `listen()` that started it — a `bun --hot` reload adopts it, so
|
|
26
|
+
* two applications hold the same object and instance identity cannot tell them
|
|
27
|
+
* apart. The slot names exactly one owner at a time instead.
|
|
32
28
|
*/
|
|
33
29
|
export interface ActiveViteDevServer {
|
|
34
30
|
readonly server: ViteServer;
|
|
35
31
|
readonly localUrl: string;
|
|
36
32
|
readonly owner: Application;
|
|
37
33
|
/**
|
|
38
|
-
* Detaches the owner's process teardown handlers. Whoever replaces this
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
* its own `process.exit()`, on the next signal.
|
|
34
|
+
* Detaches the owner's process teardown handlers. Whoever replaces this record
|
|
35
|
+
* calls it: the outgoing owner is only reachable from here, and handlers left
|
|
36
|
+
* attached would still close this server on the next signal.
|
|
42
37
|
*/
|
|
43
38
|
readonly disposeTeardown: () => void;
|
|
44
39
|
}
|
|
45
40
|
/**
|
|
46
|
-
* The ambient slots `listen()` plants on `globalThis
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
* Exported so the tests that plant stand-ins in these slots can name them
|
|
51
|
-
* against this declaration instead of restating it. Not part of the public
|
|
52
|
-
* API: `src/index.ts` re-exports by name and does not list it.
|
|
41
|
+
* The ambient slots `listen()` plants on `globalThis`, which a `bun --hot`
|
|
42
|
+
* reload keeps, so the next run can find what the previous one left running.
|
|
43
|
+
* Exported for the tests that plant stand-ins; not part of the public API.
|
|
53
44
|
*/
|
|
54
45
|
export interface GurenGlobalSlots {
|
|
55
46
|
__gurenActiveServer?: BunServer;
|
|
56
47
|
__gurenActiveViteDevServer?: ActiveViteDevServer;
|
|
57
48
|
}
|
|
58
49
|
export type BootCallback = (app: Hono) => void | Promise<void>;
|
|
59
|
-
/**
|
|
60
|
-
* Service provider class constructor type.
|
|
61
|
-
*/
|
|
62
50
|
export type { ServiceProviderConstructor } from '../container/ServiceProvider.js';
|
|
63
51
|
export type RouteRegistration = (router: Router) => void | Promise<void>;
|
|
64
52
|
export type ApplicationFeatures = Record<string, unknown>;
|
|
@@ -66,81 +54,43 @@ export interface ApplicationOptions {
|
|
|
66
54
|
readonly boot?: BootCallback;
|
|
67
55
|
readonly providers?: Array<ServiceProviderConstructor>;
|
|
68
56
|
readonly auth?: AuthPluginOptions;
|
|
69
|
-
/**
|
|
70
|
-
* Configure internationalization: translation loading, locale detection,
|
|
71
|
-
* and Inertia `_i18n` shared props. When set, {@link I18nServiceProvider}
|
|
72
|
-
* is registered automatically.
|
|
73
|
-
*/
|
|
57
|
+
/** When set, {@link I18nServiceProvider} is registered automatically. */
|
|
74
58
|
readonly i18n?: I18nPluginOptions;
|
|
75
59
|
readonly routes?: RouteRegistration;
|
|
76
60
|
/**
|
|
77
|
-
* Application modules (RFC 0002)
|
|
78
|
-
*
|
|
79
|
-
* (wrapped in `router.group(prefix, ...)` when the module declares one).
|
|
61
|
+
* Application modules (RFC 0002). Their providers are appended to `providers`
|
|
62
|
+
* and their route registrars run after `routes`, under the module's prefix.
|
|
80
63
|
*/
|
|
81
64
|
readonly modules?: GurenModule[];
|
|
82
65
|
readonly features?: ApplicationFeatures;
|
|
83
|
-
/**
|
|
84
|
-
* Configure or disable the default security headers middleware.
|
|
85
|
-
* Set to `false` to disable entirely, or pass `SecurityHeadersOptions` to customize.
|
|
86
|
-
* Enabled by default with safe Rails-matching defaults.
|
|
87
|
-
*/
|
|
66
|
+
/** Enabled by default with Rails-matching defaults; `false` disables it. */
|
|
88
67
|
readonly securityHeaders?: SecurityHeadersOptions | false;
|
|
89
|
-
/**
|
|
90
|
-
* Configure host authorization middleware for DNS rebinding protection.
|
|
91
|
-
* Pass `HostAuthorizationOptions` to enable, or `false` / omit to disable.
|
|
92
|
-
* The `create-app` template includes a default localhost configuration.
|
|
93
|
-
*/
|
|
68
|
+
/** DNS rebinding protection. Off unless configured; the template configures it. */
|
|
94
69
|
readonly hostAuthorization?: HostAuthorizationOptions | false;
|
|
95
70
|
}
|
|
96
71
|
export interface I18nPluginOptions {
|
|
97
|
-
/**
|
|
98
|
-
* Locales the app supports. Locale detection only ever resolves to one of
|
|
99
|
-
* these, and all of them are preloaded during `boot()`.
|
|
100
|
-
*/
|
|
72
|
+
/** Detection only resolves to one of these; all are preloaded during `boot()`. */
|
|
101
73
|
readonly supported: readonly string[];
|
|
102
|
-
/**
|
|
103
|
-
* Fallback (and default) locale. Defaults to the first supported locale.
|
|
104
|
-
*/
|
|
74
|
+
/** Defaults to the first supported locale. */
|
|
105
75
|
readonly fallback?: string;
|
|
106
76
|
/**
|
|
107
|
-
* Directory
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
*
|
|
111
|
-
* Framework tooling (typed keys from `guren codegen`, `guren check
|
|
112
|
-
* --i18n`, the Vite watch) assumes the default `lang/` location — a
|
|
113
|
-
* custom path or loader opts out of those.
|
|
77
|
+
* Directory of `<path>/<locale>/*.json` files. Defaults to `'lang'`; ignored
|
|
78
|
+
* when `loader` is set. Framework tooling (typed keys, `check --i18n`, the
|
|
79
|
+
* Vite watch) assumes `lang/`, so a custom path or loader opts out of it.
|
|
114
80
|
*/
|
|
115
81
|
readonly path?: string;
|
|
116
|
-
/**
|
|
117
|
-
* Custom translation loader (e.g. `MemoryLoader` for bundled messages on
|
|
118
|
-
* serverless targets without a filesystem). Takes precedence over `path`.
|
|
119
|
-
*/
|
|
82
|
+
/** Takes precedence over `path` — e.g. `MemoryLoader` on a filesystem-less target. */
|
|
120
83
|
readonly loader?: TranslationLoader;
|
|
121
|
-
/**
|
|
122
|
-
* Locale detection middleware options. `detectLocaleMiddleware` is mounted
|
|
123
|
-
* automatically with the `supported` locales and `fallback` above; pass
|
|
124
|
-
* `false` to mount (or skip) it yourself.
|
|
125
|
-
*/
|
|
84
|
+
/** `detectLocaleMiddleware` is mounted automatically; `false` to do it yourself. */
|
|
126
85
|
readonly detect?: Omit<DetectLocaleOptions, 'supported' | 'fallback' | 'i18n'> | false;
|
|
127
|
-
/**
|
|
128
|
-
* Share the request locale and its messages with Inertia pages as the
|
|
129
|
-
* `_i18n` prop. Defaults to `true`.
|
|
130
|
-
*/
|
|
86
|
+
/** Share the locale and its messages with Inertia as `_i18n`. Defaults to `true`. */
|
|
131
87
|
readonly share?: boolean;
|
|
132
88
|
}
|
|
133
89
|
export interface AuthPluginOptions {
|
|
134
90
|
autoSession?: boolean;
|
|
135
91
|
sessionOptions?: CreateSessionMiddlewareOptions;
|
|
136
|
-
/**
|
|
137
|
-
* Automatically register CSRF middleware when session is enabled.
|
|
138
|
-
* Defaults to `true`. Set to `false` to disable (e.g., for pure API servers).
|
|
139
|
-
*/
|
|
92
|
+
/** Defaults to `true` when session is enabled. */
|
|
140
93
|
autoCsrf?: boolean;
|
|
141
|
-
/**
|
|
142
|
-
* Options passed to the CSRF middleware when `autoCsrf` is enabled.
|
|
143
|
-
*/
|
|
144
94
|
csrfOptions?: import('./middleware/csrf.js').CsrfOptions;
|
|
145
95
|
}
|
|
146
96
|
export interface ApplicationListenOptions {
|
|
@@ -149,50 +99,30 @@ export interface ApplicationListenOptions {
|
|
|
149
99
|
assetsUrl?: string;
|
|
150
100
|
vite?: StartViteDevServerOptions | false;
|
|
151
101
|
/**
|
|
152
|
-
*
|
|
153
|
-
*
|
|
154
|
-
*
|
|
155
|
-
* the original EADDRINUSE. Unset walks outside production, matching the loop
|
|
156
|
-
* this option replaces.
|
|
157
|
-
*
|
|
158
|
-
* `GUREN_STRICT_PORT=1` forces fail-fast regardless, and `port: 0` never
|
|
159
|
-
* walks — the OS is already picking a free port.
|
|
102
|
+
* `true` walks forward through the next 20 ports, `false` fails fast on
|
|
103
|
+
* EADDRINUSE, unset walks outside production. `GUREN_STRICT_PORT=1` forces
|
|
104
|
+
* fail-fast regardless, and `port: 0` never walks.
|
|
160
105
|
*/
|
|
161
106
|
portFallback?: boolean;
|
|
162
107
|
}
|
|
163
108
|
/**
|
|
164
|
-
* Where the server actually ended up listening
|
|
165
|
-
*
|
|
166
|
-
*
|
|
167
|
-
* port from the port they asked for — with a port walk or `PORT=0` in play,
|
|
168
|
-
* those are different numbers, and scraping the human-readable dev banner is
|
|
169
|
-
* the only alternative.
|
|
170
|
-
*
|
|
171
|
-
* Read-only because {@link Application.address} hands back the very object
|
|
172
|
-
* `listen()` returned: a caller that adjusted its own copy would change what
|
|
173
|
-
* every later reader sees.
|
|
109
|
+
* Where the server actually ended up listening — with a port walk or `PORT=0`
|
|
110
|
+
* in play, not the port that was asked for. Read-only because
|
|
111
|
+
* {@link Application.address} hands back this very object.
|
|
174
112
|
*/
|
|
175
113
|
export interface ListenAddress {
|
|
176
|
-
/**
|
|
177
|
-
* The port the socket is bound to — what the runtime reports, falling back
|
|
178
|
-
* to the port the successful `Bun.serve` call was made with.
|
|
179
|
-
*/
|
|
114
|
+
/** What the runtime reports, falling back to the port `Bun.serve` succeeded on. */
|
|
180
115
|
readonly port: number;
|
|
181
|
-
/** The hostname the socket is bound to. */
|
|
182
116
|
readonly hostname: string;
|
|
183
117
|
/** A URL that reaches the server, with a wildcard bind resolved to localhost. */
|
|
184
118
|
readonly url: string;
|
|
185
119
|
}
|
|
186
120
|
/**
|
|
187
|
-
*
|
|
188
|
-
*
|
|
189
|
-
* It embeds a DI Container as the backbone of the framework, binding core
|
|
190
|
-
* services and managing providers through the container's ProviderManager.
|
|
121
|
+
* Wires an app-local router and a DI container into a running Hono instance.
|
|
191
122
|
*
|
|
192
123
|
* Lifecycle rule for `listen()`/`stop()` and their helpers: re-check ownership
|
|
193
|
-
* after every `await`.
|
|
194
|
-
*
|
|
195
|
-
* owner may clear shared state.
|
|
124
|
+
* after every `await`. A concurrent call may have superseded any server or slot
|
|
125
|
+
* they remembered, and only the current owner may clear shared state.
|
|
196
126
|
*/
|
|
197
127
|
export declare class Application {
|
|
198
128
|
private readonly options;
|
|
@@ -205,14 +135,10 @@ export declare class Application {
|
|
|
205
135
|
private boundAddress?;
|
|
206
136
|
/**
|
|
207
137
|
* Detaches the Bun half's process teardown handlers, and doubles as the "are
|
|
208
|
-
* they attached?" memo
|
|
209
|
-
*
|
|
210
|
-
*
|
|
211
|
-
*
|
|
212
|
-
* The Vite half's disposer lives in {@link ActiveViteDevServer} instead,
|
|
213
|
-
* because the application that detaches those handlers is not always the one
|
|
214
|
-
* that attached them: adoption moves the server to a new owner, and the
|
|
215
|
-
* outgoing owner is only reachable through the slot.
|
|
138
|
+
* they attached?" memo — one field, because a memo and an undo that disagree
|
|
139
|
+
* leave handlers attached while a flag says otherwise. The Vite half's
|
|
140
|
+
* disposer lives in {@link ActiveViteDevServer}, since adoption moves that
|
|
141
|
+
* server to an owner reachable only through the slot.
|
|
216
142
|
*/
|
|
217
143
|
private disposeBunTeardown?;
|
|
218
144
|
private autoSessionAttached;
|
|
@@ -224,130 +150,58 @@ export declare class Application {
|
|
|
224
150
|
get i18nOptions(): I18nPluginOptions | undefined;
|
|
225
151
|
markAutoSessionAttached(): void;
|
|
226
152
|
hasAutoSessionAttached(): boolean;
|
|
227
|
-
/**
|
|
228
|
-
* Mounts the application router onto the Hono instance.
|
|
229
|
-
*/
|
|
230
153
|
mountRoutes(): Promise<void>;
|
|
231
|
-
/**
|
|
232
|
-
* Allows registering global middlewares directly on the underlying Hono app.
|
|
233
|
-
*/
|
|
234
154
|
use(path: string, ...middleware: MiddlewareHandler[]): void;
|
|
235
155
|
/**
|
|
236
|
-
*
|
|
156
|
+
* Registers providers, runs the boot callback, mounts routes, boots providers.
|
|
237
157
|
*
|
|
238
|
-
* Booting twice is a no-op
|
|
239
|
-
*
|
|
240
|
-
*
|
|
241
|
-
* remembered, so a later call attempts boot again (it resumes on a partially
|
|
242
|
-
* mounted app rather than starting clean). The security defaults are mounted
|
|
243
|
-
* by the constructor and so are outside this entirely.
|
|
158
|
+
* Booting twice is a no-op — the first call's promise is reused, concurrent
|
|
159
|
+
* callers included. A boot that throws is not remembered, so a later call
|
|
160
|
+
* retries on the partially mounted app rather than starting clean.
|
|
244
161
|
*/
|
|
245
162
|
boot(): Promise<void>;
|
|
246
163
|
private bootOnce;
|
|
247
|
-
/**
|
|
248
|
-
* Registers default security middleware (headers + host authorization).
|
|
249
|
-
*
|
|
250
|
-
* Called once, from the constructor — see the note there for why it does
|
|
251
|
-
* not belong in boot().
|
|
252
|
-
*/
|
|
164
|
+
/** Called once, from the constructor — see the note there for why. */
|
|
253
165
|
private mountSecurityDefaults;
|
|
254
166
|
private mountHostAuthorization;
|
|
255
167
|
/**
|
|
256
|
-
* Mounts an opt-in, dev-only framework endpoint
|
|
257
|
-
*
|
|
258
|
-
*
|
|
259
|
-
* Only the dynamic import is allowed to fail silently — these
|
|
260
|
-
* providers reach optional dependencies (the MCP SDK, @guren/cli) that
|
|
261
|
-
* an app need not have installed, and `missing` names that case. A
|
|
262
|
-
* failure inside the provider's own boot is a real problem and is
|
|
263
|
-
* rethrown, rather than leaving the developer with a silent 404.
|
|
168
|
+
* Mounts an opt-in, dev-only framework endpoint. Only the dynamic import may
|
|
169
|
+
* fail silently — these providers reach optional dependencies an app need not
|
|
170
|
+
* have installed. A failure inside the provider's own boot is rethrown.
|
|
264
171
|
*/
|
|
265
172
|
private mountDevEndpoint;
|
|
266
|
-
/**
|
|
267
|
-
* Fetch handler to integrate with Bun.serve or any standard Fetch runtime.
|
|
268
|
-
*/
|
|
269
173
|
fetch(request: Request, env?: unknown, executionCtx?: ExecutionContext): Promise<Response>;
|
|
270
|
-
/**
|
|
271
|
-
* Convenience helper to start a Bun server when available.
|
|
272
|
-
*/
|
|
273
174
|
listen(options?: ApplicationListenOptions): Promise<ListenAddress>;
|
|
274
175
|
/**
|
|
275
|
-
* The address {@link Application.listen} bound
|
|
276
|
-
*
|
|
277
|
-
*
|
|
278
|
-
*
|
|
279
|
-
*
|
|
280
|
-
* read it here instead of threading it out of the entrypoint.
|
|
281
|
-
*
|
|
282
|
-
* The stored value is preferred over re-reading the live server, because
|
|
283
|
-
* `listen()` resolves the port through a fallback the socket no longer
|
|
284
|
-
* carries.
|
|
285
|
-
*
|
|
286
|
-
* Liveness is only as good as the signal available: a server stopped through
|
|
287
|
-
* the framework — {@link Application.stop}, a later `listen()`, the
|
|
288
|
-
* process-exit teardown — clears what this reads, but one stopped by reaching
|
|
289
|
-
* past the framework to the Bun server's own `stop()` does not, and this keeps
|
|
290
|
-
* reporting its address. Treat it as "where `listen()` put this app", not as a
|
|
291
|
-
* health check.
|
|
176
|
+
* The address {@link Application.listen} bound — the same object it returned,
|
|
177
|
+
* preferred over re-reading the live server, whose port `listen()` may have
|
|
178
|
+
* resolved through a fallback the socket itself does not carry. Only stops
|
|
179
|
+
* that go through the framework clear it, so treat it as "where `listen()`
|
|
180
|
+
* put this app", not as a health check.
|
|
292
181
|
*/
|
|
293
182
|
get address(): ListenAddress | undefined;
|
|
294
183
|
/**
|
|
295
|
-
* Stops the server {@link listen} started
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
*
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
* `closeActiveConnections` forces in-flight requests closed instead of
|
|
302
|
-
* waiting for them, matching Bun's own `stop()` parameter. It defaults to
|
|
303
|
-
* `false` (graceful) because a caller reaching for a public stop is usually
|
|
304
|
-
* shutting down deliberately; the hot-reload path inside `listen()` forces
|
|
305
|
-
* the close, since a reload must not wait on the server it is replacing.
|
|
306
|
-
*
|
|
307
|
-
* The managed Vite dev server is taken down too. `listen()` is what started
|
|
308
|
-
* it, and `listen()`'s own bind-failure path already closes the one it
|
|
309
|
-
* started — leaving it running here would strand an asset server, and its
|
|
310
|
-
* published env vars, in a process with no application server. That close is
|
|
311
|
-
* best-effort on the same terms as every other path: it is bounded by
|
|
312
|
-
* {@link viteCloseTimeoutMs}, and a Vite server that overruns the bound is
|
|
313
|
-
* warned about and abandoned rather than holding this call open. A dev server
|
|
314
|
-
* a later `listen()` has adopted is left alone — it belongs to that call now.
|
|
315
|
-
*
|
|
316
|
-
* The stop itself is bounded by {@link bunStopTimeoutMs}: a graceful stop
|
|
317
|
-
* waits on in-flight requests, and one that never finishes would otherwise
|
|
318
|
-
* hold this call open forever.
|
|
184
|
+
* Stops the server {@link listen} started; a no-op when nothing is listening
|
|
185
|
+
* or when called twice. `closeActiveConnections` forces in-flight requests
|
|
186
|
+
* closed, matching Bun's own `stop()`. The managed Vite dev server goes too,
|
|
187
|
+
* unless a later `listen()` adopted it. Both closes are bounded
|
|
188
|
+
* ({@link bunStopTimeoutMs}, {@link viteCloseTimeoutMs}) and then abandoned.
|
|
319
189
|
*/
|
|
320
190
|
stop(closeActiveConnections?: boolean): Promise<void>;
|
|
321
|
-
/**
|
|
322
|
-
* Register a service provider.
|
|
323
|
-
*/
|
|
324
191
|
register(provider: ServiceProviderConstructor): this;
|
|
325
|
-
/**
|
|
326
|
-
* Register multiple service providers.
|
|
327
|
-
*/
|
|
328
192
|
registerMany(providers: Array<ServiceProviderConstructor>): this;
|
|
329
|
-
/**
|
|
330
|
-
* Logs the rich development server banner to the console.
|
|
331
|
-
*/
|
|
332
193
|
logDevServerBanner(options: DevBannerOptions): void;
|
|
333
194
|
/**
|
|
334
195
|
* Closes the managed Vite dev server, but only while this application still
|
|
335
|
-
* owns it
|
|
336
|
-
*
|
|
337
|
-
*
|
|
338
|
-
* have adopted the running server — same object, new owner — and closing it
|
|
339
|
-
* then would take the asset server, and its published env vars, out from
|
|
340
|
-
* under an application that is actively serving from it. The record in the
|
|
341
|
-
* slot is the one place that distinction exists, so it is read here rather
|
|
342
|
-
* than mirrored on the instance.
|
|
196
|
+
* owns it: another `listen()` may have adopted the same object, and closing it
|
|
197
|
+
* then would take the asset server out from under an app serving from it. The
|
|
198
|
+
* slot's record is the one place that distinction exists.
|
|
343
199
|
*/
|
|
344
200
|
private closeViteDevServer;
|
|
345
201
|
/**
|
|
346
|
-
* Attaches this application's Vite teardown handlers and returns the disposer
|
|
347
|
-
*
|
|
348
|
-
*
|
|
349
|
-
* has to call it — and a disposer another app could spend would leave this
|
|
350
|
-
* instance believing its handlers are attached when they are not.
|
|
202
|
+
* Attaches this application's Vite teardown handlers and returns the disposer.
|
|
203
|
+
* It is stored in the active-record slot, not on this instance, because
|
|
204
|
+
* whoever takes ownership next is the one that has to call it.
|
|
351
205
|
*/
|
|
352
206
|
private registerViteTeardown;
|
|
353
207
|
private registerBunTeardown;
|
|
@@ -1,76 +1,25 @@
|
|
|
1
1
|
import type { Context } from 'hono';
|
|
2
2
|
import type { ValidationRule } from './validation/types.js';
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
* FormRequest encapsulates both validation rules and authorization logic
|
|
7
|
-
* for a single request type. Extend this class and define `rules()` and
|
|
8
|
-
* optionally `authorize()` to create type-safe request validation.
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* ```typescript
|
|
12
|
-
* interface StorePostData {
|
|
13
|
-
* title: string
|
|
14
|
-
* content: string
|
|
15
|
-
* status: 'draft' | 'published'
|
|
16
|
-
* }
|
|
17
|
-
*
|
|
18
|
-
* class StorePostRequest extends FormRequest<StorePostData> {
|
|
19
|
-
* rules() {
|
|
20
|
-
* return {
|
|
21
|
-
* title: [required(), stringRule(), min(3), max(255)],
|
|
22
|
-
* content: [required(), stringRule()],
|
|
23
|
-
* status: [required(), inValues(['draft', 'published'])],
|
|
24
|
-
* }
|
|
25
|
-
* }
|
|
26
|
-
*
|
|
27
|
-
* async authorize() {
|
|
28
|
-
* return (await this.user()) !== null
|
|
29
|
-
* }
|
|
30
|
-
* }
|
|
31
|
-
*
|
|
32
|
-
* // In controller:
|
|
33
|
-
* const data = await new StorePostRequest().handle(this.ctx)
|
|
34
|
-
* // data is typed as StorePostData
|
|
35
|
-
* ```
|
|
4
|
+
* Validation rules and authorization for one request type, in one class.
|
|
36
5
|
*
|
|
37
6
|
* @deprecated Legacy compatibility layer — prefer schema-first validation
|
|
38
7
|
* via `this.validateBody()` / `validateQuery()` / `validateParams()`.
|
|
39
8
|
*/
|
|
40
9
|
export declare abstract class FormRequest<T = Record<string, unknown>> {
|
|
41
10
|
protected ctx: Context;
|
|
42
|
-
/**
|
|
43
|
-
* Define validation rules for this request.
|
|
44
|
-
* Return an object mapping field names to arrays of validation rules.
|
|
45
|
-
*/
|
|
46
11
|
abstract rules(): Record<string, ValidationRule[]>;
|
|
47
|
-
/**
|
|
48
|
-
* Determine if the user is authorized to make this request.
|
|
49
|
-
* Override to implement authorization logic. Defaults to true.
|
|
50
|
-
*/
|
|
51
12
|
authorize(): boolean | Promise<boolean>;
|
|
52
|
-
/**
|
|
53
|
-
* Custom error messages for validation rules.
|
|
54
|
-
* Override to provide custom messages.
|
|
55
|
-
*/
|
|
13
|
+
/** Override to customize validation messages. */
|
|
56
14
|
messages(): Record<string, string>;
|
|
57
|
-
/**
|
|
58
|
-
* Custom attribute names for validation errors.
|
|
59
|
-
* Override to provide human-readable field names.
|
|
60
|
-
*/
|
|
15
|
+
/** Override to give fields human-readable names in errors. */
|
|
61
16
|
attributes(): Record<string, string>;
|
|
62
17
|
/**
|
|
63
|
-
* Get the authenticated user from the request context.
|
|
64
|
-
*
|
|
65
18
|
* Awaiting is load-bearing: `this.user() !== null` compiles and is always
|
|
66
19
|
* true, because an unawaited call is a pending promise.
|
|
67
20
|
*/
|
|
68
21
|
protected user<TUser = unknown>(): Promise<TUser | null>;
|
|
69
|
-
/**
|
|
70
|
-
* Handle the form request: authorize, parse body, validate, return typed data.
|
|
71
|
-
* Call it from a controller with the request context:
|
|
72
|
-
* `const data = await new StorePostRequest().handle(this.ctx)`.
|
|
73
|
-
*/
|
|
22
|
+
/** Authorize, parse the body, validate, return typed data. */
|
|
74
23
|
handle(ctx: Context): Promise<T>;
|
|
75
24
|
private parseBody;
|
|
76
25
|
}
|