From 529c9f0b00dd66b52d5aef1d3f1930d715df3dee Mon Sep 17 00:00:00 2001 From: Gerzon Z Date: Wed, 2 Mar 2022 16:08:56 -0400 Subject: [PATCH] Chore: Migrate REST API - register to TS (#3796) * Migrate `user.register` to TypeScript --- app/definitions/IUser.ts | 10 ++++++++++ app/definitions/rest/v1/user.ts | 5 ++++- app/lib/rocketchat/services/restApi.ts | 4 +--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/app/definitions/IUser.ts b/app/definitions/IUser.ts index 474a2105..e1746554 100644 --- a/app/definitions/IUser.ts +++ b/app/definitions/IUser.ts @@ -22,6 +22,16 @@ export interface IPersonalAccessToken extends ILoginToken { bypassTwoFactor?: boolean; } +export interface IUserRegistered { + _id: string; + type: string; + status: UserStatus; + active: boolean; + name: string; + username: string; + __rooms: string[]; +} + export interface IUserEmailVerificationToken { token: string; address: string; diff --git a/app/definitions/rest/v1/user.ts b/app/definitions/rest/v1/user.ts index 7de12aab..b8c37cc1 100644 --- a/app/definitions/rest/v1/user.ts +++ b/app/definitions/rest/v1/user.ts @@ -1,4 +1,4 @@ -import { IUser } from '../../IUser'; +import { IUser, IUserRegistered } from '../../IUser'; export type UserEndpoints = { 'users.info': { @@ -11,4 +11,7 @@ export type UserEndpoints = { success: boolean; }; }; + 'users.register': { + POST: (params: { name: string; email: string; username: string; pass: string }) => { user: IUserRegistered }; + }; }; diff --git a/app/lib/rocketchat/services/restApi.ts b/app/lib/rocketchat/services/restApi.ts index 51526901..19217ef1 100644 --- a/app/lib/rocketchat/services/restApi.ts +++ b/app/lib/rocketchat/services/restApi.ts @@ -67,10 +67,8 @@ export const updateJitsiTimeout = (roomId: string): any => // @ts-ignore sdk.post('video-conference/jitsi.update-timeout', { roomId }); -export const register = (credentials: any): any => +export const register = (credentials: { name: string; email: string; pass: string; username: string }) => // RC 0.50.0 - // TODO: missing definitions from server - // @ts-ignore sdk.post('users.register', credentials); export const forgotPassword = (email: string): any =>