Skip to content

Commit 86e7c9b

Browse files
authored
Merge pull request #465 from elysiajs/raiden
Release 1.0: Raiden
2 parents 78671b1 + a20d6a6 commit 86e7c9b

File tree

93 files changed

+9465
-4041
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

93 files changed

+9465
-4041
lines changed

.eslintrc.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

.eslintrc.json

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/recommended",
9+
"plugin:sonarjs/recommended"
10+
],
11+
"parser": "@typescript-eslint/parser",
12+
"parserOptions": {
13+
"ecmaVersion": "latest",
14+
"sourceType": "module"
15+
},
16+
"plugins": ["@typescript-eslint", "sonarjs"],
17+
"rules": {
18+
"@typescript-eslint/ban-types": "off",
19+
"@typescript-eslint/no-explicit-any": "off",
20+
"no-mixed-spaces-and-tabs": "off",
21+
"@typescript-eslint/no-non-null-assertion": "off",
22+
"@typescript-eslint/no-extra-semi": "off",
23+
"@typescript-eslint/ban-ts-comment": "off",
24+
"@typescript-eslint/no-namespace": "off",
25+
"no-case-declarations": "off",
26+
"no-extra-semi": "off",
27+
"sonarjs/cognitive-complexity": "off"
28+
},
29+
"ignorePatterns": ["example/*", "test/**/*"]
30+
}

.npmignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
.github
44
.prettierrc
55
.eslintrc.js
6+
.eslint.json
67
.swc.cjs.swcrc
78
.swc.esm.swcrc
89
.swcrc
@@ -29,4 +30,5 @@ CODE_OF_CONDUCT.md
2930
trace
3031

3132
build.ts
33+
.scannerwork
3234
src

CHANGELOG.md

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,47 @@
1+
# 1.0.0 - 8 Mar 2024
2+
Improvement:
3+
- fine-grained reactive cookie
4+
- using single source of truth for cookie
5+
- macro support for websocket
6+
- add `mapResolve`
7+
- add `{ as: 'global' | 'scoped' | 'local' }` to lifecycle event
8+
- add ephemeral type
9+
- inline `error` to handler
10+
- inline `error` has auto-completion and type checking based on status code
11+
- handler now check return type of `error` based on status code
12+
- utility `Elysia._types` for types inference
13+
- [#495](https://github.com/elysiajs/elysia/issues/495) Provide user friendly error for failed parse
14+
- handler now infers return type for error status for Treaty
15+
- `t.Date` now allow stringified date
16+
- improves type test case
17+
- add test case for all life-cycle
18+
- resolve, mapResolve, derive, mapDerive use ephemeral type to scope down accurately
19+
- inference query dynamic variable
20+
21+
Breaking Change:
22+
- [#513](https://github.com/elysiajs/elysia/issues/513) lifecycle is now local first
23+
24+
Change:
25+
- group private API property
26+
- move `Elysia.routes` to `Elysia.router.history`
27+
- detect possible json before return
28+
- unknown response now return as-is instead of JSON.stringify()
29+
- change Elysia validation error to JSON instead of string
30+
- static content evalute hook JIT instead of AOT
31+
32+
Bug fix:
33+
- [#466](https://github.com/elysiajs/elysia/issues/466) Async Derive leaks request context to other requests if `aot: true`
34+
- [#505](https://github.com/elysiajs/elysia/issues/505) Empty ObjectString missing validation inside query schema
35+
- [#503](https://github.com/elysiajs/elysia/issues/503) Beta: undefined class when using decorate and derive
36+
- onStop callback called twice when calling .stop
37+
- mapDerive now resolve to `Singleton['derive']` instead of `Singleton['store']`
38+
- `ValidationError` doesn't return `content-type` as `application/json`
39+
- validate `error(status, value)` validate per status
40+
- derive/resolve always scoped to Global
41+
- duplicated onError call if not handled
42+
- [#516](https://github.com/elysiajs/elysia/issues/516) server timing breaks beforeHandle guards
43+
- cookie.remove() doesn't set correct cookie path
44+
145
# 0.8.17 - 12 Feb 2024
246
Feature:
347
- [#474](https://github.com/elysiajs/elysia/pull/474) Numeric Cookie with length >= 16 cant be parsed to number

build.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,12 @@ await Promise.all([
3636
await Bun.build({
3737
entrypoints: ['./src/index.ts'],
3838
outdir: './dist/bun',
39-
minify: true,
39+
minify: false,
4040
target: 'bun',
4141
sourcemap: 'external',
4242
external: ['@sinclair/typebox']
4343
})
4444

45-
await Bun.sleep(2000)
46-
4745
await Promise.all([
4846
$`cp dist/cjs/*.d.ts dist/`,
4947
$`cp dist/cjs/ws/*.d.ts dist/ws/`

bun.lockb

3.64 KB
Binary file not shown.

example/a.ts

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,5 @@
1-
import { Elysia, t } from '../src'
2-
import { req } from '../test/utils'
1+
import { Elysia } from '../src'
32

4-
const app = new Elysia({ aot: false }).post('/', (ctx) => ctx.body, {
5-
parse: (ctx, contentType) => {
6-
return contentType;
7-
},
8-
body: t.String()
9-
});
10-
11-
const res = await app.handle(
12-
new Request('http://localhost', {
13-
method: 'POST',
14-
body: 'yay',
15-
headers: { 'content-type': 'text/plain' }
16-
})
17-
).then(x => x.text())
3+
const app = new Elysia({ precompile: true })
4+
.get('/', Bun.file('test/kyuukurarin.mp4'))
5+
.listen(3000)

example/analysis.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Suite } from 'benchmark'
2+
3+
// import { createApp } from './http'
4+
5+
const run = (suite: Suite) => {
6+
suite
7+
// @ts-ignore
8+
.on('cycle', function (event) {
9+
console.log(String(event.target))
10+
})
11+
.on('complete', function () {
12+
// @ts-ignore
13+
console.log('Fastest is ' + this.filter('fastest').map('name'))
14+
})
15+
// run async
16+
.run()
17+
}
18+
19+
// run(
20+
// new Suite('Sucrose').add('analysis', () => {
21+
// createApp()
22+
// })
23+
// )

example/b.ts

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Elysia } from '../src'
2+
3+
const auth = new Elysia({ prefix: '/protected' })
4+
.derive(({ cookie: { auth } }) => ({
5+
session: {
6+
kind: 'logged-in' as string,
7+
user: 'saltyaom' as string | null
8+
}
9+
}))
10+
.guard(
11+
{
12+
beforeHandle({ error, session: { kind, user } }) {
13+
if (kind !== 'logged-in')
14+
return error(401, 'Unauthorized')
15+
16+
return user
17+
}
18+
},
19+
(app) =>
20+
app
21+
.derive(({ session }) => ({ user: session.user! }))
22+
.get('/user', ({ user }) => user)
23+
)
24+
25+
const app = new Elysia()
26+
.use(auth)
27+
// ? Will not have auth check
28+
.get('/', () => 'hai')
29+
.listen(3000)

example/cookie.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ const app = new Elysia({
2121
'/update',
2222
({ cookie: { name } }) => {
2323
name.value = 'seminar: Rio'
24-
2524
name.value = 'seminar: Himari'
26-
2725
name.maxAge = 86400
2826

2927
return name.value

0 commit comments

Comments
 (0)