@buntal/http 0.0.8 → 0.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.ts +2 -2
- package/package.json +1 -1
- package/router/index.ts +1 -1
package/index.ts
CHANGED
|
@@ -41,7 +41,6 @@ export class Http {
|
|
|
41
41
|
constructor(private config: Config) {}
|
|
42
42
|
|
|
43
43
|
start(cb?: (server: Bun.Server) => void) {
|
|
44
|
-
const res = new Res()
|
|
45
44
|
const middlewares = this.middlewares
|
|
46
45
|
|
|
47
46
|
const server = Bun.serve({
|
|
@@ -52,6 +51,7 @@ export class Http {
|
|
|
52
51
|
fetch: async (raw: Request, server): Promise<Response | any> => {
|
|
53
52
|
if (this.config.websocket && server.upgrade(raw)) return
|
|
54
53
|
|
|
54
|
+
const res = new Res()
|
|
55
55
|
if (raw.method === 'OPTIONS') {
|
|
56
56
|
return res.send('departed')
|
|
57
57
|
}
|
|
@@ -92,6 +92,7 @@ export class Http {
|
|
|
92
92
|
if (this.errorHandler) {
|
|
93
93
|
return await this.errorHandler(error)
|
|
94
94
|
}
|
|
95
|
+
const res = new Res()
|
|
95
96
|
return res.status(500).json({
|
|
96
97
|
error: error.message,
|
|
97
98
|
details: error.stack
|
|
@@ -184,4 +185,3 @@ export class Http {
|
|
|
184
185
|
export * from './app'
|
|
185
186
|
export * from './router'
|
|
186
187
|
export * from './handler'
|
|
187
|
-
export * from './middlewares'
|
package/package.json
CHANGED
package/router/index.ts
CHANGED