-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
uaAuthenticated route doctors server side added
- Loading branch information
Showing
3 changed files
with
47 additions
and
0 deletions.
There are no files selected for viewing
20 changes: 20 additions & 0 deletions
20
server/src/presentation/controllers/UnauthenticatedControllers.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import { StatusCode } from "../../types"; | ||
import UnauthenticatedUseCases from "../../use_case/UnauthenticatedUseCases"; | ||
import { NextFunction, Request, Response } from "express"; | ||
|
||
export default class UnathenicatedControllers { | ||
constructor(private unauthenticatedUseCase: UnauthenticatedUseCases) { } | ||
|
||
async getDoctors(req: Request, res: Response, next: NextFunction) { | ||
try { | ||
let offset = parseInt(req.query.offset as string); | ||
let limit = parseInt(req.query.limit as string); | ||
|
||
offset = isNaN(offset) || offset < 0 ? 0 : offset; | ||
limit = isNaN(limit) || limit < 0 ? 10 : Math.min(limit, 100); | ||
res.status(StatusCode.Success).json(await this.unauthenticatedUseCase.getDoctors(offset, limit)) | ||
} catch (error) { | ||
next(error) | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import IDoctor from "../domain/entities/IDoctor"; | ||
import IDoctorRepository from "../domain/interface/repositories/IDoctorRepository"; | ||
import { PaginatedResult } from "../types"; | ||
|
||
|
||
export default class UnauthenticatedUseCases { | ||
constructor(private doctorRepository: IDoctorRepository) { } | ||
|
||
|
||
|
||
async getDoctors(offset: number, limit: number): Promise<PaginatedResult<IDoctor>> { | ||
const isVerified = true; | ||
const isBlocked = false | ||
const data = await this.doctorRepository.findMany(offset, limit, isVerified, isBlocked); | ||
data.items = data.items.filter(item=>item.role!=='admin') | ||
return data; | ||
} | ||
} |
131534b
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
avm-care – ./
avm-care.vercel.app
avm-care-git-main-sinans-projects-8d312afe.vercel.app
avm-care-sinans-projects-8d312afe.vercel.app