Skip to content

Commit 9425f11

Browse files
ggazzoclaude
andcommitted
refactor(api): migrate chat.getURLPreview to typed endpoint with response schema
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
1 parent a97701a commit 9425f11

1 file changed

Lines changed: 22 additions & 9 deletions

File tree

  • apps/meteor/app/api/server/v1

apps/meteor/app/api/server/v1/chat.ts

Lines changed: 22 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1328,13 +1328,27 @@ const chatEndpoints = API.v1
13281328
});
13291329
return API.v1.success(messages);
13301330
},
1331-
);
1332-
1333-
API.v1.addRoute(
1334-
'chat.getURLPreview',
1335-
{ authRequired: true, validateParams: isChatGetURLPreviewProps },
1336-
{
1337-
async get() {
1331+
)
1332+
.get(
1333+
'chat.getURLPreview',
1334+
{
1335+
authRequired: true,
1336+
query: isChatGetURLPreviewProps,
1337+
response: {
1338+
200: ajv.compile<{ urlPreview: object }>({
1339+
type: 'object',
1340+
properties: {
1341+
urlPreview: { type: 'object' },
1342+
success: { type: 'boolean', enum: [true] },
1343+
},
1344+
required: ['urlPreview', 'success'],
1345+
additionalProperties: false,
1346+
}),
1347+
400: validateBadRequestErrorResponse,
1348+
401: validateUnauthorizedErrorResponse,
1349+
},
1350+
},
1351+
async function action() {
13381352
const { roomId, url } = this.queryParams;
13391353

13401354
if (!(await canAccessRoomIdAsync(roomId, this.userId))) {
@@ -1346,8 +1360,7 @@ API.v1.addRoute(
13461360

13471361
return API.v1.success({ urlPreview });
13481362
},
1349-
},
1350-
);
1363+
);
13511364

13521365
export type ChatEndpoints = ExtractRoutesFromAPI<typeof chatEndpoints>;
13531366

0 commit comments

Comments
 (0)