Comparing version 0.12.2 to 0.12.3
{ | ||
"name": "bunshine", | ||
"version": "0.12.2", | ||
"version": "0.12.3", | ||
"module": "server/server.ts", | ||
@@ -5,0 +5,0 @@ "type": "module", |
@@ -1,7 +0,7 @@ | ||
<img alt="Bunshine Logo" src="https://github.com/kensnyder/bunshine/raw/main/assets/bunshine-logo.png?v=0.12.2" width="200" height="187" /> | ||
<img alt="Bunshine Logo" src="https://github.com/kensnyder/bunshine/raw/main/assets/bunshine-logo.png?v=0.12.3" width="200" height="187" /> | ||
[](https://npmjs.com/package/bunshine) | ||
[](https://www.npmjs.com/package/bunshine?activeTab=dependencies) | ||
 | ||
[](https://opensource.org/licenses/ISC) | ||
[](https://npmjs.com/package/bunshine) | ||
[](https://www.npmjs.com/package/bunshine?activeTab=dependencies) | ||
 | ||
[](https://opensource.org/licenses/ISC) | ||
@@ -8,0 +8,0 @@ # Bunshine |
@@ -84,3 +84,3 @@ import type { BunFile, Server } from 'bun'; | ||
} | ||
/** A shorthand for `new Response(fileBody, fileHeaders)` */ | ||
/** A shorthand for `new Response(bunFile, fileHeaders)` */ | ||
async file( | ||
@@ -87,0 +87,0 @@ filenameOrBunFile: string | BunFile, |
@@ -42,3 +42,4 @@ import { BunFile } from 'bun'; | ||
) { | ||
return new Response(file, { | ||
const body = process.versions.bun ? file : await file.arrayBuffer(); | ||
return new Response(body, { | ||
status: 200, | ||
@@ -45,0 +46,0 @@ headers: { |
@@ -64,4 +64,5 @@ import type { BunFile } from 'bun'; | ||
} else { | ||
const body = process.versions.bun ? file : await file.arrayBuffer(); | ||
// not in zipped cache; return original file | ||
return new Response(file, { | ||
return new Response(body, { | ||
status: 200, | ||
@@ -68,0 +69,0 @@ headers: { |
@@ -95,7 +95,7 @@ import type { ServeOptions, Server } from 'bun'; | ||
} | ||
listen(options: ListenOptions) { | ||
if (typeof options === 'number') { | ||
options = { port: options }; | ||
listen(portOrOptions: ListenOptions) { | ||
if (typeof portOrOptions === 'number') { | ||
portOrOptions = { port: portOrOptions }; | ||
} | ||
const server = Bun.serve(this.getExport(options)); | ||
const server = Bun.serve(this.getExport(portOrOptions)); | ||
this.server = server; | ||
@@ -102,0 +102,0 @@ return server; |
@@ -244,6 +244,7 @@ import { BunFile } from 'bun'; | ||
} else { | ||
const body = process.versions.bun ? file : await file.arrayBuffer(); | ||
// Bun will automatically set content-type and content-length, | ||
// but delays until the response is actually sent, but middleware might | ||
// want to know the file details ahead of time | ||
response = new Response(file, { | ||
response = new Response(body, { | ||
headers: { | ||
@@ -250,0 +251,0 @@ 'Content-Length': String(file.size), |
252998
4667