Skip to content

Instantly share code, notes, and snippets.

@qodirovshohijahon
Created January 11, 2021 16:49
Show Gist options
  • Save qodirovshohijahon/5c3ef3857572cb26544cdf5484353de8 to your computer and use it in GitHub Desktop.
Save qodirovshohijahon/5c3ef3857572cb26544cdf5484353de8 to your computer and use it in GitHub Desktop.
export const myQuizList = async (
req: IRequest,
res: Response,
next: NextFunction
) => {
try {
const quizRepo = await quizRepository()
const user: any = req.sessionData?.user
console.log('-----------', req.sessionData)
if (!user) {
return new ApiResponse(res).error(404, 'USER_NOT_FOUND')
}
const data: Quiz = await quizRepo.paginate({
...req.query,
where: {
categoryId: req.query.categoryId,
deleted: false,
isPrivate: false,
author: user?.id,
},
relations: ['user', 'author'],
columns: ['title', 'author'],
})
if (!data) {
return new ApiResponse(res).error(404, 'QUIZES_NOT_FOUND')
}
new ApiResponse(res).success(data)
} catch (e) {
console.error(e)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment