apigrip 0.2.0 → 0.2.2
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/client/dist/index.html
CHANGED
|
@@ -10,7 +10,7 @@
|
|
|
10
10
|
if (t) document.documentElement.setAttribute('data-theme', t);
|
|
11
11
|
} catch (e) {}
|
|
12
12
|
</script>
|
|
13
|
-
<script type="module" crossorigin src="/assets/index-
|
|
13
|
+
<script type="module" crossorigin src="/assets/index-B6sjbmFk.js"></script>
|
|
14
14
|
<link rel="stylesheet" crossorigin href="/assets/index-kzeRjfI8.css">
|
|
15
15
|
</head>
|
|
16
16
|
<body>
|
package/package.json
CHANGED
package/server/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import express from 'express';
|
|
2
|
+
import fs from 'node:fs';
|
|
2
3
|
import path from 'node:path';
|
|
3
4
|
import { fileURLToPath } from 'node:url';
|
|
4
5
|
import { createProjectRoutes } from './routes/project.js';
|
|
@@ -42,12 +43,20 @@ export function createServer(options = {}) {
|
|
|
42
43
|
// Serve frontend static files
|
|
43
44
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
|
44
45
|
const clientDist = path.resolve(__dirname, '../client/dist');
|
|
45
|
-
|
|
46
|
+
const indexHtml = path.join(clientDist, 'index.html');
|
|
46
47
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
48
|
+
if (fs.existsSync(indexHtml)) {
|
|
49
|
+
app.use(express.static(clientDist));
|
|
50
|
+
|
|
51
|
+
// SPA fallback: serve index.html for all non-API routes
|
|
52
|
+
app.get('/{*splat}', (req, res) => {
|
|
53
|
+
res.sendFile(indexHtml);
|
|
54
|
+
});
|
|
55
|
+
} else {
|
|
56
|
+
app.get('/{*splat}', (req, res) => {
|
|
57
|
+
res.status(503).send('Frontend not built. Run: npm run build');
|
|
58
|
+
});
|
|
59
|
+
}
|
|
51
60
|
|
|
52
61
|
return { app, state };
|
|
53
62
|
}
|