@lovelybunch/api 1.0.9 → 1.0.10

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.
@@ -58,6 +58,46 @@ import * as resourcesById from './routes/api/v1/resources/[id]/route.js';
58
58
  import * as config from './routes/api/v1/config/route.js';
59
59
  import agentsApp from './routes/api/v1/agents/route.js';
60
60
  import agentsByIdApp from './routes/api/v1/agents/[id]/route.js';
61
+ // Handle trailing slashes by creating explicit redirect routes
62
+ const trailingSlashRoutes = [
63
+ '/api/v1/proposals/',
64
+ '/api/v1/terminal/sessions/',
65
+ '/api/v1/ai/',
66
+ '/api/v1/chats/',
67
+ '/api/v1/resources/',
68
+ '/api/v1/config/'
69
+ ];
70
+ // Add explicit handlers for trailing slash routes that redirect to non-slash versions
71
+ trailingSlashRoutes.forEach(route => {
72
+ const methods = ['GET', 'POST', 'PUT', 'PATCH', 'DELETE'];
73
+ methods.forEach(method => {
74
+ app.on(method, route, (c) => {
75
+ const newPath = route.slice(0, -1);
76
+ const url = new URL(c.req.url);
77
+ url.pathname = newPath;
78
+ return c.redirect(url.toString(), 308);
79
+ });
80
+ });
81
+ });
82
+ // Handle trailing slashes for parameterized routes
83
+ app.on(['GET', 'PUT', 'PATCH', 'DELETE'], '/api/v1/proposals/:id/', (c) => {
84
+ const id = c.req.param('id');
85
+ const url = new URL(c.req.url);
86
+ url.pathname = `/api/v1/proposals/${id}`;
87
+ return c.redirect(url.toString(), 308);
88
+ });
89
+ app.on(['GET', 'PUT', 'DELETE'], '/api/v1/chats/:id/', (c) => {
90
+ const id = c.req.param('id');
91
+ const url = new URL(c.req.url);
92
+ url.pathname = `/api/v1/chats/${id}`;
93
+ return c.redirect(url.toString(), 308);
94
+ });
95
+ app.on(['GET'], '/api/v1/resources/:id/', (c) => {
96
+ const id = c.req.param('id');
97
+ const url = new URL(c.req.url);
98
+ url.pathname = `/api/v1/resources/${id}`;
99
+ return c.redirect(url.toString(), 308);
100
+ });
61
101
  // Register API routes - individual handlers
62
102
  app.get('/api/v1/proposals', proposals.GET);
63
103
  app.post('/api/v1/proposals', proposals.POST);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lovelybunch/api",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "type": "module",
5
5
  "main": "dist/server-with-static.js",
6
6
  "exports": {