Releases: elysiajs/elysia
0.4 - 月夜の音楽会 (Moonlit Night Concert)
Named after the opening music of "The Liar Princess and the Blind Prince" trailer, 「月夜の音楽会」(Moonlit Night Concert) composed and sang by Akiko Shikata.
This version doesn't introduce an exciting new feature, later but a foundation for more solid ground, and internal improvement for the future of Elysia.
Ahead of Time Complie
By default, Elysia has to deal with conditional checking in various situations, for example, checking if the life-cycle of the route existed before performing, or unwrapping validation schema if provided.
This introduces a minimal overhead to Elysia and overall because even if the route doesn't have a life-cycle event attached to it, it needs to be runtime checked.
Since every function is checked on compile time, it's not possible to have a conditional async, for example, a simple route that returns a file should be synced, but since it's compile-time checking, some routes might be async thus making the same simple route async too.
An async function introduces an additional tick to the function, making it a bit slower. But since Elysia is a foundation for web servers, we want to optimize every part to make sure that you don't run into performance problems.
We fix this small overhead by introducing Ahead Time Compilation.
As the name suggests, instead of checking dynamic life-cycle and validation on the runtime, Elysia checks life-cycle, validation, and the possibility of an async function and generates a compact function, removing an unnecessary part like an un-used life-cycle and validation.
Making conditional async function possible, since instead of using a centralized function for handling, we compose a new function especially created for each route instead. Elysia then checks all life-cycle functions and handlers to see if there's an async, and if not, the function will be synced to reduce additional overhead.
TypeBox 0.26
TypeBox is a library that powered Elysia's validation and type provider to create a type-level single source of truth, re-exported as Elysia.t.
In this update, we update TypeBox from 0.25.4 to 0.26.
This brings a lot of improvement and new features, for example, a Not
type and Convert
for coercion
value which we might support in some next version of Elysia.
But the one benefit for Elysia would be, Error.First()
which allows us to get the first error of type instead of using Iterator, this reduces overhead in creating a new Error to send back to the client.
There are some changes to TypeBox and Elysia.t that normally wouldn't have much effect on your end, but you can see what's a new feature in TypeBox release here.
Validate response per status
Previously, Elysia's response validate multiple status responses using union type.
This might have unexpected results for highly dynamic apps with a strict response for status.
For example if you have a route like:
app.post('/strict-status', process, {
schema: {
response: {
200: t.String(),
400: t.Number()
}
}
})
It's expected that if 200 response is not a string, then it should throw a validation error, but in reality, it wouldn't throw an error because response validation is using union. This might leave an unexpected value to the end user and a type error for Eden Treaty.
With this release, a response is validated per status instead of union, which means that it will strictly validate based on response status instead of unioned type.
Separation of Elysia Fn
Elysia Fn is a great addition to Elysia, with Eden, it breaks the boundary between client and server allowing you to use any server-side function in your client, fully type-safe and even with primitive types like Error, Set, and Map.
But with the primitive type support, Elysia Fn depends on "superjson" which is around 38% of Elysia's dependency size.
In this release, to use Elysia Fn, you're required to explicitly install @elysiajs/fn
to use Elysia Fn. This approach is like installing an additional feature same as cargo add --feature
.
This makes Elysia lighter for servers that don't use Elysia Fn, Following our philosophy, To ensure that you have what you actually need
However, if you forgot to install Elysia Fn and accidentally use Elysia Fn, there will be a type warning reminding you to install Elysia Fn before usage, and a runtime error telling the same thing.
For migration, besides a breaking change of installing @elysiajs/fn
explicitly, there's no migration need.
Conditional Route
This release introduces .if
method for registering a conditional route or plugin.
This allows you to declaratively for a specific conditional, for example excluding Swagger documentation from the production environment.
const isProduction = process.env.NODE_ENV === 'production'
const app = new Elysia().if(!isProduction, (app) =>
app.use(swagger())
)
Eden Treaty will be able to recognize the route as if it's a normal route/plugin.
Custom Validation Error
Big thanks to amirrezamahyari on #31 which allows Elysia to access TypeBox's error property, for a better programmatically error response.
new Elysia()
.onError(({ code, error, set }) => {
if (code === 'NOT_FOUND') {
set.status = 404
return 'Not Found :('
}
if (code === 'VALIDATION') {
set.status = 400
return {
fields: error.all()
}
}
})
.post('/sign-in', () => 'hi', {
schema: {
body: t.Object({
username: t.String(),
password: t.String()
})
}
})
.listen(8080)
Now you can create a validation error for your API not limited to only the first error.
Notable 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
Afterward
This release might not be a big release with a new exciting feature, but this improve a solid foundation, and Proof of Concept for planned I have for Elysia in the future, and making Elysia even faster and more versatile than it was.
I'm really excited for what will be unfold in the future.
Thank you for your continuous support for Elysia~
the moonlit night concert, our secret
let’s start again without letting go of this hand
the moonlit night concert, our bonds
I want to tell you, “you are not a liar”
the memories in my heart is like flower that keeps blooming
no matter what you look like, you are my songstress
be by my side tonight
0.3 ー「大地の閾を探して [Looking for Edge of Ground] 」
Named after Camellia's song「大地の閾を探して [Looking for Edge of Ground]」ft. Hatsune Miku, is the last track of my most favorite's Camellia album,「U.U.F.O」. This song has a high impact on me personally, so I'm not taking the name lightly.
This is the most challenging update, bringing the biggest release of Elysia yet, with rethinking and redesigning of Elysia architecture to be highly scalable while making less breaking change as possible.
I'm pleased to announce the release candidate of Elysia 0.3 with exciting new features coming right up.
Elysia Fn
Introducing Elysia Fn, run any backend function on the frontend with full auto-completion and full type support.
c.12.02.26.mp4
For rapid development, Elysia Fn allows you to "expose" backend code to call from the frontend with full type-safety, autocompletion, original code comment, and "click-to-definition", allowing you to speed up the development.
You can use Elysia Fn with Eden for full-type safety via Eden Fn.
Permission
You can limit allow or deny scopes of the function, check for authorization header and other headers' fields, validate parameters, or limit keys access programmatically.
Keys checking supports type-safety and auto-completion of all possible functions, so you're not missing out on some function or accidentally typing down the wrong name.
And narrowing the scope of property programmatically also narrow down the type of parameters, or in other words, full type-safety.
Technical detail
In technical detail, Elysia Fn uses JavaScript's Proxy to capture object property, and parameters to create batched requests to the server to handle and returns the value across the network.
Elysia Fn extends superjson, allowing native type in JavaScript like Error, Map, Set, and undefined to parse across JSON data.
Elysia Fn supports multiple use-cases, for example accessing Prisma on the client-side Nextjs app.
Theoretically, it's possible to use Redis, Sequelize, RabbitMQ, and more.
As Elysia is running on Bun, Elysia Fn can run over 1.2 million operation/second concurrently (tested on M1 Max).
Learn more about Elysia Fn at Eden Fn.
Type Rework
Over 6.5-9x faster for type checking, and uncountable type's LoC reduction.
Elysia 0.3, over 80% of Elysia, and Eden types have been rewritten to focus on performance, type-inference, and fast auto-completion.
Testing for over 350 routes with complex types, Elysia uses only 0.22
seconds to generate a type declaration to use with Eden.
As the Elysia route now compile directly to literal object instead of Typebox reference, Elysia type declaration is much smaller than it used to be on 0.2 and is easier to be consumed by Eden. And by much smaller, it means 50-99% smaller.
Not only Elysia integration with TypeScript is significantly faster, but Elysia is better at understanding TypeScript and your code better.
For example, with 0.3, Elysia will be less strict with plugin registration, allowing you to register the plugin without full type-completion of Elysia Instance.
Inlining use
function now infers the parent type, and the nested guard can reference types of models from the parent more accurately.
Type Declaration is now also can be built, and exported.
With the rewrite of type, Elysia understands TypeScript far better than it used to, type-completion will be significantly faster than it was, and we encourage you to try it out to see how fast it is.
For more detail, see this thread on Twitter
File Upload
Thanks to Bun 0.5.7, Form Data is implemented and enabled by default in Elysia 0.3 with multipart/formdata
.
To define type completion and validation for uploading a file, Elysia.t
now extends TypeBox with File
and Files
for file validation.
The validation includes checking for file type with auto-completion of standard file size, the minimum and maximum size of the file, and the total of files per field.
Elysia 0.3 also features schema.contentType
to explicitly validate incoming request type to strictly check headers before validating the data.
OpenAPI Schema 3.0.x
With Elysia 0.3, Elysia now uses OpenAPI schema 3.0.x by default for better stating API definitions, and better support for multiple types based on content-type.
schema.details
are now updated to OpenAPI 3.0.x, and Elysia also updates the Swagger plugin to match the OpenAPI 3.0.x to take advantage of new features in OpenAPI 3 and Swagger, especially with file uploading.
Eden Rework
To support more demand for Elysia, supporting Elysia Fn, Rest all together, Eden has been reworked to scale with the new architecture.
Eden now exports 3 types of function.
- Eden Treaty
eden/treaty
: Original Eden syntax you know and love - Eden Fn
eden/fn
: Access to Eden Fn - Eden Fetch
eden/fetch
: Fetch-like syntax, for highly complex Elysia type (> 1,000 route / Elysia instance)
With the rework of type definitions and support for Elysia Eden, Eden is now much faster and better at inference type from the server.
Auto-completion and faster and use fewer resources than it used to, in fact, Eden's type declaration has been almost 100% reworked to reduce the size and inference time, making it support over 350 routes of auto-completion in a blink of an eye (~0.26 seconds).
To make Elysia Eden, fully type-safe, with Elysia's better understanding of TypeScript, Eden can now narrow down the type based on response status, allowing you to capture the type correctly in any matter of condition.
Notable 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
- 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]
Afterward
With the introduction of Elysia Fn, I'm personally excited to see how it will be adopted in frontend development, removing the line between frontend and backend. And Type Rework of Elysia, making type-checking and auto-completion much faster.
I'm excited to see how you will use Elysia to create the wonderful things you are going to build.
We have Discord server dedicated to Elysia. Feel free to say hi or just chill and hang out.
Thank you for supporting Elysia.
Under a celestial map that never have ends
On a cliff that never have name
I just holwed
Hoping the neverending reverberation will reach you
And I believe someday, I will stand on edge of the ground
(Until the day I can be back to you to tell it)
0.3 ー「大地の閾を探して [Looking for Edge of Ground] 」(RC)
Named after Camellia's song「大地の閾を探して [Looking for Edge of Ground]」ft. Hatsune Miku, is the last track of my most favorite's Camellia album,「U.U.F.O」. This song has a high impact on me personally, so I'm not taking the name lightly.
This is the most challenging update, bringing the biggest release of Elysia yet, with rethinking and redesigning of Elysia architecture to be highly scalable while making less breaking change as possible.
And I'm pleased to announce the release candidate of Elysia 0.3 with exciting new features coming right up.
Elysia Fn
Introducing Elysia Fn, run any backend function on the frontend with full auto-completion and full type support.
c.12.02.26.mp4
For rapid development, Elysia Fn allows you to "expose" backend code to call from the frontend with full type-safety, autocompletion, original code comment, and "click-to-definition", allowing you to speed up the development.
You can use Elysia Fn with Eden for full-type safety via Eden Fn.
Permission
You can limit allow or deny scopes of the function, check for authorization header and other headers' fields, validate parameters, or limit keys access programmatically.
Keys checking supports type-safety and auto-completion of all possible functions, so you're not missing out on some function or accidentally typing down the wrong name.
And narrowing the scope of property programmatically also narrow down the type of parameters, or in other words, full type-safety.
Technical detail
In technical detail, Elysia Fn uses JavaScript's Proxy to capture object property, and parameters to create batched requests to the server to handle and returns the value across the network.
Elysia Fn extends superjson, allowing native type in JavaScript like Error, Map, Set, and undefined to parse across JSON data.
Elysia Fn supports multiple use-cases, for example accessing Prisma on the client-side Nextjs app.
Theoretically, it's possible to use Redis, Sequelize, RabbitMQ, and more.
As Elysia is running on Bun, Elysia Fn can run over 1.2 million operation/second concurrently (tested on M1 Max).
Type Rework
Over 6.5-9x faster for type checking, and uncountable type's LoC reduction.
Elysia 0.3, over 80% of Elysia, and Eden types have been rewritten to focus on performance, type-inference, and fast auto-completion.
Testing for over 350 routes with complex types, Elysia uses only 0.22
seconds to generate a type declaration to use with Eden.
As the Elysia route now compile directly to literal object instead of Typebox reference, Elysia type declaration is much smaller than it used to be on 0.2 and is easier to be consumed by Eden. And by much smaller, it means 50-99% smaller.
Not only Elysia integration with TypeScript is significantly faster, but Elysia is better at understanding TypeScript and your code better.
For example, with 0.3, Elysia will be less strict with plugin registration, allowing you to register the plugin without full type-completion of Elysia Instance.
Inlining use
function now infers the parent type, and the nested guard can reference types of models from the parent more accurately.
Type Declaration is now also can be built, and exported.
With the rewrite of type, Elysia understands TypeScript far better than it used to, type-completion will be significantly faster than it was, and we encourage you to try it out to see how fast it is.
For more detail, see this thread on Twitter
File Upload
Thanks to Bun 0.5.7, Form Data is implemented and enabled by default in Elysia 0.3 with multipart/formdata
.
To define type completion and validation for uploading a file, Elysia.t
now extends TypeBox with File
and Files
for file validation.
The validation includes checking for file type with auto-completion of standard file size, the minimum and maximum size of the file, and the total of files per field.
Elysia 0.3 also features schema.contentType
to explicitly validate incoming request type to strictly check headers before validating the data.
OpenAPI Schema 3.0.x
With Elysia 0.3, Elysia now uses OpenAPI schema 3.0.x by default for better stating API definitions, and better support for multiple types based on content-type.
schema.details
are now updated to OpenAPI 3.0.x, and Elysia also updates the Swagger plugin to match the OpenAPI 3.0.x to take advantage of new features in OpenAPI 3 and Swagger, especially with file uploading.
Eden Rework
To support more demand for Elysia, supporting Elysia Fn, Rest all together, Eden has been reworked to scale with the new architecture.
Eden now exports 3 types of function.
Eden Treaty eden/treaty
: Original Eden syntax you know and love,
Eden Fn eden/fn
: Access to Eden Fn
Eden Fetch eden/fetch
: Fetch-like syntax, for highly complex Elysia type (> 1,000 route / Elysia instance)
With the rework of type definitions and support for Elysia Eden, Eden is now much faster and better at inference type from the server.
Auto-completion and faster and use fewer resources than it used to, in fact, Eden's type declaration has been almost 100% reworked to reduce the size and inference time, making it support over 350 routes of auto-completion in a blink of an eye (~0.26 seconds).
To make Elysia Eden, fully type-safe, with Elysia's better understanding of TypeScript, Eden can now narrow down the type based on response status, allowing you to capture the type correctly in any matter of condition.
Notable 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 an external module
- Exported variable has or is using name 'DEFS' from an external module
- Possible errors for building the Elysia app with
declaration: true
intsconfig.json
Breaking Change:
- Remove
derive
- Update from OpenAPI 2.x to OpenAPI 3.0.3
- Moved context.store[SYMBOL] to meta[SYMBOL] (internal)
Afterword
With the introduction of Elysia Fn, I'm personally excited to see how it will be adopted in frontend development, removing the line between frontend and backend. And Type Rework of Elysia, making type-checking and auto-completion much faster.
I'm excited to see how you will use Elysia to create the wonderful things you are going to build.
We have Discord server dedicated to Elysia. Feel free to say hi or just chill and hang out.
Thank you for supporting Elysia.
Under a celestial map that never have ends
On a cliff that never have name
I just holwed
Hoping the neverending reverberation will reach you
And I believe someday, I will stand on edge of the ground
(Until the day I can be back to you to tell it)
0.2 ー「The Blessing」
The Blessing
「Blessing」brings more improvement, mainly on TypeScript performance, type-inference, and better auto-completion and some new features to reduce boilerplate.
Named after YOASOBI's song「祝福」, an opening for Witch from "Mobile Suit Gundam: The Witch from Mercury".
Defers / Lazy Loading Module
With Elysia 0.2 now add support for the lazy loading module and async plugin.
This made it possible to defer plugin registration and incrementally apply after the Elysia server is started to achieve the fastest possible start-up time in Serverless/Edge environments.
To create defers module, simply mark the plugin as async:
const plugin = async (app: Elysia) => {
const stuff = await doSomeHeavyWork()
return app.get('/heavy', stuff)
}
app.use(plugin)
Lazy Loading
Some modules might be heavy and importing before starting the server might not be a good idea.
We can tell Elysia to skip the module then register the module later, and register the module when finish loading by using import
statement in use
:
app.use(import('./some-heavy-module'))
This will register the module after the import is finished making the module lazy-load.
Defers Plugin and lazy loading module will have all type-inference available right out of the box.
Reference Model
Now Elysia can memorize schema and reference the schema directly in Schema fields, without creating an import file via Elysia.setModel
This list of schema available, brings auto-completion, complete type-inference, and validation as you expected from inline schema.
To use a reference model, first, register the model with setModel
, then write a model name to reference a model in schema
const app = new Elysia()
.setModel({
sign: t.Object({
username: t.String(),
password: t.String()
})
})
.post('/sign', ({ body }) => body, {
schema: {
body: 'sign',
response: 'sign'
}
})
This will bring auto-completion of known models.
And type reference stopping you from accidentally returning invalid type.
Using @elysiajs/swagger
will also create a separate Model
section for listing available models.
Reference also handles validation as you expected.
In short, it's as same as inline schema but now you only need to type the name of the schema to handle validation and typing instead of a long list of imports.
OpenAPI Detail field
Introducing new field schema.detail
for customizing detail for the route following the standard of OpenAPI Schema V2 with auto-completion.
This allows you to write better documentation and fully editable Swagger as you want:
Union Type
The previous version of Elysia sometime has a problem with distinct Union types, as Elysia tries to catch the response to create a full type reference for Eden.
Results in invalidation of possible types,
Union Response
Made possible by Union Type, now returning multiple response status for schema
now available using schema.response[statusCode]
app
.post(
'/json/:id',
({ body, params: { id } }) => ({
...body,
id
}),
{
schema: {
body: 'sign',
response: {
200: t.Object({
username: t.String(),
password: t.String(),
id: t.String()
}),
400: t.Object({
error: t.String()
})
}
}
}
)
Elysia will try to validate all schema in response
allowing one of the types to be returned.
Return types are also supported report in Swagger's response.
Faster Type Inference
As Elysia 0.1 explore the possibility of using type inference for improving better Developer Experience, we found that sometimes it takes a long time to update type inference because of heavy type inference and in-efficient custom generic.
With Elysia 0.2 now optimized for faster type-inference, preventing duplication of heavy type unwrap, results in better performance for updating type and inference.
Ecosystem
With Elysia 0.2 enabling async plugin and deferred module many new plugins that isn't possible before became reality.
Like:
- Elysia Static plugin with the non-blocking capability
- Eden with union-type inference for multiple responses
- New Elysia Apollo Plugin for Elysia
Notable Improvement:
onRequest
andonParse
now can accessPreContext
- Support
application/x-www-form-urlencoded
by default - body parser now parse
content-type
with extra attribute eg.application/json;charset=utf-8
- Decode URI parameter path parameter
- Eden now reports an error if Elysia is not installed
- Skip declaration of existing model and decorators
Breaking Changes:
onParse
now accepts(context: PreContext, contentType: string)
instead of(request: Request, contentType: string)
- To migrate, add
.request
to context to accessRequest
- To migrate, add
Afterward
Thank you for supporting Elysia and being interested in this project.
This release brings better DX and hopefully all you need to write great software with Bun.
Now we have Discord server where you can ask any questions about Elysia or just hang out and chill around is also welcome.
With the wonderful tools, we are happy to see what wonderful software you will build.
Not to be part of those images someone paints
Not advancing in that show chosen by someone else
You and I, alive to write our story
Will never let you be lone and be gone from your side
0.2 - Blessing (RC)
0.2.0 RC - 23 Jan 2022
「Blessing」brings more improvement, mainly on TypeScript performance, type-inference, and better auto-completion and some new features to reduce boilerplate.
Named after YOASOBI's song「祝福」, an opening for Witch from "Mobile Suit Gundam: The Witch from Mercury".
Defers / Lazy Loading Module
With Elysia 0.2 now add support for the lazy loading module and async plugin.
This made it possible to defer plugin registration and incrementally apply after the Elysia server is started to achieve the fastest possible start-up time in Serverless/Edge environments.
To create defers module, simply mark the plugin as async:
const plugin = async (app: Elysia) => {
const stuff = await doSomeHeavyWork()
return app.get('/heavy', stuff)
}
app.use(plugin)
Lazy Loading
Some modules might be heavy and importing before starting the server might not be a good idea.
We can tell Elysia to skip the module then register the module later, and register the module when finish loading by using import
statement in use
:
app.use(import('./some-heavy-module'))
This will register the module after the import is finished making the module lazy-load.
Defers Plugin and lazy loading module will have all type-inference available right out of the box.
Reference Model
Now Elysia can memorize schema and reference the schema directly in Schema fields, without creating an import file via Elysia.setModel
This list of schema available, brings auto-completion, complete type-inference, and validation as you expected from inline schema.
To use a reference model, first, register the model with setModel
, then write a model name to reference a model in schema
const app = new Elysia()
.setModel({
sign: t.Object({
username: t.String(),
password: t.String()
})
})
.post('/sign', ({ body }) => body, {
schema: {
body: 'sign',
response: 'sign'
}
})
This will bring auto-completion of known models.
And type reference stopping you from accidentally returning invalid type.
Using @elysiajs/swagger
will also create a separate Model
section for listing available models.
Reference also handles validation as you expected.
In short, it's as same as inline schema but now you only need to type the name of the schema to handle validation and typing instead of a long list of imports.
OpenAPI Detail field
Introducing new field schema.detail
for customizing detail for the route following the standard of OpenAPI Schema V2 with auto-completion.
This allows you to write better documentation and fully editable Swagger as you want:
Union Type
The previous version of Elysia sometime has a problem with distinct Union types, as Elysia tries to catch the response to create a full type reference for Eden.
Results in invalidation of possible types,
Union Response
Made possible by Union Type, now returning multiple response status for schema
now available using schema.response[statusCode]
app
.post(
'/json/:id',
({ body, params: { id } }) => ({
...body,
id
}),
{
schema: {
body: 'sign',
response: {
200: t.Object({
username: t.String(),
password: t.String(),
id: t.String()
}),
400: t.Object({
error: t.String()
})
}
}
}
)
Elysia will try to validate all schema in response
allowing one of the types to be returned.
Return types are also supported report in Swagger's response.
Faster Type Inference
As Elysia 0.1 explore the possibility of using type inference for improving better Developer Experience, we found that sometimes it takes a long time to update type inference because of heavy type inference and in-efficient custom generic.
With Elysia 0.2 now optimized for faster type-inference, preventing duplication of heavy type unwrap, results in better performance for updating type and inference.
Notable Improvement:
onRequest
andonParse
now can accessPreContext
- Support
application/x-www-form-urlencoded
by default - body parser now parse
content-type
with extra attribute eg.application/json;charset=utf-8
- Decode URI parameter path parameter
Breaking Changes:
onParse
now accepts(context: PreContext, contentType: string)
instead of(request: Request, contentType: string)
- To migrate, add
.request
to context to accessRequest
- To migrate, add
Afterward
Thank you for supporting Elysia and being interested in this project.
This release brings better DX and hopefully all you need to write great software with Bun.
Now we have Discord server where you can ask any questions about Elysia or just hang out and chill around is also welcome.
With the wonderful tools, we are happy to see what wonderful software you will build.
Not to be part of those images someone paints
Not advancing in that show chosen by someone else
You and I, alive to write our story
Will never let you be lone and be gone from your side
0.1 ー「Reburn」
0.1.0 - 24 Dec 2022
「Reburn」is the first stable beta release for Elysia.
Happy Christmas, wishing you happiness tonight as we release the first stable release of Elysia.
The API is now stabilized, and Elysia will focus on growing its ecosystem and plugins for common patterns.
Eden
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
elysia_eden.mp4
The fastest
With a lot of effort put into micro-optimization and re-architecture, Elysia is the fastest Bun web framework benchmarked on 24 December 2022, outperforming 2/3 category put into the test.
See benchmark results at Bun http benchmark
Improved Documentation
Elysia now has improved documentation at elysiajs.com.
Now with a proper landing page, searchable content, and revised content put into.
Afterward
Merry Christmas, and happy new year.
As 0.1 release, we recommended giving Elysia a try and building stuff with it.
With the wonderful tools, we are happy to see what wonderful software you will 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!