Skip to content

Commit 0536d0f

Browse files
committed
refactor: update app
1 parent 4b31c2b commit 0536d0f

File tree

7 files changed

+342
-107
lines changed

7 files changed

+342
-107
lines changed

app/index.html

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!doctype html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta name="viewport" content="width=device-width,initial-scale=1">
6+
<title>StackBlitz Zip API</title>
7+
<style>body{font-family:system-ui,-apple-system,Segoe UI,Roboto,Helvetica,Arial;margin:2rem}</style>
8+
</head>
9+
<body>
10+
<h1>StackBlitz Zip API</h1>
11+
<p>Replace <code>stackblitz.com</code> with <code>stackblitz.zip</code> in any StackBlitz URL.</p>
12+
<ul>
13+
<script server>
14+
const links = [
15+
'https://stackblitz.zip/edit/nuxt-starter-k7spa3r4',
16+
'https://stackblitz.zip/edit/vitejs-vite-starter',
17+
]
18+
</script>
19+
<? for (const link of links) { ?>
20+
<li><a href="<?= link ?>" target="_blank" rel="noopener noreferrer"><?= link ?></a></li>
21+
<? } ?>
22+
</ul>
23+
<p>The <code>.zip</code> extension is optional but recommended for clarity.</p>
24+
<footer style="margin-top:2rem;border-top:1px solid #eee;padding-top:1rem;font-size:0.9rem;color:#555">
25+
<p>Star on GitHub: <a href="https://github.com/danielroe/stackblitz.zip" target="_blank" rel="noopener noreferrer">danielroe/stackblitz.zip</a></p>
26+
</footer>
27+
</body>
28+
</html>

app/nitro.config.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { defineConfig } from 'nitro'
2+
3+
export default defineConfig({
4+
routeRules: {
5+
'/': { prerender: true },
6+
},
7+
})

app/package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,13 @@
77
"node": "^20.19.0 || >=22.12.0"
88
},
99
"scripts": {
10-
"dev": "vite dev",
11-
"build": "vite build",
10+
"dev": "nitro dev",
11+
"build": "nitro build",
1212
"postinstall": "cd .. && pnpm build",
1313
"preview": "node .output/server/index.mjs"
1414
},
1515
"dependencies": {
16-
"h3": "2.0.1-rc.5",
17-
"nitro": "latest",
16+
"nitro": "npm:nitro-nightly",
1817
"stackblitz-zip": "workspace:*",
1918
"vite": "^7.2.0"
2019
}

app/routes/index.ts

Lines changed: 0 additions & 13 deletions
This file was deleted.
Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1-
import { defineEventHandler, getRouterParam, HTTPError } from 'h3'
1+
import { defineHandler, HTTPError } from 'nitro/h3'
22
import { downloadToBlob, parseUrl } from 'stackblitz-zip'
33

4-
export default defineEventHandler(async (event) => {
5-
const path = getRouterParam(event, 'path')
4+
export default defineHandler(async (event) => {
5+
if (event.url.pathname === '/')
6+
return
7+
8+
const path = event.context.params!.path
69

710
if (!path) {
811
throw new HTTPError({

app/vite.config.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,5 @@ import { nitro } from 'nitro/vite'
22
import { defineConfig } from 'vite'
33

44
export default defineConfig({
5-
plugins: [
6-
nitro({
7-
config: {
8-
routeRules: {
9-
'/': { prerender: true },
10-
},
11-
},
12-
}),
13-
],
5+
plugins: [nitro()],
146
})

0 commit comments

Comments
 (0)