Skip to content

Commit

Permalink
feat: Delete /user endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
eleanorreem committed May 28, 2024
1 parent 75e6359 commit 25de1ac
Show file tree
Hide file tree
Showing 7 changed files with 307 additions and 48 deletions.
16 changes: 16 additions & 0 deletions src/firebase/firebase.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { SlackMessageClient } from 'src/api/slack/slack-api';
import { ZapierWebhookClient } from 'src/api/zapier/zapier-webhook-client';
import { CourseUserService } from 'src/course-user/course-user.service';
import { CourseUserEntity } from 'src/entities/course-user.entity';
import { PartnerAccessEntity } from 'src/entities/partner-access.entity';
import { PartnerAdminEntity } from 'src/entities/partner-admin.entity';
import { PartnerEntity } from 'src/entities/partner.entity';
import { SubscriptionUserEntity } from 'src/entities/subscription-user.entity';
import { SubscriptionEntity } from 'src/entities/subscription.entity';
import { TherapySessionEntity } from 'src/entities/therapy-session.entity';
import { UserEntity } from 'src/entities/user.entity';
import { PartnerService } from 'src/partner/partner.service';
import { SubscriptionUserService } from 'src/subscription-user/subscription-user.service';
import { SubscriptionService } from 'src/subscription/subscription.service';
import { TherapySessionService } from 'src/therapy-session/therapy-session.service';
import { PartnerAccessService } from '../partner-access/partner-access.service';
import { UserService } from '../user/user.service';
import { FIREBASE, firebaseFactory } from './firebase-factory';
Expand All @@ -19,6 +27,9 @@ import { FIREBASE, firebaseFactory } from './firebase-factory';
PartnerAccessEntity,
CourseUserEntity,
PartnerAdminEntity,
SubscriptionUserEntity,
SubscriptionEntity,
TherapySessionEntity,
]),
],
providers: [
Expand All @@ -27,6 +38,11 @@ import { FIREBASE, firebaseFactory } from './firebase-factory';
PartnerAccessService,
CourseUserService,
PartnerService,
SubscriptionUserService,
SubscriptionService,
TherapySessionService,
ZapierWebhookClient,
SlackMessageClient,
],
exports: [FIREBASE],
})
Expand Down
24 changes: 23 additions & 1 deletion src/partner-access/partner-access.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { SlackMessageClient } from 'src/api/slack/slack-api';
import { ZapierWebhookClient } from 'src/api/zapier/zapier-webhook-client';
import { CourseUserService } from 'src/course-user/course-user.service';
import { CourseUserEntity } from 'src/entities/course-user.entity';
import { PartnerAccessEntity } from 'src/entities/partner-access.entity';
import { PartnerAdminEntity } from 'src/entities/partner-admin.entity';
import { PartnerEntity } from 'src/entities/partner.entity';
import { SubscriptionUserEntity } from 'src/entities/subscription-user.entity';
import { SubscriptionEntity } from 'src/entities/subscription.entity';
import { TherapySessionEntity } from 'src/entities/therapy-session.entity';
import { UserEntity } from 'src/entities/user.entity';
import { PartnerService } from 'src/partner/partner.service';
import { SubscriptionUserService } from 'src/subscription-user/subscription-user.service';
import { SubscriptionService } from 'src/subscription/subscription.service';
import { TherapySessionService } from 'src/therapy-session/therapy-session.service';
import { AuthService } from '../auth/auth.service';
import { FirebaseModule } from '../firebase/firebase.module';
import { UserService } from '../user/user.service';
Expand All @@ -21,10 +29,24 @@ import { PartnerAccessService } from './partner-access.service';
PartnerAccessEntity,
PartnerAdminEntity,
CourseUserEntity,
SubscriptionUserEntity,
TherapySessionEntity,
SubscriptionEntity,
]),
FirebaseModule,
],
controllers: [PartnerAccessController],
providers: [PartnerAccessService, AuthService, UserService, CourseUserService, PartnerService],
providers: [
PartnerAccessService,
AuthService,
UserService,
CourseUserService,
PartnerService,
SubscriptionUserService,
SubscriptionService,
TherapySessionService,
ZapierWebhookClient,
SlackMessageClient,
],
})
export class PartnerAccessModule {}
16 changes: 16 additions & 0 deletions src/session-user/session-user.module.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,22 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { SlackMessageClient } from 'src/api/slack/slack-api';
import { ZapierWebhookClient } from 'src/api/zapier/zapier-webhook-client';
import { CourseUserEntity } from 'src/entities/course-user.entity';
import { CourseEntity } from 'src/entities/course.entity';
import { PartnerAccessEntity } from 'src/entities/partner-access.entity';
import { PartnerAdminEntity } from 'src/entities/partner-admin.entity';
import { PartnerEntity } from 'src/entities/partner.entity';
import { SessionUserEntity } from 'src/entities/session-user.entity';
import { SessionEntity } from 'src/entities/session.entity';
import { SubscriptionUserEntity } from 'src/entities/subscription-user.entity';
import { SubscriptionEntity } from 'src/entities/subscription.entity';
import { TherapySessionEntity } from 'src/entities/therapy-session.entity';
import { UserEntity } from 'src/entities/user.entity';
import { PartnerService } from 'src/partner/partner.service';
import { SubscriptionUserService } from 'src/subscription-user/subscription-user.service';
import { SubscriptionService } from 'src/subscription/subscription.service';
import { TherapySessionService } from 'src/therapy-session/therapy-session.service';
import { CourseUserService } from '../course-user/course-user.service';
import { CourseService } from '../course/course.service';
import { PartnerAccessService } from '../partner-access/partner-access.service';
Expand All @@ -28,6 +36,9 @@ import { SessionUserService } from './session-user.service';
PartnerAccessEntity,
CourseEntity,
PartnerAdminEntity,
SubscriptionUserEntity,
TherapySessionEntity,
SubscriptionEntity,
]),
],
controllers: [SessionUserController],
Expand All @@ -39,6 +50,11 @@ import { SessionUserService } from './session-user.service';
PartnerAccessService,
CourseService,
PartnerService,
SubscriptionUserService,
TherapySessionService,
SubscriptionService,
ZapierWebhookClient,
SlackMessageClient,
],
})
export class SessionUserModule {}
13 changes: 3 additions & 10 deletions src/user/user.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,20 +63,13 @@ export class UserController {
return req['user'];
}

// TODO - work out if this is used anywhere and delete if necessary
@ApiBearerAuth()
@Post('/delete')
@UseGuards(FirebaseAuthGuard)
async deleteUserRecord(@Req() req: Request): Promise<string> {
return await this.userService.deleteUser(req['user'] as GetUserDto);
}

@ApiBearerAuth()
@Delete()
@UseGuards(FirebaseAuthGuard)
async deleteUser(@Req() req: Request): Promise<string> {
return await this.userService.deleteUser(req['user'] as GetUserDto);
async deleteUser(@Req() req: Request): Promise<UserEntity> {
return await this.userService.deleteUser(req['user'].user as UserEntity);
}

// This route must go before the Delete user route below as we want nestjs to check against this one first
@ApiBearerAuth('access-token')
@Delete('/cypress')
Expand Down
26 changes: 25 additions & 1 deletion src/user/user.module.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,20 @@
import { Module } from '@nestjs/common';
import { TypeOrmModule } from '@nestjs/typeorm';
import { SlackMessageClient } from 'src/api/slack/slack-api';
import { ZapierWebhookClient } from 'src/api/zapier/zapier-webhook-client';
import { CourseUserService } from 'src/course-user/course-user.service';
import { CourseUserEntity } from 'src/entities/course-user.entity';
import { PartnerAccessEntity } from 'src/entities/partner-access.entity';
import { PartnerAdminEntity } from 'src/entities/partner-admin.entity';
import { PartnerEntity } from 'src/entities/partner.entity';
import { SubscriptionUserEntity } from 'src/entities/subscription-user.entity';
import { SubscriptionEntity } from 'src/entities/subscription.entity';
import { TherapySessionEntity } from 'src/entities/therapy-session.entity';
import { UserEntity } from 'src/entities/user.entity';
import { PartnerService } from 'src/partner/partner.service';
import { SubscriptionUserService } from 'src/subscription-user/subscription-user.service';
import { SubscriptionService } from 'src/subscription/subscription.service';
import { TherapySessionService } from 'src/therapy-session/therapy-session.service';
import { AuthService } from '../auth/auth.service';
import { FirebaseModule } from '../firebase/firebase.module';
import { PartnerAccessService } from '../partner-access/partner-access.service';
Expand All @@ -21,10 +29,26 @@ import { UserService } from './user.service';
PartnerEntity,
CourseUserEntity,
PartnerAdminEntity,
TherapySessionEntity,
SubscriptionUserEntity,
SubscriptionEntity,
TherapySessionEntity,
]),
FirebaseModule,
],
controllers: [UserController],
providers: [UserService, AuthService, PartnerAccessService, PartnerService, CourseUserService],
providers: [
UserService,
AuthService,
PartnerAccessService,
PartnerService,
CourseUserService,
TherapySessionService,
SubscriptionUserService,
SubscriptionService,
SlackMessageClient,
ZapierWebhookClient,
TherapySessionService,
],
})
export class UserModule {}
Loading

0 comments on commit 25de1ac

Please sign in to comment.