Skip to content

Commit

Permalink
📘 doc: use throw error
Browse files Browse the repository at this point in the history
  • Loading branch information
SaltyAom committed Dec 24, 2024
1 parent 718c648 commit 5dfebc8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 14 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Bug fix:
- [#971](https://github.com/elysiajs/elysia/issues/971) remove top level import, use dynamic import instead
- [#969](https://github.com/elysiajs/elysia/issues/969) Invalid context on `.onStart`, `.onStop`
- [#965](https://github.com/elysiajs/elysia/issues/965) [Composer] failed to generate optimized handler. Unexpected identifier 'mapCompactResponse'
- decorator name with space is not working

# 1.2.2 - 24 Dec 2024
Bug fix:
Expand Down
6 changes: 3 additions & 3 deletions build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,8 @@ await Promise.all([

await $`cp dist/index*.d.ts dist/bun`

const fsMjs = Bun.file('dist/universal/fs.mjs')
const fsMjsContent = await fsMjs.text()
Bun.write(fsMjs, fsMjsContent.replace(`require("fs")`, `await import("fs")`))
// const fsMjs = Bun.file('dist/universal/fs.mjs')
// const fsMjsContent = await fsMjs.text()
// Bun.write(fsMjs, fsMjsContent.replace(`require("fs")`, `await import("fs")`))

process.exit()
12 changes: 3 additions & 9 deletions example/a.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,12 @@ import { Elysia, file, getSchemaValidator, t } from '../src'
import { post, req } from '../test/utils'

const app = new Elysia()
.onAfterHandle(() => {
console.log('after handle')
})
.mapResponse((context) => {
return context.response
})
.get('/', async () => {
return 'ok'
.get('/image', async () => {
return file('test/kyuukurarin.mp4')
})
.listen(3000)

console.log(app.routes[0].compile().toString())
// console.log(app.routes[0].compile().toString())

// app.handle(req('/'))

Expand Down
4 changes: 2 additions & 2 deletions src/universal/file.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { type stat as Stat } from 'fs/promises'

import { isBun } from './utils'
import type { BunFile } from 'bun'
import { MaybePromise } from '../types'
import type { MaybePromise } from '../types'

export const mime = {
aac: 'audio/aac',
Expand Down Expand Up @@ -115,7 +115,7 @@ export class ElysiaFile {

return fs.createReadStream(path)
})
this.value = import('fs/promises').then((fs) => {
this.stats = import('fs/promises').then((fs) => {
stat = fs.stat

return fs.stat(path)
Expand Down

0 comments on commit 5dfebc8

Please sign in to comment.