Skip to content

Commit

Permalink
Create the mentee revoke mentee application API
Browse files Browse the repository at this point in the history
  • Loading branch information
anjula-sack committed Sep 1, 2024
1 parent 3130cf7 commit 34d5d0e
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
7 changes: 7 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
node_modules
npm-debug.log
dist
.git
*.md
.gitignore
.env
26 changes: 25 additions & 1 deletion src/controllers/mentee.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import type { Request, Response } from 'express'
import { type ApiResponse } from '../types'
import type Mentee from '../entities/mentee.entity'
import type Profile from '../entities/profile.entity'
import { getMentee, updateStatus } from '../services/admin/mentee.service'
import {
getMentee,
revoke,
updateStatus
} from '../services/admin/mentee.service'
import { MentorApplicationStatus, StatusUpdatedBy } from '../enums'
import { addMentee, getPublicMentee } from '../services/mentee.service'

Expand Down Expand Up @@ -65,6 +69,26 @@ export const updateMenteeStatus = async (
}
}

export const revokeApplication = async (
req: Request,
res: Response
): Promise<ApiResponse<Mentee>> => {
try {
const user = req.user as Profile

const { statusCode, message } = await revoke(user.uuid)
return res.status(statusCode).json({ message })
} catch (err) {
if (err instanceof Error) {
console.error('Error executing query', err)
return res
.status(500)
.json({ error: 'Internal server error', message: err.message })
}
throw err
}
}

export const getMenteeDetails = async (
req: Request,
res: Response
Expand Down
2 changes: 2 additions & 0 deletions src/routes/mentee/mentee.route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import {
getMenteeDetails,
getPublicMenteeDetails,
menteeApplicationHandler,
revokeApplication,
updateMenteeStatus
} from '../../controllers/mentee.controller'
import { requestBodyValidator } from '../../middlewares/requestValidator'
Expand All @@ -26,5 +27,6 @@ menteeRouter.put(
[requireAuth, requestBodyValidator(updateMenteeStatusSchema)],
updateMenteeStatus
)
menteeRouter.put('/revoke-application', requireAuth, revokeApplication)

export default menteeRouter

0 comments on commit 34d5d0e

Please sign in to comment.