Elysia 1.4

Last reviewed Sep 25, 2026

Export as PDF

Prompt Details

Prompt Composition

3prompts
  1. JavaScript ES2026102 lines · 3.1K tokens
  2. TypeScript 746 lines · 1.5K tokens
  3. 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, local covers the declaring instance and its descendants; scoped additionally reaches its immediate parent, and global propagates through ancestors. Export a security plugin's hooks deliberately with as rather than assuming .use(plugin) protects subsequent parent routes.
  • Perform authentication and resource authorization in resolve or onBeforeHandle before handlers perform effects. derive and onTransform run before schema validation; use their input as unvalidated data. Order resolve before hooks that consume its principal, and check tenant, ownership, operation, and current resource state.
  • Treat onRequest as 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') from beforeHandle, or throw a handled error. Merely setting set.status does not stop the handler. Keep authorization out of afterHandle, mapResponse, and afterResponse, which