Skip to content

Commit a7207d4

Browse files
chore: migrate removeInvite/:_id endpoint to chained API pattern with AJV validation
1 parent aa37226 commit a7207d4

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

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

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -170,19 +170,23 @@ const invites = API.v1
170170

171171
return API.v1.success((await findOrCreateInvite(this.userId, { rid, days, maxUses })) as IInvite);
172172
},
173-
);
174-
175-
API.v1.addRoute(
176-
'removeInvite/:_id',
177-
{ authRequired: true },
178-
{
179-
async delete() {
173+
)
174+
.delete(
175+
'removeInvite/:_id',
176+
{
177+
authRequired: true,
178+
response: {
179+
200: ajv.compile<boolean>({
180+
type: 'boolean',
181+
}),
182+
},
183+
},
184+
async function () {
180185
const { _id } = this.urlParams;
181186

182187
return API.v1.success(await removeInvite(this.userId, { _id }));
183188
},
184-
},
185-
);
189+
);
186190

187191
API.v1.addRoute(
188192
'useInviteToken',
@@ -239,5 +243,5 @@ type InvitesEndpoints = ExtractRoutesFromAPI<typeof invites>;
239243

240244
declare module '@rocket.chat/rest-typings' {
241245
// eslint-disable-next-line @typescript-eslint/naming-convention, @typescript-eslint/no-empty-interface
242-
interface Endpoints extends InvitesEndpoints {}
246+
interface Endpoints extends InvitesEndpoints { }
243247
}

packages/rest-typings/src/v1/invites.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ const SendInvitationEmailParamsSchema: JSONSchemaType<SendInvitationEmailParams>
8282
export const isSendInvitationEmailParams = ajv.compile<SendInvitationEmailParams>(SendInvitationEmailParamsSchema);
8383

8484
export type InvitesEndpoints = {
85-
'/v1/removeInvite/:_id': {
86-
DELETE: () => boolean;
87-
};
8885
'/v1/useInviteToken': {
8986
POST: (params: UseInviteTokenProps) => {
9087
room: {

0 commit comments

Comments
 (0)