Elysia 1.4
Last reviewed Sep 25, 2026
Prompt Details
Prompt Composition
3prompts
- JavaScript ES2026102 lines · 3.1K tokens
- TypeScript 746 lines · 1.5K tokens
- Elysia 1.472 lines · 3.6K tokens
Total220 lines · 8.2K tokens
CWE Coverage
- 20
- 22
- 59
- 73
- 79
- 89
- 95
- 117
- 200
- 208
- 209
- 287
- 323
- 338
- 346
- 347
- 352
- 362
- 434
- 459
- 471
- 488
- 494
- 502
- 524
- 532
- 602
- 613
- 614
- 639
- 770
- 807
- 829
- 838
- 862
- 863
- 915
- 916
- 918
- 922
- 942
- 943
- 1004
- 1275
- 1321
- 1333
Prompt Preview
Apply the TypeScript 7 prompt first. These rules cover Elysia 1.4 and were checked against 1.4.30. Apply Bun server and WebSocket settings only to the Bun adapter; verify equivalent controls on the actual Node.js adapter or Fetch-based host. Pin independently versioned plugins compatible with Elysia 1.4.
Routes, lifecycle, and authorization
- Register guards and route lifecycle hooks before protected routes and before
.use()imports their routes. For hooks with scope,localcovers the declaring instance and its descendants;scopedadditionally reaches its immediate parent, andglobalpropagates through ancestors. Export a security plugin's hooks deliberately withasrather than assuming.use(plugin)protects subsequent parent routes. - Perform authentication and resource authorization in
resolveoronBeforeHandlebefore handlers perform effects.deriveandonTransformrun before schema validation; use their input as unvalidated data. Orderresolvebefore hooks that consume its principal, and check tenant, ownership, operation, and current resource state. - Treat
onRequestas global and pre-routing: it lacks validated body, parameters, and derived identity. Returning a value skips the remaining lifecycle, so an early cache response must independently satisfy authorization and privacy requirements. - Return a denial such as
return status(401, 'Unauthorized')frombeforeHandle, or throw a handled error. Merely settingset.statusdoes not stop the handler. Keep authorization out ofafterHandle,mapResponse, andafterResponse, which