MCPcopy Create free account
hub / github.com/Writesonic/GPTRouter / getModelById

Function getModelById

src/controllers/model.controller.ts:45–62  ·  view source on GitHub ↗
(
  request: FastifyRequestTypebox<typeof GetModelByIdSchema>,
  reply: FastifyReplyTypebox<typeof GetModelByIdSchema>,
)

Source from the content-addressed store, hash-verified

43 * @returns {Promise<void>} - A Promise that resolves when the operation is complete.
44 */
45export 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};

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected