( request: FastifyRequestTypebox<typeof GetAllModelsSchema>, reply: FastifyReplyTypebox<typeof GetAllModelsSchema>, )
| 12 | * @returns {Promise<void>} - A Promise that resolves when the operation is complete. |
| 13 | */ |
| 14 | export const getAllModels = async ( |
| 15 | request: FastifyRequestTypebox<typeof GetAllModelsSchema>, |
| 16 | reply: FastifyReplyTypebox<typeof GetAllModelsSchema>, |
| 17 | ) => { |
| 18 | try { |
| 19 | const data = await request.server.orm |
| 20 | .getRepository(Model) |
| 21 | .find({ relations: ["provider"], order: { order: "ASC" } }); |
| 22 | const res = data.map(model => ({ |
| 23 | id: model.id, |
| 24 | name: model.name, |
| 25 | providerId: model.providerId, |
| 26 | providerName: model.provider.name, |
| 27 | createdAt: model.createdAt, |
| 28 | updatedAt: model.updatedAt, |
| 29 | inputType: model.inputType, |
| 30 | order: model.order, |
| 31 | })); |
| 32 | reply.code(200).send(res); |
| 33 | } catch (e: any) { |
| 34 | Sentry.captureException(e); |
| 35 | reply.code(500).send(e); |
| 36 | } |
| 37 | }; |
| 38 | |
| 39 | /** |
| 40 | * Get a model by its ID from the database. |
nothing calls this directly
no outgoing calls
no test coverage detected