Skip to content

Commit

Permalink
Merge branch 'main' into chore/any-spam
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltyAom committed Mar 25, 2024
2 parents da35a42 + 30d014b commit 7165860
Show file tree
Hide file tree
Showing 40 changed files with 1,201 additions and 538 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Expand Up @@ -5,4 +5,5 @@ build
dump.rdb
dist
trace
.scannerwork
.scannerwork
*.tsbuildinfo
31 changes: 31 additions & 0 deletions CHANGELOG.md
@@ -1,3 +1,34 @@
# 1.0.7 - 20 Mar 2024
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](https://github.com/elysiajs/elysia/issues/548) additional case for "accessing all query params using property name (ctx.query) doesn't work anymore"
- [#599](https://github.com/elysiajs/elysia/issues/559) plugin with scoped settings not functioning correctly

# 1.0.6 - 20 Mar 2024
Bug fix:
- inline function doesn't propagate correctly on type level

# 1.0.5 - 19 Mar 2024
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

# 1.0.4 - 18 Mar 2024
Improvement:
- resolve, derive soundness

# 1.0.3 - 18 Mar 2024
Improvement:
- Reduce instruction for static resource
Expand Down
8 changes: 5 additions & 3 deletions build.ts
Expand Up @@ -28,11 +28,13 @@ await Promise.all([
outDir: 'dist/cjs',
format: 'cjs',
target: 'node20',
dts: true,
// dts: true,
...tsupConfig
})
])

await $`tsc --project tsconfig.dts.json`

await Bun.build({
entrypoints: ['./src/index.ts'],
outdir: './dist/bun',
Expand All @@ -43,8 +45,8 @@ await Bun.build({
})

await Promise.all([
$`cp dist/cjs/*.d.ts dist/`,
$`cp dist/cjs/ws/*.d.ts dist/ws/`
$`cp dist/*.d.ts dist/cjs`,
$`cp dist/ws/*.d.ts dist/cjs/ws/`,
])

await $`cp dist/index*.d.ts dist/bun`
Expand Down
Binary file modified bun.lockb
Binary file not shown.
36 changes: 29 additions & 7 deletions example/a.ts
@@ -1,10 +1,32 @@
import { Elysia, error, t } from '../src'
import { Elysia, t, ValidationError } from '../src'

const app = new Elysia({ precompile: true })
.headers({
a: 'hello'
})
.get('/', 'a')
const app = new Elysia({
// precompile: true,
aot: false,
})
.get(
'/update',
({ cookie: { name } }) => {
name.value = 'seminar: Himari'

return 'a'
},
{
cookie: t.Cookie(
{
name: t.Optional(t.String())
},
{
secrets: 'a',
sign: ['name']
}
)
}
)
.listen(3000)

console.log(app.routes[0].composed?.toString())
app.handle(new Request('http://localhost:3000/update'))
.then((x) => x.headers.getSetCookie())
.then(console.log)

// console.log(app.routes[0].composed?.toString())
31 changes: 6 additions & 25 deletions example/b.ts
@@ -1,29 +1,10 @@
import { Elysia } from '../src'
import { req } from '../test/utils'

const auth = new Elysia({ prefix: '/protected' })
.derive(({ cookie: { auth } }) => ({
session: {
kind: 'logged-in' as string,
user: 'saltyaom' as string | null
}
}))
.guard(
{
beforeHandle({ error, session: { kind, user } }) {
if (kind !== 'logged-in')
return error(401, 'Unauthorized')
const a = new Elysia().trace({ as: 'global' }, async ({ set }) => {
set.headers['X-Powered-By'] = 'elysia'
})

return user
}
},
(app) =>
app
.derive(({ session }) => ({ user: session.user! }))
.get('/user', ({ user }) => user)
)
const app = new Elysia().use(a).get('/', () => 'hi')

const app = new Elysia()
.use(auth)
// ? Will not have auth check
.get('/', () => 'hai')
.listen(3000)
const response = await app.handle(req('/')).then(x => x.text()).then(console.log)
2 changes: 1 addition & 1 deletion example/body.ts
Expand Up @@ -28,6 +28,6 @@ const app = new Elysia()
}
})
.post('/mirror', ({ body }) => body)
.listen(8080)
.listen(3000)

console.log('🦊 Elysia is running at :8080')
2 changes: 1 addition & 1 deletion example/counter.ts
Expand Up @@ -3,4 +3,4 @@ import { Elysia } from '../src'
new Elysia()
.state('counter', 0)
.get('/', ({ store }) => store.counter++)
.listen(8080)
.listen(3000)
2 changes: 1 addition & 1 deletion example/custom-response.ts
Expand Up @@ -12,4 +12,4 @@ new Elysia()
.get('/', () => ({
hello: 'world'
}))
.listen(8080)
.listen(3000)
2 changes: 1 addition & 1 deletion example/error.ts
Expand Up @@ -30,4 +30,4 @@ new Elysia()
console.log(error)
}
})
.listen(8080)
.listen(3000)
2 changes: 1 addition & 1 deletion example/file.ts
Expand Up @@ -12,4 +12,4 @@ new Elysia()

return Bun.file('./example/takodachi.png')
})
.listen(8080)
.listen(3000)
2 changes: 1 addition & 1 deletion example/guard.ts
Expand Up @@ -29,4 +29,4 @@ new Elysia()
})
})
)
.listen(8080)
.listen(3000)
2 changes: 1 addition & 1 deletion example/headers.ts
Expand Up @@ -7,4 +7,4 @@ new Elysia()
set.headers['x-powered-by'] = 'Elysia'
set.status = 'Bad Request'
})
.listen(8080)
.listen(3000)
2 changes: 1 addition & 1 deletion example/hook.ts
Expand Up @@ -18,4 +18,4 @@ new Elysia()
}
]
})
.listen(8080)
.listen(3000)
2 changes: 1 addition & 1 deletion example/nested-schema.ts
Expand Up @@ -31,4 +31,4 @@ new Elysia()
)
)
.get('*', () => 'Star now work')
.listen(8080)
.listen(3000)
2 changes: 1 addition & 1 deletion example/params.ts
Expand Up @@ -4,6 +4,6 @@ const app = new Elysia()
.get('/', () => 'Elysia')
// Retrieve params, automatically typed
.get('/id/:id', ({ params }) => params.id)
.listen(8080)
.listen(3000)

console.log('Listen')
2 changes: 1 addition & 1 deletion example/redirect.ts
Expand Up @@ -5,4 +5,4 @@ new Elysia()
.get('/redirect', ({ set }) => {
set.redirect = '/'
})
.listen(8080)
.listen(3000)
2 changes: 1 addition & 1 deletion example/response.ts
Expand Up @@ -12,4 +12,4 @@ new Elysia()
status: 418
})
})
.listen(8080)
.listen(3000)
2 changes: 1 addition & 1 deletion example/router.ts
Expand Up @@ -11,4 +11,4 @@ const a = new Elysia()
.get('/a', () => 'A')
.guard({}, (app) => app.get('/guard', () => 'a'))
.use(prefix('prefixed'))
.listen(8080)
.listen(3000)
2 changes: 1 addition & 1 deletion example/schema.ts
Expand Up @@ -58,7 +58,7 @@ const app = new Elysia()
}
})
)
.listen(8080)
.listen(3000)

type A = (typeof app)['meta'][typeof SCHEMA]['/']
type B = (typeof app)['meta'][typeof DEFS]
Expand Down
2 changes: 1 addition & 1 deletion example/simple.ts
Expand Up @@ -4,7 +4,7 @@ import { Elysia } from '../src'
const t1 = performance.now()
new Elysia()
.get('/', () => 'Hi')
.listen(8080)
.listen(3000)

console.log(performance.now() - t1)

Expand Down
2 changes: 1 addition & 1 deletion example/type-inference.ts
Expand Up @@ -5,4 +5,4 @@ const counter = (app: Elysia) => app.state('counter', 0)
new Elysia()
.use(counter)
.guard({}, (app) => app.get('/id/:id', ({ store: { counter } }) => counter))
.listen(8080)
.listen(3000)
64 changes: 25 additions & 39 deletions package.json
@@ -1,7 +1,7 @@
{
"name": "elysia",
"description": "Ergonomic Framework for Human",
"version": "1.0.3",
"version": "1.0.7",
"author": {
"name": "saltyAom",
"url": "https://github.com/SaltyAom",
Expand All @@ -12,76 +12,64 @@
"types": "./dist/index.d.ts",
"exports": {
".": {
"bun": "./dist/bun/index.js",
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/cjs/index.js",
"types": "./dist/index.d.ts"
"require": "./dist/cjs/index.js"
},
"./ws": {
"bun": "./dist/ws/index.js",
"types": "./dist/ws/index.d.ts",
"import": "./dist/ws/index.mjs",
"require": "./dist/cjs/ws/index.js",
"types": "./dist/ws/index.d.ts"
"require": "./dist/cjs/ws/index.js"
},
"./compose": {
"bun": "./dist/compose.js",
"types": "./dist/compose.d.ts",
"import": "./dist/compose.mjs",
"require": "./dist/cjs/compose.js",
"types": "./dist/compose.d.ts"
"require": "./dist/cjs/compose.js"
},
"./context": {
"bun": "./dist/context.js",
"types": "./dist/context.d.ts",
"import": "./dist/context.mjs",
"require": "./dist/cjs/context.js",
"types": "./dist/context.d.ts"
"require": "./dist/cjs/context.js"
},
"./cookie": {
"bun": "./dist/cookie.js",
"types": "./dist/cookie.d.ts",
"import": "./dist/cookie.mjs",
"require": "./dist/cjs/cookie.js",
"types": "./dist/cookie.d.ts"
"require": "./dist/cjs/cookie.js"
},
"./error": {
"bun": "./dist/error.js",
"types": "./dist/error.d.ts",
"import": "./dist/error.mjs",
"require": "./dist/cjs/error.js",
"types": "./dist/error.d.ts"
"require": "./dist/cjs/error.js"
},
"./handler": {
"bun": "./dist/handler.js",
"types": "./dist/handler.d.ts",
"import": "./dist/handler.mjs",
"require": "./dist/cjs/handler.js",
"types": "./dist/handler.d.ts"
"require": "./dist/cjs/handler.js"
},
"./schema": {
"bun": "./dist/schema.js",
"types": "./dist/schema.d.ts",
"import": "./dist/schema.mjs",
"require": "./dist/cjs/schema.js",
"types": "./dist/schema.d.ts"
"require": "./dist/cjs/schema.js"
},
"./trace": {
"bun": "./dist/trace.js",
"types": "./dist/trace.d.ts",
"import": "./dist/trace.mjs",
"require": "./dist/cjs/trace.js",
"types": "./dist/trace.d.ts"
"require": "./dist/cjs/trace.js"
},
"./type-system": {
"bun": "./dist/type-system.js",
"types": "./dist/type-system.d.ts",
"import": "./dist/type-system.mjs",
"require": "./dist/cjs/type-system.js",
"types": "./dist/type-system.d.ts"
"require": "./dist/cjs/type-system.js"
},
"./types": {
"bun": "./dist/types.js",
"types": "./dist/types.d.ts",
"import": "./dist/types.mjs",
"require": "./dist/cjs/types.js",
"types": "./dist/types.d.ts"
"require": "./dist/cjs/types.js"
},
"./utils": {
"bun": "./dist/utils.js",
"types": "./dist/utils.d.ts",
"import": "./dist/utils.mjs",
"require": "./dist/cjs/utils.js",
"types": "./dist/utils.d.ts"
"require": "./dist/cjs/utils.js"
}
},
"repository": {
Expand Down Expand Up @@ -126,9 +114,7 @@
"eslint-plugin-sonarjs": "^0.23.0",
"expect-type": "^0.16.0",
"memoirist": "0.1.6",
"ts-toolbelt": "^9.6.0",
"tsup": "^8.0.2",
"type-fest": "^4.10.1",
"typescript": "^5.4.2"
},
"peerDependencies": {
Expand Down

0 comments on commit 7165860

Please sign in to comment.