File tree Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Expand file tree Collapse file tree 3 files changed +32
-1
lines changed Original file line number Diff line number Diff line change @@ -6,7 +6,7 @@ export class Activity {
6
6
uid ! : string ;
7
7
8
8
@PrimaryKey ( )
9
- questionId ! : number ;
9
+ questionId ! : string ;
10
10
11
11
@Property ( )
12
12
submitted ! : Date ;
Original file line number Diff line number Diff line change
1
+ import { Request , Response } from "express" ;
2
+ import { Profile } from "../entities/Profile" ;
3
+ import { ApiResponse , StatusMessageType } from "../types" ;
4
+ import { handleServerError } from "../utils" ;
5
+ import { getAuth } from "firebase-admin/auth" ;
6
+ import { Activity } from "../entities/Activity" ;
7
+
8
+ export async function deleteProfileHandler ( req : Request , res : Response ) {
9
+ const em = req . orm . em . fork ( ) ;
10
+ const uid = req . userToken . uid ;
11
+
12
+ try {
13
+ await em . transactional ( async ( manager ) => {
14
+ await manager . nativeDelete ( Profile , { uid : uid } ) ;
15
+ await manager . nativeDelete ( Activity , { uid : uid } ) ;
16
+ } ) ;
17
+
18
+ const response : ApiResponse = {
19
+ statusMessage : {
20
+ message : "Profile deleted successfully" ,
21
+ type : StatusMessageType . SUCCESS ,
22
+ } ,
23
+ payload : { } ,
24
+ } ;
25
+ res . status ( 200 ) . send ( response ) ;
26
+ } catch ( err : any ) {
27
+ handleServerError ( err , res ) ;
28
+ }
29
+ }
Original file line number Diff line number Diff line change 1
1
import { Router } from "express" ;
2
2
import { updateProfileHandler , updateProfileMulter } from "./update" ;
3
3
import { viewProfileHandler } from "./view" ;
4
+ import { deleteProfileHandler } from "./delete" ;
4
5
5
6
const router = Router ( ) ;
6
7
7
8
router . post ( "/" , updateProfileMulter , updateProfileHandler ) ;
8
9
router . get ( "/" , viewProfileHandler ) ;
10
+ router . delete ( "/" , deleteProfileHandler ) ;
9
11
10
12
export default router ;
You can’t perform that action at this time.
0 commit comments