Skip to content

Commit 7e3bf60

Browse files
Copilothotlong
andauthored
Changes before error encountered
Agent-Logs-Url: https://github.com/objectstack-ai/spec/sessions/3f488b6a-3c5e-42a1-bc4c-25061d45d6d5 Co-authored-by: hotlong <50353452+hotlong@users.noreply.github.com>
1 parent 6b2eadc commit 7e3bf60

18 files changed

Lines changed: 107 additions & 48 deletions

File tree

packages/adapters/express/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ export function createExpressRouter(options: ExpressAdapterOptions): Router {
7878
// ─── Explicit routes (framework-specific handling required) ────────────────
7979

8080
// --- Discovery ---
81-
router.get('/', async (_req: Request, res: Response) => {
81+
router.get('/discovery', async (_req: Request, res: Response) => {
8282
res.json({ data: await dispatcher.getDiscoveryInfo(prefix) });
8383
});
8484

packages/adapters/fastify/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,13 +76,13 @@ export async function objectStackPlugin(fastify: FastifyInstance, options: Fasti
7676
// ─── Explicit routes (framework-specific handling required) ────────────────
7777

7878
// --- Discovery ---
79-
fastify.get(`${prefix}`, async (_request: FastifyRequest, reply: FastifyReply) => {
79+
fastify.get(`${prefix}/discovery`, async (_request: FastifyRequest, reply: FastifyReply) => {
8080
return reply.send({ data: await dispatcher.getDiscoveryInfo(prefix) });
8181
});
8282

8383
// --- .well-known ---
8484
fastify.get('/.well-known/objectstack', async (_request: FastifyRequest, reply: FastifyReply) => {
85-
return reply.redirect(prefix);
85+
return reply.redirect(`${prefix}/discovery`);
8686
});
8787

8888
// --- Auth (needs auth service integration) ---

packages/adapters/hono/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,13 @@ export function createHonoApp(options: ObjectStackHonoOptions): Hono {
8181
// ─── Explicit routes (framework-specific handling required) ────────────────
8282

8383
// --- Discovery ---
84-
app.get(`${prefix}`, async (c) => {
84+
app.get(`${prefix}/discovery`, async (c) => {
8585
return c.json({ data: await dispatcher.getDiscoveryInfo(prefix) });
8686
});
8787

8888
// --- .well-known ---
8989
app.get('/.well-known/objectstack', (c) => {
90-
return c.redirect(prefix);
90+
return c.redirect(`${prefix}/discovery`);
9191
});
9292

9393
// --- Auth (needs auth service integration) ---

packages/adapters/nestjs/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ export class ObjectStackController {
9494
}
9595

9696
// --- Discovery Endpoint ---
97-
@Get()
97+
@Get('discovery')
9898
async discovery() {
9999
return { data: await this.service.dispatcher.getDiscoveryInfo('/api') };
100100
}
@@ -241,7 +241,7 @@ export class ObjectStackController {
241241
export class DiscoveryController {
242242
@Get('objectstack')
243243
discover(@Res() res: any) {
244-
return res.redirect('/api');
244+
return res.redirect('/api/discovery');
245245
}
246246
}
247247

packages/adapters/nestjs/src/nestjs.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -442,12 +442,12 @@ describe('ObjectStackController', () => {
442442
});
443443

444444
describe('DiscoveryController', () => {
445-
it('redirects to /api', () => {
445+
it('redirects to /api/discovery', () => {
446446
const controller = new DiscoveryController();
447447
const res = createMockRes();
448448

449449
controller.discover(res);
450450

451-
expect(res._redirectUrl).toBe('/api');
451+
expect(res._redirectUrl).toBe('/api/discovery');
452452
});
453453
});

packages/adapters/nextjs/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ export function createRouteHandler(options: NextAdapterOptions) {
6262
const method = req.method;
6363

6464
// --- 0. Discovery Endpoint ---
65-
if (segments.length === 0 && method === 'GET') {
65+
if (segments.length === 1 && segments[0] === 'discovery' && method === 'GET') {
6666
return NextResponse.json({ data: await dispatcher.getDiscoveryInfo(options.prefix || '/api') });
6767
}
6868

@@ -152,7 +152,7 @@ export function createDiscoveryHandler(options: NextAdapterOptions) {
152152
return async function discoveryHandler(req: NextRequest) {
153153
const apiPath = options.prefix || '/api';
154154
const url = new URL(req.url);
155-
const targetUrl = new URL(apiPath, url.origin);
155+
const targetUrl = new URL(`${apiPath}/discovery`, url.origin);
156156
return NextResponse.redirect(targetUrl);
157157
}
158158
}

packages/adapters/nuxt/src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ export function createH3Router(options: NuxtAdapterOptions): Router {
8989

9090
// --- Discovery ---
9191
router.get(
92-
`${prefix}`,
92+
`${prefix}/discovery`,
9393
defineEventHandler(async () => {
9494
return { data: await dispatcher.getDiscoveryInfo(prefix) };
9595
}),
@@ -99,7 +99,7 @@ export function createH3Router(options: NuxtAdapterOptions): Router {
9999
router.get(
100100
'/.well-known/objectstack',
101101
defineEventHandler((event) => {
102-
return sendRedirect(event, prefix);
102+
return sendRedirect(event, `${prefix}/discovery`);
103103
}),
104104
);
105105

packages/adapters/sveltekit/src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ export function createRequestHandler(options: SvelteKitAdapterOptions) {
9999
const segments = path.split('/').filter(Boolean);
100100

101101
// --- Discovery ---
102-
if (segments.length === 0 && method === 'GET') {
102+
if (segments.length === 1 && segments[0] === 'discovery' && method === 'GET') {
103103
return new Response(JSON.stringify({ data: await dispatcher.getDiscoveryInfo(prefix) }), {
104104
status: 200,
105105
headers: { 'Content-Type': 'application/json' },

packages/client/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -238,10 +238,10 @@ export class ObjectStackClient {
238238
this.logger.debug('Standard discovery probe failed', { error: (e as Error).message });
239239
}
240240

241-
// 2. Fallback to Legacy/Direct Path /api/v1
241+
// 2. Fallback to Protocol-standard Discovery Path /api/v1/discovery
242242
if (!data) {
243-
const fallbackUrl = `${this.baseUrl}/api/v1`;
244-
this.logger.debug('Falling back to legacy discovery', { url: fallbackUrl });
243+
const fallbackUrl = `${this.baseUrl}/api/v1/discovery`;
244+
this.logger.debug('Falling back to standard discovery endpoint', { url: fallbackUrl });
245245
const res = await this.fetchImpl(fallbackUrl);
246246
if (!res.ok) {
247247
throw new Error(`Failed to connect to ${fallbackUrl}: ${res.statusText}`);
@@ -1700,7 +1700,7 @@ export class ObjectStackClient {
17001700
notifications: '/api/v1/notifications',
17011701
ai: '/api/v1/ai',
17021702
i18n: '/api/v1/i18n',
1703-
feed: '/api/v1/data',
1703+
feed: '/api/v1/feed',
17041704
};
17051705

17061706
return routeMap[type] || `/api/v1/${type}`;

packages/plugins/plugin-hono-server/src/hono-plugin.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -276,8 +276,8 @@ export class HonoServerPlugin implements Plugin {
276276
};
277277

278278
// Discovery endpoints
279-
rawApp.get('/.well-known/objectstack', (c: any) => c.json({ data: discovery }));
280-
rawApp.get(prefix, (c: any) => c.json({ data: discovery }));
279+
rawApp.get('/.well-known/objectstack', (c: any) => c.redirect(`${prefix}/discovery`));
280+
rawApp.get(`${prefix}/discovery`, (c: any) => c.json({ data: discovery }));
281281

282282
ctx.logger.info('Registered discovery endpoints', { prefix });
283283

0 commit comments

Comments
 (0)