File tree Expand file tree Collapse file tree 2 files changed +29
-0
lines changed Expand file tree Collapse file tree 2 files changed +29
-0
lines changed 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 . nativeDelete ( Profile , { uid : uid } ) ;
14
+ await em . nativeDelete ( Activity , { uid : uid } ) ;
15
+
16
+ const response : ApiResponse = {
17
+ statusMessage : {
18
+ message : "Profile deleted successfully" ,
19
+ type : StatusMessageType . SUCCESS ,
20
+ } ,
21
+ payload : { } ,
22
+ } ;
23
+ res . status ( 200 ) . send ( response ) ;
24
+ } catch ( err : any ) {
25
+ handleServerError ( err , res ) ;
26
+ }
27
+ }
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