-
-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into chore/any-spam
- Loading branch information
Showing
40 changed files
with
1,201 additions
and
538 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,5 @@ build | |
dump.rdb | ||
dist | ||
trace | ||
.scannerwork | ||
.scannerwork | ||
*.tsbuildinfo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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()) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ new Elysia() | |
.get('/', () => ({ | ||
hello: 'world' | ||
})) | ||
.listen(8080) | ||
.listen(3000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,4 @@ new Elysia() | |
console.log(error) | ||
} | ||
}) | ||
.listen(8080) | ||
.listen(3000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ new Elysia() | |
|
||
return Bun.file('./example/takodachi.png') | ||
}) | ||
.listen(8080) | ||
.listen(3000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,4 +29,4 @@ new Elysia() | |
}) | ||
}) | ||
) | ||
.listen(8080) | ||
.listen(3000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,4 +7,4 @@ new Elysia() | |
set.headers['x-powered-by'] = 'Elysia' | ||
set.status = 'Bad Request' | ||
}) | ||
.listen(8080) | ||
.listen(3000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,4 +18,4 @@ new Elysia() | |
} | ||
] | ||
}) | ||
.listen(8080) | ||
.listen(3000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -31,4 +31,4 @@ new Elysia() | |
) | ||
) | ||
.get('*', () => 'Star now work') | ||
.listen(8080) | ||
.listen(3000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,4 +5,4 @@ new Elysia() | |
.get('/redirect', ({ set }) => { | ||
set.redirect = '/' | ||
}) | ||
.listen(8080) | ||
.listen(3000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,4 @@ new Elysia() | |
status: 418 | ||
}) | ||
}) | ||
.listen(8080) | ||
.listen(3000) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.