@lovelybunch/api 1.0.7 → 1.0.9
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/dist/server-with-static.js +46 -40
- package/package.json +1 -1
|
@@ -47,39 +47,34 @@ app.get('/ws/terminal/:sessionId', upgradeWebSocket((c) => ({
|
|
|
47
47
|
}
|
|
48
48
|
})));
|
|
49
49
|
// Import and register API routes
|
|
50
|
-
import proposals from './routes/api/v1/proposals/
|
|
51
|
-
import
|
|
52
|
-
import
|
|
53
|
-
import
|
|
54
|
-
import
|
|
55
|
-
import
|
|
56
|
-
import
|
|
57
|
-
import
|
|
58
|
-
import
|
|
59
|
-
import
|
|
60
|
-
import
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
app.
|
|
68
|
-
app.
|
|
69
|
-
app.
|
|
70
|
-
app.
|
|
71
|
-
app.
|
|
72
|
-
app.
|
|
73
|
-
app.
|
|
74
|
-
app.
|
|
75
|
-
|
|
76
|
-
app.route('/api/v1/
|
|
77
|
-
app.route('/api/v1/
|
|
78
|
-
app.route('/api/v1/context', context);
|
|
79
|
-
app.route('/api/v1/config', config);
|
|
80
|
-
app.route('/api/v1/user', user);
|
|
81
|
-
app.route('/api/v1/agents', agents);
|
|
82
|
-
app.route('/api/v1/agents/:id', agentsById);
|
|
50
|
+
import * as proposals from './routes/api/v1/proposals/route.js';
|
|
51
|
+
import * as proposalsById from './routes/api/v1/proposals/[id]/route.js';
|
|
52
|
+
import * as terminalSessions from './routes/api/v1/terminal/sessions/route.js';
|
|
53
|
+
import * as ai from './routes/api/v1/ai/route.js';
|
|
54
|
+
import * as chats from './routes/api/v1/chats/route.js';
|
|
55
|
+
import * as chatsById from './routes/api/v1/chats/[id]/route.js';
|
|
56
|
+
import * as resources from './routes/api/v1/resources/route.js';
|
|
57
|
+
import * as resourcesById from './routes/api/v1/resources/[id]/route.js';
|
|
58
|
+
import * as config from './routes/api/v1/config/route.js';
|
|
59
|
+
import agentsApp from './routes/api/v1/agents/route.js';
|
|
60
|
+
import agentsByIdApp from './routes/api/v1/agents/[id]/route.js';
|
|
61
|
+
// Register API routes - individual handlers
|
|
62
|
+
app.get('/api/v1/proposals', proposals.GET);
|
|
63
|
+
app.post('/api/v1/proposals', proposals.POST);
|
|
64
|
+
app.get('/api/v1/proposals/:id', proposalsById.GET);
|
|
65
|
+
app.patch('/api/v1/proposals/:id', proposalsById.PATCH);
|
|
66
|
+
app.delete('/api/v1/proposals/:id', proposalsById.DELETE);
|
|
67
|
+
app.get('/api/v1/terminal/sessions', terminalSessions.GET);
|
|
68
|
+
app.post('/api/v1/ai', ai.POST);
|
|
69
|
+
app.get('/api/v1/chats', chats.GET);
|
|
70
|
+
app.post('/api/v1/chats', chats.POST);
|
|
71
|
+
app.get('/api/v1/chats/:id', chatsById.GET);
|
|
72
|
+
app.get('/api/v1/resources', resources.GET);
|
|
73
|
+
app.get('/api/v1/resources/:id', resourcesById.GET);
|
|
74
|
+
app.get('/api/v1/config', config.GET);
|
|
75
|
+
// Register API routes - Hono apps
|
|
76
|
+
app.route('/api/v1/agents', agentsApp);
|
|
77
|
+
app.route('/api/v1/agents', agentsByIdApp);
|
|
83
78
|
// Health check endpoint
|
|
84
79
|
app.get('/api/health', (c) => {
|
|
85
80
|
return c.json({ status: 'ok', timestamp: new Date().toISOString() });
|
|
@@ -109,15 +104,26 @@ for (const possiblePath of possibleStaticPaths) {
|
|
|
109
104
|
}
|
|
110
105
|
}
|
|
111
106
|
if (staticPath) {
|
|
112
|
-
// Serve static
|
|
113
|
-
app.use('/*', serveStatic({
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
107
|
+
// Serve static assets
|
|
108
|
+
app.use('/assets/*', serveStatic({ root: staticPath }));
|
|
109
|
+
// Serve specific static files
|
|
110
|
+
app.use('/vite.svg', serveStatic({ root: staticPath }));
|
|
111
|
+
app.use('/favicon.ico', serveStatic({ root: staticPath }));
|
|
112
|
+
// Serve index.html for all non-API, non-WebSocket routes (SPA routing)
|
|
113
|
+
app.get('*', async (c) => {
|
|
114
|
+
const requestPath = c.req.path;
|
|
115
|
+
// Don't serve index.html for API or WebSocket routes
|
|
116
|
+
if (requestPath.startsWith('/api/') || requestPath.startsWith('/ws/')) {
|
|
117
|
+
return c.text('Not Found', 404);
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
117
120
|
const html = fs.readFileSync(path.join(staticPath, 'index.html'), 'utf-8');
|
|
118
|
-
c.html(html);
|
|
121
|
+
return c.html(html);
|
|
122
|
+
}
|
|
123
|
+
catch (error) {
|
|
124
|
+
return c.text('Not Found', 404);
|
|
119
125
|
}
|
|
120
|
-
})
|
|
126
|
+
});
|
|
121
127
|
}
|
|
122
128
|
// Export function to start the server
|
|
123
129
|
export async function startServer(options = {}) {
|