-
-
Notifications
You must be signed in to change notification settings - Fork 226
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #25 from elysiajs/next
feat: 0.3 - 大地の閾を探して [Looking for Edge of Ground]
- Loading branch information
Showing
40 changed files
with
3,098 additions
and
977 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
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,23 +1,26 @@ | ||
.git | ||
.gitignore | ||
.prettierrc | ||
.eslintrc.js | ||
.cjs.swcrc | ||
.es.swcrc | ||
.esm.swcrc | ||
.swcrc | ||
bun.lockb | ||
.husky | ||
.github | ||
|
||
bun.lockb | ||
node_modules | ||
tsconfig.json | ||
CHANGELOG.md | ||
|
||
example | ||
tests | ||
docs | ||
src | ||
# src | ||
.DS_Store | ||
test | ||
CHANGELOG.md | ||
.eslintrc.js | ||
tsconfig.cjs.json | ||
tsconfig.esm.json | ||
|
||
CONTRIBUTING.md | ||
CODE_OF_CONDUCT.md |
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,33 +1,78 @@ | ||
import { Elysia, t } from '../src' | ||
|
||
const authenticate = (app: Elysia) => | ||
app.group('/authenticate', (group) => | ||
group | ||
export const plugin = (app: Elysia) => | ||
app.group('/a', (app) => | ||
app | ||
.setModel({ | ||
sign: t.Object({ | ||
username: t.String() | ||
}) | ||
}) | ||
.post( | ||
'/login', | ||
({ body: { username, password }, set }) => { | ||
throw new Error('A') | ||
}, | ||
'/json/:id', | ||
({ body, params: { id }, query: { name } }) => 'h', | ||
{ | ||
beforeHandle: ({ body: { username, password }, set }) => {}, | ||
schema: { | ||
body: t.Object({ | ||
username: t.String(), | ||
password: t.String() | ||
}) | ||
headers: 'sign', | ||
params: t.Object({ | ||
id: t.Number() | ||
}), | ||
response: { | ||
200: t.String(), | ||
400: t.String() | ||
}, | ||
detail: { | ||
summary: 'Transform path parameter' | ||
} | ||
} | ||
} | ||
) | ||
.onError(({ code, error, set }) => { | ||
console.log("A") | ||
) | ||
|
||
return { | ||
status: 400, | ||
body: { | ||
error: 'Bad request' | ||
} | ||
} | ||
const app = new Elysia({ | ||
serve: { | ||
// Max payload in byte | ||
maxRequestBodySize: 1024 | ||
} | ||
}) | ||
.use(plugin) | ||
.derive((context) => { | ||
return { | ||
a: 'b' | ||
} | ||
}) | ||
.decorate('A', 'b') | ||
.post('/sign', ({ body }) => body, { | ||
schema: { | ||
body: t.Object({ | ||
email: t.String({ | ||
format: 'email' | ||
}), | ||
time: t.String({ | ||
format: 'date-time' | ||
}) | ||
}) | ||
) | ||
} | ||
}) | ||
.post( | ||
'/file', | ||
({ set, a, A }) => { | ||
const file = Bun.file('') | ||
if (file.size === 0) { | ||
set.status = 404 | ||
return 2 | ||
} | ||
|
||
const app = new Elysia().use(authenticate).listen(8080) | ||
return file | ||
}, | ||
{ | ||
error({ set }) {}, | ||
schema: { | ||
response: t.Object({ | ||
200: t.File(), | ||
404: t.Number() | ||
}) | ||
} | ||
} | ||
) | ||
.listen(8080) |
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 |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Elysia } from '../src' | ||
|
||
const app = new Elysia() | ||
.get('/', () => 'Hello Elysia') | ||
.fn({ | ||
mirror: async <T extends string>(value: T) => { | ||
if (value === 'false') throw new Error("Value can't be false") | ||
|
||
return value | ||
} | ||
}) | ||
.listen(8080) |
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.