Skip to content

Commit 1a6351e

Browse files
committed
perf: migrate to client-zip
1 parent fdd1a97 commit 1a6351e

File tree

6 files changed

+69
-101
lines changed

6 files changed

+69
-101
lines changed

app/server.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { defineHandler, HTTPError } from 'nitro/h3'
2-
import { downloadToBlob, parseUrl } from 'stackblitz-zip'
2+
import { downloadToResponse, parseUrl } from 'stackblitz-zip'
33

44
export default defineHandler(async (event) => {
55
const { pathname } = event.url
@@ -19,13 +19,13 @@ export default defineHandler(async (event) => {
1919

2020
try {
2121
const projectId = parseUrl(stackblitzUrl)
22-
const blob = await downloadToBlob({ projectId, verbose: true })
22+
const response = await downloadToResponse({ projectId, verbose: true })
2323

2424
// Set headers for file download
2525
event.res.headers.set('Content-Type', 'application/zip')
2626
event.res.headers.set('Content-Disposition', `attachment; filename="${projectId}.zip"`)
2727

28-
return blob
28+
return response.blob()
2929
}
3030
catch (error) {
3131
throw new HTTPError({

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
"test:types": "tsc --noEmit"
4141
},
4242
"dependencies": {
43-
"jszip": "^3.10.1"
43+
"client-zip": "^2.4.5"
4444
},
4545
"devDependencies": {
4646
"@antfu/eslint-config": "latest",
@@ -55,6 +55,7 @@
5555
"simple-git-hooks": "latest",
5656
"tsdown": "latest",
5757
"typescript": "latest",
58+
"unzipit": "^1.4.3",
5859
"vitest": "latest"
5960
},
6061
"resolutions": {

pnpm-lock.yaml

Lines changed: 26 additions & 76 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)