Security:
- #891 Upgrade Cookie to 0.7.x to fix CVE-2024-47764
Bug fix:
Bug fix:
- Handle object with
.then
even if it's not promise (looking at you, Drizzle)
Bug fix:
- Fix
set-cookie
to resent if value is accessed even without set
Improvement:
- infer 200 response from handle if not specified
Bug fix:
- merge guard and not specified hook responses status
Bug fix:
- unable to return
error
from derive/resolve
Breaking change:
- remove automatic conversion of 1-level deep object with file field to formdata
- migration: wrap a response with
formdata
- migration: wrap a response with
- (internal): remove
ELYSIA_RESPONSE
symbol - (internal)
error
now useclass ElysiaCustomStatusResponse
instead of plain object
Improvement:
- Optimize
object type
response mapping performance
Change:
- Coerce number to numeric on body root automatically
- Coerce boolean to booleanString on body root automatically
Bug fix:
- #838 invalid
onAfterResponse
typing - #855 Validation with Numeric & Number options doesn't work
- #843 Resolve does not work with aot: false
Bug fix:
- separate between
createStaticHandler
andcreateNativeStaticHandler
for maintainability - performance degradation using inline fetch on text static response and file
Bug fix:
createStaticResponse
unintentionally mutateset.headers
Feature:
- add auto-completion to
Content-Type
headers
Bug fix:
- exclude file from Bun native static response until Bun support
- set 'text/plain' for string if no content-type is set for native static response
Feature:
- #813 allow UnionEnum to get readonly array by @BleedingDev
Bug fix:
- #830 Incorrect type for ws.publish
- #827 returning a response is forcing application/json content-type
- #821 handle "+" in query with validation
- #820 params in hooks inside prefixed groups are incorrectly typed never
- #819 setting cookie attribute before value cause cookie attribute to not be set
- #810 wrong inference of response in afterResponse, includes status code
Feature:
- setup provenance publish
- #808 add UnionEnum type with JSON schema enum usage
- #807 add closeActiveConnections to Elysia.stop()
Bug fix:
- #808 ArrayString type cast as Object instead of Array
- config.nativeStaticResponse is not defined
Feature:
- native Bun static response
- can be disabled by setting
app.config.nativeStaticResponse = false
- can be disabled by setting
- #93 export TypeSystemPolicy
- #752 tye coercion on dynamic mode
Bug fix:
- #332 mount() does not preserve body when fetching through http server
- Using as('plugin') cast cause derive key to be unknown
Bug fix:
- incorrect named export 'fasti-querystring' to 'fast-querystring'
Change:
- getter fields no longer stringified to JSON by default on returning response
Bug fix:
- #796 ValueClone: Unable to clone value after 1.1.8 update
- #795 Broken Dates after 1.1.8 update
- #793 Unable to delete property. t.File()
Feature:
- #748 add standardHostname config
Bug fix:
- #787 #789 #737 Unexpected TypeError on NODE_ENV=production in mapValueError
- #793 unable to delete property t.File()
- #780 error from sending empty body multipart/form-data
- #779 custom errors thrown in onRequest are not usable when caught in onError
- #771 error from body-parser when sent Content-Type header without body
- #679 plugin registered by async inline function don't work
- #670 support for classes and getter fields
Bug fix:
parseQuery
is not parsing array on body
Change:
- rename
parseQuery
toparseQueryFromURL
- export fast-querystring.js path
Feature:
- #763 add hide in detail to hide route from OpenAPI/swagger
- add streaming support for fetch proxy
Bug fix:
- #776 custom errors throw in onRequest do not get proper code set in onError
Feature:
- refactor fastQuerystring using switch and bitwise flag
Bug fix:
- sucrose: invalid separateFunction on minified async function
- #758 guard doesn't apply cookie schema
Feature:
- #718 implement normalization support for class instances with getter functions
Bug fix:
- removeColonAlias accidentally slice -2 end index for last parameter
- #726 lazy instantiation of
stringToStructureCoercions
- #750 Cookie: Right side of assignment cannot be destructured
- #749 Query params following an array query are parsed as array items
- #751 Dynamic mode response failed if null or undefined value is returned
- #741 stream stringify object
Change:
- sucrose: exact inference name
- use
mapResponse
instead ofmapCompactResponse
for stream - defers first stream execution before returning response
- #722 derive context is not passed to onError
Bug fix:
onError
with scope not being able to infer context type
Bug fix:
- #724, bun#12594 sucrose: possibly fix
bun build --compile
not being able to infer first, and last context parameter - derive is being override by resolve in certain function
- #722 Type error with global
app.derive
followed by onError
- #722 Type error with global
- params on
onError
is now{ [key in string]: string }
instead ofnever
- #721 unexpected isContextPassToFunction: minified whitespace of arrow function causing inaccurate separateFunction
Breaking Change:
- parse query as
string
instead ofstring | string[]
unless specified
Feature:
- Trace v2
- Normalization is on by default
- Data type coercion
- Guard as, bulk as cast
- Response status coercion
- Optional path parameter
- Generator response stream
Breaking Change:
- Parse value as string for all validators unless explicitly specified.
- Rename
onResponse
toonAfterResponse
- [Internal] Remove $passthrough in favor of toResponse
- [Internal] UnwrapRoute type now always resolve with status code
Improvement:
- Add auto-complete for
set.headers
- Add
server
property onError
supports array function- Parse query object with and without schema
- Sucrose: improve isContextPassToFunction, and extractMainParameter stability
- Add
replaceSchemaType
- Add
route
tocontext
- Optimize recursive MacroToProperty type
- Parse query array and object
- Optimize code path for
composeGeneralHandler
- Add debug report on compiler panic
- Reduce memory usage of route registration ~36% on large codebase
- Reduce compilation code path
- Remove trace inference
- Reduce router compilation code path
- removing route handler compilation cache (st${index}, stc${index})
- Add undefined union to cookie in case if cookie is not present
- Optimize response status resolve type inference
Change:
- Deprecated
ObjectString
for parsing array - Using
Cookie<unknown>
instead ofCookie<any>
if schema is not defined - Remove prototype poluation from hook
- remove static analysis for query name
- remove query replace '+' in favor removing static query analysis
- mapResponse is now called in error event
- reconcilation decorator in type level
Bug fix:
- Normalize headers accidentally use query validator check instead
onError
missing trace symbol- Headers validator compilation is not cached
- Deduplicate macro propagation
- Websocket in nested group now work
- Error response is not check unless successful status code is provided
Bug fix:
Bug fix:
- mapResponse is not called on beforeHandle, and afterHandle
Bug fix:
- type is resolved as
File
if@types/bun
is not installed when using with Eden Treaty
Bug fix:
derive
,resolve
support void return- #677 Query params validation for array of string fail
Feature:
- add
toResponse
for mapping custom response - #606 Object encoding in query parameters
Bug fix:
- #654 set correct normalization behavior for addtional properties
- #649 cookie decode value might be null
- #664 "default" option is not being applied on validation
- #656 ctx.query doesn't work in some case
- set forceDynamicQuery to true by default
- #658 aot does not recognize the use of ctx.body within a try catch
- #630 accessing ctx.query directly breaks the object
Breaking Change:
- set default cookie path to
/
Feature:
- add
form
utility for returning explicit formdata - add object with image to return as
formdata
Bug fix:
- return
Bun.file
by specifyingt.File()
andt.Object({ any: t.File() })
as a response
Breaking Change:
t.type({ error })
now accepts(error: ({ type, validator, value, errors }) => unknown)
instead of(error: (type, validator, value) => unknown)
Improvement:
t.type({ error })
acceptsstring | number | boolean | Object
instead ofstring
t.type({ error })
returnstring | number | boolean | Object | void
instead ofstring
- add
errors: ValueError[]
tot.type({ error({ errors }) {} })
Bug fix:
- #644 redirect doesn't work with
aot: false
- #641 cookie schema validation doesn't work with
aot: true
- #615 highlight derive and resolve when using
onError
Bug fix:
- macro is not inherits inside group
Bug fix:
- remove set.clone spread operator for mapping Response
Feature:
- add support for partitioned cookie
Bug fix:
- recursive MacroToProperty type on unknown macro
Improvement:
- add context.url to get full URL string (including query)
- reduce query parsing instruction
Bug fix:
- ratelimit#28 trace hang when using server-timing with rate-limit plugin
Feature:
- add
redirect
function toContext
Improvement:
- sucrose: remove unreachable query bracket check, reduce bracket instruction
- sucrose: query accessor keyword check at initialization instead of in loop
- sucrose: remove accessor check
- sucrose: skip query check for immediate return
Change:
- sucrose: add
isArrowReturn
toseparateFunction
- sucrose: skip inference queries check if
query
is not found
Change:
- allow custom parser when
type
is specified - add
contentType
to context - soft deprecate
contentType
as 2ndparse
parameter
Bug fix:
- #622 sucrose: mistake cookie for query
- duplicate format found
- using
parse
,type
,body
generate invalid syntax
Improvement:
- #596 account for 20x response status schemas for type safety
Bug fix:
- #615
- 588 separate async derive/resolve function doesn't get await
- primitive thrown result in invalid type
Improvement:
- export
InferContext
andInferHandler
Bug fix:
- remove accidental
console.log
incompile
Feature:
- add
InferContext
Bug fix:
- returning null with response validation cause error
Bug fix:
- possibly fix for "Duplicate type kind 'Files' detected"
- add ajv-formats
- #562 %26 (&) to be interpreted as & (query separator)
Bug fix:
- ServerTiming#1 late beforeHandle on set trace inference doesn't produce exit instruction
Feature:
Elysia.config.detail
constructor- shorthand
Elysia.tags
to constructor,LocalHook
- guard inherits detail
Bug fix:
- inference link on
precompile: false
creating unnecessary instruction
Feature:
- #562 add
normalize
config
Improvement:
- Scope cookie instruction to route level instead of global config
- #557 cache tsc buildinfo for running faster
- #551 use AnyElysia instead of inline Elysia
Bug fix:
Feature:
- add Elysia.propagate to propagate hook type from 'local' to 'scoped'
Improvement:
- remove function.$elysia
- remove function extension
Bug fix:
- duplicate macro call
- #548 additional case for "accessing all query params using property name (ctx.query) doesn't work anymore"
- #599 plugin with scoped settings not functioning correctly
Bug fix:
- inline function doesn't propagate correctly on type level
Improvement:
- using regex for date pattern matching before using new Date validation
- using tsc to emit declaration file instead of tsup
- add
mapResponse
to MacroManager
Bug fix:
- Ephemeral and Volatile type isn't recognize by MacroManager
- inline guard cookie doesn't apply to local instance
Improvement:
- resolve, derive soundness
Improvement:
- Reduce instruction for static resource
Bug fix:
- Fix returning mulitple status code using
error
doesn't accept the response
Feature:
- add
scoped
support forderive
andresolve
Improvement:
- Type soundness
- type inference performance improvement
Improvement:
mapHandler
now check passthrough once instead of twice- exclude return type of
ELYSIA_RESPONSE
type fromderive
andresolve
- throw error if
error
is return inderive
andresolve
- handle
return error
ontransform
- #502 merge response schema from parent scope
Bug fix:
- explicit
type: 'json'
with body schema throw unexpectedbody.Check
is not a function - #549 await the .modules of nested Elysia instances
- #548 Accessing all query params using property name (ctx.query) doesn't work anymore
Improvement:
- fine-grained reactive cookie
- using single source of truth for cookie
- macro support for websocket
- add
mapResolve
- add
{ as: 'global' | 'scoped' | 'local' }
to lifecycle event - add ephemeral type
- inline
error
to handler - inline
error
has auto-completion and type checking based on status code - handler now check return type of
error
based on status code - utility
Elysia._types
for types inference - #495 Provide user friendly error for failed parse
- handler now infers return type for error status for Treaty
t.Date
now allow stringified date- improves type test case
- add test case for all life-cycle
- resolve, mapResolve, derive, mapDerive use ephemeral type to scope down accurately
- inference query dynamic variable
Breaking Change:
- #513 lifecycle is now local first
Change:
- group private API property
- move
Elysia.routes
toElysia.router.history
- detect possible json before return
- unknown response now return as-is instead of JSON.stringify()
- change Elysia validation error to JSON instead of string
- static content evalute hook JIT instead of AOT
Bug fix:
- #466 Async Derive leaks request context to other requests if
aot: true
- #505 Empty ObjectString missing validation inside query schema
- #503 Beta: undefined class when using decorate and derive
- onStop callback called twice when calling .stop
- mapDerive now resolve to
Singleton['derive']
instead ofSingleton['store']
ValidationError
doesn't returncontent-type
asapplication/json
- validate
error(status, value)
validate per status - derive/resolve always scoped to Global
- duplicated onError call if not handled
- #516 server timing breaks beforeHandle guards
- cookie.remove() doesn't set correct cookie path
Feature:
- #474 Numeric Cookie with length >= 16 cant be parsed to number
- #476 Using a query key that contains a hyphen or a dot raises a SyntaxError
- #460
Change:
- #472 Move documentation issue template to documentation repository
Feature:
- #448 BooleanString - @bogeychan
Bug fix:
Bug fix:
- #451 macro does not run when it should (macro deduplication)
- #450 Local hook parse doesn't get executed with
aot: false
Bug fix:
- types are missing in
exports.*
- #441 Vite doesn't get bundle without main
Bug fix:
- types is not import
- bun build regression on export * from '@sinclair/typebox/system'
- update memoirist to use mjs
Change:
- using .mjs for es module
Change:
- using tsup instead of swc
- #441 remove nanoid, using web crypto randomInt instead
Bug fix:
- #446 numeric string check to use Number instead of parseInt
- #445 empty body custom response when set.headers is empty
Bug fix:
- #440 query params with + sign did not get converted
- #433 remove crypto, unblock vite bundling, cloudflare worker support
- #422 add check for instanceof if constructor.name doesn't match
Bug fix:
- macro panic
Bug fix:
- Add TypeBox back to Bun bundle
Improvement:
- #385 If error is instanceof Response, respond with it
Bug fix:
- onRequest doesn't early return
- handle thrown error function
- #373 cookie is not set when File is return
- #379 WebSocket: Sending a space character ' ' receives 0
- #317 Exclude TypeBox from bundling
Bug fix:
- body without default value thrown Object.assign error
Bug fix:
- Bun entry point
Bug fix:
- macro caused an Object.entries cannot be undefined
mapResponse
andafterHandle
missing decorators
Bug fix:
- add early return on
isContextPassToFunction
for static content to prevent invalid regex
Bug fix:
ctx.path
andctx.qi
is missing when usingonRequest
Bug fix:
be
is undefined when usingafterResponse
withmapResponse
Feature:
headers
initialization function- macro
- static content
- default property
- error function
- add stack trace to plugin checksum configurable by
config.analytic
(default to false) - new life-cycle
resolve
: derive after validationmapResponse
: custom response mapping
Improvement:
- lazy query reference
- add content-range header to
File
andBlob
by default if etag is not used - update TypeBox to 0.32
- override lifecycle response of
be
andaf
Breaking Change:
afterHandle
no longer early return
Change:
- change validation response to JSON
- differentiate derive from
decorator['request']
asdecorator['derive']
derive
now don't show infer type in onRequest
Bug fix:
- remove
headers
,path
fromPreContext
- remove
derive
fromPreContext
- Elysia type doesn't output custom
error
onStart
doesn't reflect server
Improvement:
- #345 add font to
SchemaOptions
- Update
@types/cookie
to^0.6.0
Bug fix:
- #338 guard sandbox did not inherit global config.
- #330 preserve query params for mounted handler
- #332 reexport TSchema from typebox
- #319 TypeBox Ref error when using Elysia.group()
Bug fix:
- Emergency release override latest beta
Bug fix:
- WebSocket params conflict with defined type
- Inherits status code on custom error
Chore:
- Update
cookie
to0.6.0
Bug fix:
- #314 Unable to dereference schema with 'undefined' when using t.Ref
Bug fix:
- #312 default params type suggestion for WebSocket
- #310 Preserve original hostname when using
.mount()
- #309 t.RegExp doesn't work due to requiring default value
- #308 t.Numeric should not convert empty string to 0
- #305 Elysia({ scoped: true }) should still expose defined routes on type level
- #304 Using a hook/guard/schema with a handler function and request without body results in a "Unexpected end of JSON input"-error
- #299 Missing request.path parameter in .onRequest
- #289 Ability to localize TypeBox errors
- #272 onError handler has error property as undefined on Cloudflare Workers
- #210 t.Numeric not validating properly
- #188 Status codes of the error classes don't match the response through onError
- #140 plugin hierarchy messes up derive function in child plugin
- #27 Websocket definition in groups
Bug fix:
- duplicated lifecycle event if using function plugin async
Bug fix:
- Leaked type from
guard
callback andgroup guard
Bug fix:
- add
ReadableStream
to response mapping tomapResponse
Bug fix:
- Send
exit
status on early return with trace set
Change:
- Rewrite
trace
Bug fix:
- trace not awaiting multiple trace process
- trace hang on early
beforeHandle
return afterHandle
withtrace.afterHandle
AoT cause duplicate value header
Bug fix:
- #281 add cookie.remove options
- add
await traceDone
to early return
Bug fix:
trace
is stuck when inherits to plugin
Improvement:
- add unit test for
mapCompactResponse
,Passthrough
Bug fix:
- add
$passthrough
formapCompactResponse
Feature:
- add map handler for
ReadableStream
- add
$passthrough
for custom property for response mapping
Bug fix:
.route
acceptstring[]
instead ofstring
Change:
- remove
ElyEden
Feature:
- add
ElyEden
- re-add
id
to websocket
Bug fix:
- #255 removeCookie sends HTTP-Header that is ignored by the Browser
- #263 http and websocket on same route
- #269 Correct handling of Buffer object
Improvement:
t.Cookie
cookie option type- #253 platform agnostic cookie
- Decorator like
state
,decorate
andderive
, doesn't apply to WebSocketdata
- re-export
Static
from
Change:
- Update TypeBox to 0.31.17
- #218 Fix #213 prepend async redefined routes (partial fix)
- Using set
onRequest
doesn't set headers and status on empty error handler
Bug fix:
- Make
t.Files
parameter optional - model remap now using
TSchema
instead of literal type for creating type abstraction
Improvement:
- Using listener instead of microtick to handle
trace.set
- Set default cookie path to '/'
Bug fix:
- Duplicate group path when hook is provided
Bug fix:
- Handle cookie expire time
- Set default value of config.cookie.path to '/'
Improvement:
- Skip cookie validation if schema is empty object
Bug fix:
- Accept cookie property from constructor when schema is not defined
Bug fix:
- handle FFI object in deepMerge, fix Prisma
Bug fix:
- async instance cause config to be undefined
Bug fix:
- async instance cause type conflict
Bug fix:
- #210
t.Numeric
allowing plainString
t.ObjectString
allowing plainString
- #209
t.MaybeEmpty
toleratenull
andundefined
- #205 WebSocket routes not working in plugins
- #195, #201 allow WebSocket destructuring
Bug fix:
- Separate return type by status
Bug fix:
- inject derive to
GraceHandler
Bug fix:
- check for class-like object
- add
GraceHandler
to access bothapp
andcontext
Bug fix:
- resolve 200 by default when type is not provided
Bug fix:
- decorator and store is resolved as
undefined
inonError
hook - deepMerge with Module object
- Retain comment in
.d.ts
Bug Fix:
- Class property is removed when calling deepMerge
Feature:
- rewrite type
- rewrite Web Socket
- add mapper method
- add affix, prefix, suffix
- trace
- typeBox.Transfom
- rewrite Type.ElysiaMeta to use TypeBox.Transform
- new type:
- t.Cookie
- t.ObjectString
- t.MaybeEmpty
- t.Nullable
- add
Context
toonError
- lifecycle hook now accept array function
- true encapsulation scope
Improvement:
- static Code Analysis now support rest parameter
- breakdown dynamic router into single pipeline instead of inlining to static router to reduce memory usage
- set
t.File
andt.Files
toFile
instead ofBlob
- skip class instance merging
- handle
UnknownContextPassToFunction
- #157 WebSocket - added unit tests and fixed example & api by @bogeychan
- #179 add github action to run bun test by @arthurfiorette
Breaking Change:
- remove
ws
plugin, migrate to core - rename
addError
toerror
Change:
- using single findDynamicRoute instead of inlining to static map
- remove
mergician
- remove array routes due to problem with TypeScript
Bug fix:
- strictly validate response by default
t.Numeric
not working on headers / query / paramst.Optional(t.Object({ [name]: t.Numeric }))
causing error- add null check before converting
Numeric
- inherits store to instance plugin
- handle class overlapping
- #187 InternalServerError message fixed to "INTERNAL_SERVER_ERROR" instead of "NOT_FOUND" by @bogeychan
- #167 mapEarlyResponse with aot on after handle
Feature:
- #149 support additional status codes in redirects
Improvement:
- #157 added unit tests and fixed example & api
Bug fix:
- #167 mapEarlyResponse with aot on after handle
- #160 typo in test suite name
- #152 bad code in Internal server error class
Bug fix:
- Maximum callstack for duplicated deep class / object
- #121 Cannot use PrismaClient in .decorate or .state
Bug fix:
- Remove
const
andRemoveDeepWritable
from decorate to allow function call
Feature:
- #112 Route arrays
Bug fix:
- #107 Elysia handler local hooks not recognizing registered errors on app instance
Bug fix:
- Inherits state and error from plugin instance
Improvement:
- Automatically parse File to
Files
if set
Bug fix:
- #98 Add context.set.cookie to accept array of string
- #92 WebSocket beforeHandle unable to access plugins / state / derive's
Bug fix:
- inherits
onError
lifecycle from plugin instance
Bug fix:
- inherits
set
ifResponse
is returned
Bug fix:
- deduplicate plugin via global model
- duplicated life-cycle
- top-down plugin deduplication
- plugin life-cycle leak on new model
- add
Elysia.scope
to contain lifecycle, store, and decorators
Bug fix:
- make this.server.reload optional to make Node compatability work
- duplicate path name when using prefix config with group
- don't filter local event inside new plugin model group
- Remove post.handler in return
Bug fix:
- Make this.server.reload optional to make Node compatability work
Bug fix:
- #86 Group prefix repeating on inline function callback
- #88, onResponse hooks validation return non 400
Bug fix:
- Query is set to pathname when ? not presented in dynamic mode
Bug fix:
- Derive not working on dynamic mode
Bug fix:
- append routes on dynamic mode
Bug fix:
- use: Plugin type inference
Bug fix:
- Collide Elysia.prefix on other methods
Bug fix:
- Collide Elysia.prefix type
Bug fix:
- Collide Elysia.prefix type
- Add skip group with prefix instance see #85
Bug fix:
- resolve .code and [ERROR_CODE]
Change:
- Add ErrorCode symbol
Bug fix:
- Inline guard hook
- Error code not handled
- Set default query to {} when presented
Improvement:
- Drop usage of
node:process
to support Cloudflare Worker
Feature:
- Introducing Dynamic Mode (aot: false)
- Introducing
.mount
- Introducing
.error
for handling Strict Error Type - Plugin checksum for plugin deduplication
- Add
.onResponse
Improvement:
- TypeBox 0.30
- AfterHandle now automatically maps the value
- Using Bun Build for targeting Bun
- Support Cloudflare worker with Dynamic Mode (and ENV)
Change:
- Moved registerSchemaPath to @elysiajs/swagger
Feature:
- Add
addError
to declaratively add Error to scope - Add
afterHandle
now can return a literal value instead of limited to onlyResponse
Feature:
- Introduce
.mount
- Add dynamic mode for TypeBox
- Add $elysiaChecksum to deduplicate lifecycle event
- Add $elysiaHookType to differentiate between global and local hook in
use
Fix:
- Deduplication of plugin's lifecycle (see $elysiaHookType)
Change:
- Using Bun Build for target Bun
Breaking Change:
- [Internal] refactored
getSchemaValidator
,getResponseSchemaValidator
to named parameters - [Internal] moved
registerSchemaPath
to@elysiajs/swagger
Feature:
- [Internal] Add qi (queryIndex) to context
- Add
error
field to Elysia type system for adding custom error message
Feature:
- [Internal] Add support for accessing composedHandler via routes
Feature:
- Dynamic mode for Cloudflare Worker
- Support for registering custom error code
- Using
loosePath
(by default), and add `config.strictPath - Support for setting basePath
- Recursive path typing
Improvement:
- Slighty improve type checking speed
Bug Fix:
- recursive schema collision causing infinite type
Breaking Change:
- Remove Elysia Symbol (Internal)
Bug fix:
- ws resolve type to undefined instead of unknown cause unexpected type mismatched when not provided
Bug fix:
- #68 invalid path params when using numeric
Bug fix:
- #68 invalid optional query params when using numeric
Bug fix:
- update onAfterHandle to be Response only
Bug fix:
- async fn on Static Code Analysis
Bug fix:
- optimize
ws
plugin type
Bug fix:
mapEarlyResponse
is missing on request
Improvement:
- Respect explicit body type first
mapCompactResponse
onnull
orundefined
type
Bug fix:
- Mapped unioned type on Static Code Analysis
form
isundefined
when using parsingformData
Improvement:
- Respect inner scope of lifecycle first
- Add type support for local
afterHandle
Bug fix:
onAfterHandler
cause response to mutate on void
Improvement:
- Map CommonJS module in package.json
Improvement:
- Using tsc to compile CommonJS instead of SWC to support
module.exports
syntax
Bug fix:
- Add loosen type for onError's code for defying custom error status
Bug fix:
- Multiple onRequest cause error
Improvement:
- Experimental basic support for Static Code Analysis in Nodejs
Bug fix:
- h is undefined when using headers in Node environment
- Update Memoirist to 0.1.4 to support full CommonJS
Improvement:
- Add content-type support for 'none', 'arrayBuffer' / 'application/octet-stream'
- Add type support type registration of wildcard params
- Add support for 'config.basePath'
Improvement:
- Add support for returning a class instance
Bug fix:
- Bun is undefined on other runtime
Improvement:
- Using
new Response
instead of factoryResponse.json
Improvement:
- Using request.json() to handle application/json body instead of JSON.parse(await c.text())
Improvement:
- Add Static Code Analysis for conditional try-catch
- Reduce usage of method to accessor
Improvement:
- Add
mapCompactResponse
for static code analysis - Using
constructor.name
to inline object mapping - Using single assignment for URL destructuring
- Using default map for dynamic route to remove static map label and break
Bug fix:
- Web Socket context.headers is empty Elysia#46
Improvement:
- Static Code Analysis for fallback route
Bug fix:
- Remove constant generic from
state
to be mutable
Bug fix:
- Syntax error if multiple numeric type is set
- Prevent fallthrough behavior of switch map
Improvement:
- Add CommonJS support for running Elysia with Node adapter
- Remove manual fragment mapping to speed up path extraction
- Inline validator in
composeHandler
to improve performance - Use one time context assignment
- Add support for lazy context injection via Static Code Analysis
- Ensure response non nullability
- Add unioned body validator check
- Set default object handler to inherits
- Using
constructor.name
mapping instead ofinstanceof
to improve speed - Add dedicated error constructor to improve performance
- Conditional literal fn for checking onRequest iteration
- improve WebSocket type
Bug fix:
- Possible
Breaking Change:
- Rename
innerHandle
tofetch
- to migrate: rename
.innerHandle
tofetch
- to migrate: rename
- Rename
.setModel
to.model
- to migrate: rename
setModel
tomodel
- to migrate: rename
- Remove
hook.schema
tohook
- to migrate: remove schema and curly brace
schema.type
:
// from app.post('/', ({ body }) => body, { schema: { body: t.Object({ username: t.String() }) } }) // to app.post('/', ({ body }) => body, { body: t.Object({ username: t.String() }) })
- to migrate: remove schema and curly brace
- remove
mapPathnameRegex
(internal)
Bug fix:
- it recompile on async
Bug fix:
- detect promise on parse
- using swc to compile to commonjs
Improvement:
- Improve merge schema type
Bug fix:
- Add support for ALL method for dynamic path
- Add support for parser in pre-compiled body
Bug fix:
- Use Memoirist instead of Raikiri in ws
Improvement:
- Static Code Analysis on derive
Improvement:
- Re-compile on lazy modules
Improvement:
- Merge nested schema type
Fix:
- set default object handler to inherits
Fix:
- emergency override experimental version
Fix:
- CatchResponse to return 200 status code by default when using Eden Treaty
Fix:
- response schema doesn't unwrap response type
Fix:
- Update Raikiri stability
Improvement:
- Add support for
parse
in websocket #33
Fix:
- Inherits out-of-order
onError
life cycle in nested group - Update Raikiri to 0.1.2 to handle mangled part
Fix:
- Fix LocalHandler doesn't check single type response
Improvement:
- Update Raikiri to ^1.1.0
Improvement:
- perf: add static route main class
- perf: reduce
ComposedHandler
to function instead of nested object
Fix:
group
andguard
shouldn't decorate a request on type-level (acceptable on run-time level for shared memory)
Fix:
- Using default value check for
set.status
instead truthy value
Improvement:
- using
isNotEmpty
formapResponse
- pre check if
set.headers['Set-Cookie']
is array before converting to headers - using
mapPathnameAndQueryRegEx.exec(request.url)
instead ofrequest.url.match(mapPathnameAndQueryRegEx)
Fix:
- Scoped decorators
Improvement:
- Use constructor name for faster handler matching
- Map Promise
Fix:
- remove type module from package.json
Feature:
- Ahead of Time compilation
- TypeBox 0.26
- Validate response per status instead of union
- Add
if
for conditional route - Custom Validation Error
Improvement:
- Update TypeBox to 0.26.8
- Inline a declaration for response type
- Refactor some type for faster response
- Use Typebox
Error().First()
instead of iteration - Add
innerHandle
for returning an actual response (for benchmark)
Breaking Change:
- Separate
.fn
to@elysiajs/fn
Fix:
- child to inhertis WebSocket plugin (#27)
- multiple status response does not work with the group (#28)
Fix:
- Wildcard fallback of Raikiri
Feature:
- Elysia Fn
- Suport
multipart/form-data
t.File
andt.Files
for file validationschema.content
for specifying content type
Improvement:
- Add string format: 'email', 'uuid', 'date', 'date-time'
- Update @sinclair/typebox to 0.25.24
- Update Raikiri to 0.2.0-beta.0 (ei)
- Add file upload test thanks to #21 (@amirrezamahyari)
- Pre compile lowercase method for Eden
- Reduce complex instruction for most Elysia types
- Change store type to
unknown
- Compile
ElysiaRoute
type to literal - Optimize type compliation, type inference and auto-completion
- Improve type compilation speed
- Improve TypeScript inference between plugin registration
- Optimize TypeScript inference size
- Context creation optimization
- Use Raikiri router by default
- Remove unused function
- Refactor
registerSchemaPath
to support OpenAPI 3.0.3 - Add
error
inference for Eden - Mark
@sinclair/typebox
as optionalpeerDenpendencies
Fix:
- Raikiri 0.2 thrown error on not found
- Union response with
t.File
is not working - Definitions isn't defined on Swagger
- details are missing on group plugin
- group plugin, isn't unable to compile schema
- group is not exportable because EXPOSED is a private property
- Multiple cookies doesn't set
content-type
toapplication/json
EXPOSED
is not export when usingfn.permission
- Missing merged return type for
.ws
- Missing nanoid
- context side-effects
t.Files
in swagger is referring to single file- Eden response type is unknown
- Unable to type
setModel
inference definition via Eden - Handle error thrown in non permission function
- Exported variable has or is using name 'SCHEMA' from external module
- Exported variable has or is using name 'DEFS' from external module
- Possible errors for building Elysia app with
declaration: true
intsconfig.json
Breaking Change:
- Rename
inject
toderive
- Depreacate
ElysiaRoute
, changed to inline - Remove
derive
- Update from OpenAPI 2.x to OpenAPI 3.0.3
- Move context.store[SYMBOL] to meta[SYMBOL]
Improvement:
- Add string format: 'email', 'uuid', 'date', 'date-time'
Fix:
- Raikiri 0.2 thrown error on not found
Improvement:
- Update @sinclair/typebox to 0.25.24
- Update Raikiri to 0.2.0-beta.0 (ei)
- Add file upload test thanks to #21 (@amirrezamahyari)
Fix:
- Union response with
t.File
is not working
Fix:
- Definitions isn't defined on Swagger
- details are missing on group plugin
- group plugin, isn't unable to compile schema
- group is not exportable because EXPOSED is a private property
Fix:
- console.log while using cookie
Breaking Change:
- Rename
inject
toderive
Fix:
- Multiple cookies doesn't set
content-type
toapplication/json
EXPOSED
is not export when usingfn.permission
Fix:
- Missing merged return type for
.ws
Fix:
- Missing nanoid
Fix:
- context side-effects
Improvement:
- Pre compile lowercase method for Eden
Improvement:
- ~33% faster for compiling type inference
- Reduce complex instruction for most Elysia types
- Change store type to
unknown
Fix:
t.Files
in swagger is referring to single file- Eden response type is unknown
Improvement:
- Compile
ElysiaRoute
type to literal - Optimize type compliation, type inference and auto-completion
- Improve type compilation speed by ~3x
Fix:
- Unable to type
setModel
inference definition via Eden
Breaking Change:
- Depreacate
ElysiaRoute
, changed to inline
Fix:
- Handle error thrown in non permission function
Feature:
- Elysia Fn
- Suport
multipart/form-data
t.File
andt.Files
for file validationschema.content
for specifying content type
Improvement:
- Improve TypeScript inference between plugin registration
- Optimize TypeScript inference size
- Context creation optimization
- Use Raikiri router by default
- Remove unused function
- Refactor
registerSchemaPath
to support OpenAPI 3.0.3 - Add
error
inference for Eden - Mark
@sinclair/typebox
as optionalpeerDenpendencies
Fix:
- Exported variable has or is using name 'SCHEMA' from external module
- Exported variable has or is using name 'DEFS' from external module
- Possible errors for building Elysia app with
declaration: true
intsconfig.json
Breaking Change:
- Remove
derive
- Update from OpenAPI 2.x to OpenAPI 3.0.3
- Move context.store[SYMBOL] to meta[SYMBOL]
Bug fix:
group
doesn't inheritsonError
Bug fix:
group
doesn't inheritsonError
Improvement:
- Remove
bind(this)
Feature:
- Add supports for multiple cookie
Improvement:
- Minor optimization
Improvement:
- Using SWC to bundle and minification
- Minor optimization
Improvement:
- Update Raikiri to 0.0.0-beta.4
Change:
- Remove strictPath option and enabled by default
Improvement:
- Migrate from @medley/router to Raikiri
- Minor optimization
Improvement:
- Map OpenAPI's schema detail on response
- Fix Type instantiation is excessively deep and possibly infinite
- Improve TypeScript inference time by removing recursive type in generic
- Inferred body is never instead of unknown
Feature:
- Add support for reference model via
.model
- Add support for OpenAPI's
definitions
field
Feature:
- Add support for custom openapi field using
schema.detail
- Add support for custom code for
response
Improvement:
- Unioned status type for response
- Optimize TypeScript inference performance
Breaking Change:
onParse
now accepts(context: PreContext, contentType: string)
instead of(request: Request, contentType: string)
- To migrate, add
.request
to context to accessRequest
- To migrate, add
Feature:
onRequest
andonParse
now can accessPreContext
- Support
application/x-www-form-urlencoded
by default
Improvement:
- body parser now parse
content-type
with extra attribute eg.application/json;charset=utf-8
Feature:
- Support for Async / lazy-load plugin
Improvement:
- Decode URI parameter path parameter
- Handle union type correctly
Improvement:
- Validate
Response
object - Union type inference on response
Bug fix:
- onRequest doesn't run in
group
andguard
Improvement:
- Parse encoded URI on querystring
- Exclude URI fragment from querystring
- Blasphemy hack for updating Elysia server using
--hot
- Exclude fragment on
getPath
[Reburn] is the first stable beta release for Elysia.
Happy Christmas, wishing you happy tonight as we release the first stable release of Elysia.
With this API is now stabilized, and Elysia will focus on growing its ecosystem and plugins for common patterns.
Introducing Eden, a fully type-safe client for Elysia server like tRPC.
A 600 bytes client for Elysia server, no code generation need, creating a fully type-safe, and auto-complete for both client and server.
See Eden in action on Twitter
With a lot effort put into micro-optimization and re-architecture, Elysia is the fastest Bun web framework benchmarked on 24 December 2022, outperformed 2/3 category put into test.
See benchmark results at Bun http benchmark
Elysia now have an improved documentation at elysiajs.com.
Now with a proper landing page, searchable content, and revised content put into.
Merry Christmas, and happy new year.
As 0.1 released, we recommended to give Elysia a try and build stuff with it.
With the wonderful tools, we are happy to looking forward to see what wonderful software will you build.
Fly away, let me fly away Never hide in dark Head on, start a riot Fly away, defying fate in my way Crush it Make it! Feel My Heart!
Change:
- Remove cjs format as Bun can import ESM from CJS
- Remove comment on build file, rely on .t.ds instead
Change:
- Support plugins which use
getPath
, andmapQuery
on 0.1.0-rc.6
Improvement:
- Infers type from
group
, andguard
Change:
Elysia.handle
now only accept validURL
Improvement:
- Minor optimization
Router.register
now returns type- Inline default bodyParser
Fix:
.listen
object is now optional
Breaking Change:
onError
change its type:
// Previously
onError: (error: Error, code: ErrorCode)
// Now
onError: (params: {
error: Error
code: ErrorCode
set: Context['set']
}) => any
To migrate, add curly brace to onError
parameters.
onRequest
change its type:
// Previously
onRequest: (request: Request, store: Instance['Store']) => any
// Now
onRequest: (params: {
request: Request,
store: Instance['store']
set: Context['set']
})
To migrate, add curly brace to onRequest
parameters.
Feature:
- Manual patch for bun#1435, and unblock test suite for error handler.
Fix:
- Remove
console.log
for '*'
Feature:
- Strict type for
SCHEMA
- Infered type parameters for
SCHEMA
Fix:
- Auto prefix path with
/
for non - Fallback catch all route for registered parameter
Fix:
- skip body parsing for 'HEAD'
- missing response status on some error
- compatability for cjs
- add main fields for Bundlephobia supports
- add declaration file for both esm and cjs
- ship
src
for TypeScript support withdeclare global
Stabilized API
Feature:
- add header access to context via
context.header
Breaking Change:
- rename
schema.header
toschema.headers
Bug fix:
inject
now acceptContext
Feature:
derive
to creating derive stateinject
to decorate method based on context
Feature:
.all
for registering path with any method
Improvement:
getSchemaValidator
now infer output type to be reusable with@kingworldjs/trpc
Bug fix:
handler.hooks
is undefined on 404
Improvement:
- Decorators is now lazily allocate
.serve
now accept numberic string as port for convenient withprocess.env
[Just Right Slow] introduce breaking major changes of KingWorld, specific on a plugin system.
Previously, we define plugin by accepting 2 parameters, KingWorld
and Config
like this:
const plugin = (app: KingWorld, config) => app
new KingWorld().use(plugin, {
// Provide some config here
})
However, this has flaw by the design because:
- No support for async plugin
- No generic for type inference
- Not possible to accept 3...n parameters (if need)
- Hard/heavy work to get type inference
To fix all of the problem above, KingWorld now accept only one parameter.
A callback which return KingWorld Instance, but accept anything before that.
const plugin = (config) => (app: KingWorld) => app
new KingWorld().use(plugin({
// provide some config here
}))
This is a workaround just like the way to register async plugin before exp.51, we accept any parameters in a function which return callback of a KingWorld instance.
This open a new possibility, plugin can now be async, generic type is now possible.
More over that, decorate can now accept any parameters as it doesn't really affect any performance or any real restriction.
Which means that something like this is now possible.
const a = <Name extends string = string>(name: Name) => (app: KingWorld) => app.decorate(name, {
hi: () => 'hi'
})
new KingWorld()
.use(a('customName'))
// Retrieve generic from plugin, not possible before exp.51
.get({ customName } => customName.hi())
This lead to even more safe with type safety, as you can now use any generic as you would like.
The first plugin to leverage this feature is jwt which can introduce jwt function with custom namespace which is type safe.
Change:
- new
decorators
property for assigning fastContext
Improvement:
- Faster router.find performance
- Faster query map performance
- Early return on not found
- Better type for
router
Change:
- Remove
storeFactory
from router
Bug fix:
- Conditionally return header in response
Bug fix:
- Import Context as non-default
- TypeScript's type not infering Context
Bug fix:
- Remove
export default Context
as it's a type - Import Context as non-default
Bug fix:
- Add custom response to
Blob
Bug fix:
- Set default HTTP status to 200 (oven-sh/bun#1523)
Improvement:
- Faster object iteration for setting headers
KingWorld
config now acceptServe
includingSSL
Change:
- Use direct comparison for falsey value
Bug fix:
- Router doesn't handle part which start with the same letter
Change:
- Internal schema now use correct OpenAPI type (KingWorld need CORRECTION 💢💢)
Breaking Change:
Context
is nowinterface
(non-constructable)responseHeaders
,status
,redirect
is now replaced withset
- To migrate:
// From app.get('/', ({ responseHeaders, status, redirect }) => { responseHeaders['server'] = 'KingWorld' status(401) redirect('/') }) // To app.get('/', ({ set }) => { set.headers['server'] = 'KingWorld' set.status = 401 set.redirect = '/' })
Improvement:
- Global
.schema
now infer type for handler - Add JSDocs for main method with example
.listen
now acceptBun.Server
as a callback function- Response support for
FileBlob
Breaking Change:
method
is changed toroute
Improvement:
LocalHook
now prefers the nearest type instead of the merge- Merge the nearest schema first
- add
contentType
as a second parameter forBodyParser
Bug fix:
- Correct type for
after handle
- Fix infinite cycling infer type for
Handler
Bug fix:
- Correct type for
afterHandle
[Sage] is one of the major experimental releases and breaking changes of KingWorld.
The major improvement of Sage is that it provides almost (if not) full support for TypeScript and type inference.
KingWorld has a complex type of system. It's built with the DRY principle in mind, to reduce the developer's workload.
That's why KingWorld tries to type everything at its best, inferring type from your code into TypeScript's type.
For example, writing schema with nested guard
is instructed with type and validation.
This ensures that your type will always be valid no matter what, and inferring type to your IDE automatically.
You can even type response
to make your that you didn't leak any important data by forgetting to update the response when you're doing a migration.
KingWorld's validator now replaced zod
, and ajv
with @sinclair/typebox
.
With the new validator, validation is now faster than the previous version by 188x if you're using zod, and 4.1x if you're using ajv adapter.
With Edge Computing in mind, refactoring to new validate dropped the unused packages and reduced size by 181.2KB. To give you an idea, KingWorld without a validator is around 10KB (non-gzipped).
Memory usage is also reduced by almost half by changing the validator.
According to M1 Max running example/simple.ts
, running exp.36 uses 24MB of memory while exp.37 use 12MB of memory
This greatly improves the performance of KingWorld in a long run.
Breaking Change:
- Replace
zod
,zod-to-json-schema
,ajv
, with@sinclair/typebox
Improvement:
use
now accept any nonKingWorld<{}, any>
use
now combine typed between current instance and pluginuse
now auto infer type if function is inlineLocalHook
can now inferparams
type from path string
Change:
TypedSchema
is now replaced withInstance['schema']
Breaking Change:
AfterRequestHandle
now accept (Context
,Response
) instead of(Response, Context)
Improvement:
.guard
now combine global and local recursively.use
now inherits schema
Bug fix:
- Remove
console.log
on failed validation
Improvement:
- Add Ajv 8.11.0
- Error log for validation is updated to
instancePath
Feature:
.schema
for global schema validation.start
,.stop
and acceptKingWorld<Instance>
as first parameter
Improvement:
.guard
now auto infer type from schema toHandler
- scoped
.guard
now inherits hook NewInstance
now inheritsInheritSchema
Bug fix:
- Rename
afterHandle
toonAfterHandle
to match naming convention - Make
afterHandle
inRegisterHook
optional - Internal type conversion between
Hook
,LocalHook
Feature:
- add
afterHandle
hook
Improvement:
- Using
WithArray<T>
to reduce redundant type
Bug fix:
beforeHandle
hook doesn't accept array
Bug fix:
- Add
zod
by default
Bug fix:
- Add
zod-to-json-schema
by default
[Regulus]
This version introduces rework for internal architecture. Refine, and unify the structure of how KingWorld works internally.
Although many refactoring might require, I can assure you that this is for the greater good, as the API refinement lay down a solid structure for the future of KingWorld.
Thanks to API refinement, this version also introduced a lot of new interesting features, and many APIs simplified.
Notable improvements and new features:
- Define Schema, auto-infer type, and validation
- Simplifying Handler's generic
- Unifying Life Cycle into one property
- Custom Error handler, and body-parser
- Before start/stop and clean up effect
Happy halloween.
This version named [GHOST FOOD] is one of the big improvement for KingWorld, I have been working on lately. It has a lot of feature change for better performance, and introduce lots of deprecation.
Be sure to follow the migration section in Breaking Change
.
Feature:
- Auto infer type from
plugin
after merging withuse
decorate
to extendsContext
method- add
addParser
, for custom handler for parsing body
Breaking Change:
-
Moved
store
intocontext.store
- To migrate:
// From app.get(({}, store) => store.a) // To app.get(({ store }) => store.a)
-
ref
, andrefFn
is now removed -
Remove
Plugin
type, simplified Plugin type declaration- To migrate:
// From import type { Plugin } from 'kingworld' const a: Plugin = (app) => app // To import type { KingWorld } from 'kingworld' const a = (app: KingWorld) => app
-
Migrate
Header
toRecord<string, unknown>
- To migrate:
app.get("/", ({ responseHeader }) => { // From responseHeader.append('X-Powered-By', 'KingWorld') // To responseHeader['X-Powered-By', 'KingWorld'] return "KingWorld" })
Change:
- Store is now globally mutable
Improvement:
- Faster header initialization
- Faster hook initialization
Feature:
- Add
config.strictPath
for handling strict path
Improvement:
- Improve
clone
performance - Inline
ref
value - Using object to store internal route
Bug fix:
- 404 on absolute path
Feature:
- Auto infer typed for
params
,state
,ref
onRequest
now accept async functionrefFn
syntax sugar for adding fn as reference instead of() => () => value
Improvement:
- Switch from
@saltyaom/trek-router
to@medley/router
- Using
clone
instead of flatten object - Refactor path fn for inline cache
- Refactor
Context
to class
Bug fix:
.ref()
throw error when accept function
Change:
- optimized for
await
Feature:
- Initialial config is now available, starting with
bodyLimit
config for limiting body size
Breaking Change:
ctx.body
is now a literal value instead ofPromise
- To migrate, simply remove
await
- To migrate, simply remove
Change:
default
now acceptHandler
instead ofEmptyHandler
Bug fix:
- Default Error response now return
responseHeaders
- Possibly fixed parsing body error benchmark
Breaking Change:
- context.body is now deprecated, use request.text() or request.json() instead
Improvement:
- Using reference header to increase json response speed
- Remove
body
getter, setter
Change:
- Using
instanceof
to early returnResponse
Breaking Change:
context.headers
now returnHeader
instead ofRecord<string, string>
Feature:
- Add status function to
Context
handle
now acceptnumber | Serve
- Remove
querystring
to support native Cloudflare Worker - Using raw headers check to parse
body
type
Feature:
- Handle error as response
Change:
- Use Array Spread instead of concat as it's faster by 475%
- Update to @saltyaom/trek-router 0.0.7 as it's faster by 10%
- Use array.length instead of array[0] as it's faster by 4%
Change:
- With lazy initialization, KingWorld is faster by 15% (tested on 14' M1 Max)
- Micro optimization
- Remove
set
from headers
Change:
- Remove dependencies:
fluent-json-schema
,fluent-schema-validator
- Update
@saltyaom/trek-router
to0.0.2
Breaking Change:
- Move
hook.schema
to separate plugin, @kingworldjs/schema- To migrate, simply move all
hook.schema
topreHandler
instead
- To migrate, simply move all
Change:
- Rename type
ParsedRequest
toContext
- Exposed
#addHandler
to_addHandler
Breaking Change:
- Rename
context.responseHeader
tocontext.responseHeaders
- Change type of
responseHeaders
toHeader
instead ofRecord<string, string>