( request: FastifyRequestTypebox<typeof GetModelByIdSchema>, reply: FastifyReplyTypebox<typeof GetModelByIdSchema>, )
| 43 | * @returns {Promise<void>} - A Promise that resolves when the operation is complete. |
| 44 | */ |
| 45 | export const getModelById = async ( |
| 46 | request: FastifyRequestTypebox<typeof GetModelByIdSchema>, |
| 47 | reply: FastifyReplyTypebox<typeof GetModelByIdSchema>, |
| 48 | ) => { |
| 49 | try { |
| 50 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
| 51 | // @ts-ignore |
| 52 | const { id } = request.params; |
| 53 | const response = await request.server.orm.getRepository(Model).findOne({ where: { id: id } }); |
| 54 | if (!response) { |
| 55 | reply.code(404).send({ message: ERROR_MESSAGES.MODEL_NOT_FOUND }); |
| 56 | } |
| 57 | if (response) reply.code(200).send(response); |
| 58 | } catch (e: any) { |
| 59 | Sentry.captureException(e); |
| 60 | reply.code(500).send(e); |
| 61 | } |
| 62 | }; |
nothing calls this directly
no outgoing calls
no test coverage detected