@fatdoge/wtree 0.1.6 → 0.1.8
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/api/createApiApp.ts
CHANGED
|
@@ -25,7 +25,7 @@ export function createApiApp(getRepoRoot: () => string) {
|
|
|
25
25
|
})
|
|
26
26
|
})
|
|
27
27
|
|
|
28
|
-
app.use((req: Request, res: Response) => {
|
|
28
|
+
app.use('/api', (req: Request, res: Response) => {
|
|
29
29
|
res.status(404).json({ ok: false, error: { code: 'NOT_FOUND', message: 'API not found' } })
|
|
30
30
|
})
|
|
31
31
|
|
package/api/ui/startUiDev.ts
CHANGED
|
@@ -63,7 +63,9 @@ export async function startUiDevServer(options: {
|
|
|
63
63
|
const combinedApp = express()
|
|
64
64
|
|
|
65
65
|
// 1. API routes
|
|
66
|
-
|
|
66
|
+
// The createApiApp returns an app that already handles /api routes.
|
|
67
|
+
// We should mount it at root, so requests to /api/xxx are handled correctly.
|
|
68
|
+
combinedApp.use(createApiApp(() => repoRoot))
|
|
67
69
|
|
|
68
70
|
// 2. Static files
|
|
69
71
|
combinedApp.use(serveStatic(distPath))
|
|
@@ -19,7 +19,7 @@ export function createApiApp(getRepoRoot) {
|
|
|
19
19
|
error: { code: 'INTERNAL', message: 'Server internal error' },
|
|
20
20
|
});
|
|
21
21
|
});
|
|
22
|
-
app.use((req, res) => {
|
|
22
|
+
app.use('/api', (req, res) => {
|
|
23
23
|
res.status(404).json({ ok: false, error: { code: 'NOT_FOUND', message: 'API not found' } });
|
|
24
24
|
});
|
|
25
25
|
return app;
|
|
@@ -43,7 +43,9 @@ export async function startUiDevServer(options) {
|
|
|
43
43
|
// Let's rewrite the logic to use a single server for both API and UI
|
|
44
44
|
const combinedApp = express();
|
|
45
45
|
// 1. API routes
|
|
46
|
-
|
|
46
|
+
// The createApiApp returns an app that already handles /api routes.
|
|
47
|
+
// We should mount it at root, so requests to /api/xxx are handled correctly.
|
|
48
|
+
combinedApp.use(createApiApp(() => repoRoot));
|
|
47
49
|
// 2. Static files
|
|
48
50
|
combinedApp.use(serveStatic(distPath));
|
|
49
51
|
// 3. SPA fallback
|