( request: FastifyRequestTypebox<typeof UpdatePromptSchema>, reply: FastifyReplyTypebox<typeof UpdatePromptSchema>, )
| 99 | * @returns {Promise<void>} |
| 100 | */ |
| 101 | export const updatePrompt = async ( |
| 102 | request: FastifyRequestTypebox<typeof UpdatePromptSchema>, |
| 103 | reply: FastifyReplyTypebox<typeof UpdatePromptSchema>, |
| 104 | ) => { |
| 105 | try { |
| 106 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
| 107 | // @ts-ignore |
| 108 | const { id } = request.params; |
| 109 | const prompt = await request.server.orm.getRepository(Prompt).findOne({ where: { id: id } }); |
| 110 | console.log(prompt); |
| 111 | if (!prompt) { |
| 112 | reply.code(404).send({ message: "Prompt not found" }); |
| 113 | } |
| 114 | await request.server.orm.getRepository(Prompt).update(id, request.body); |
| 115 | const res = await request.server.orm.getRepository(Prompt).findOne({ where: { id: id } }); |
| 116 | if (!res) { |
| 117 | reply.code(404).send({ message: "Prompt not found" }); |
| 118 | } else { |
| 119 | reply.code(200).send(res); |
| 120 | } |
| 121 | } catch (e: any) { |
| 122 | Sentry.captureException(e); |
| 123 | reply.code(500).send(e); |
| 124 | } |
| 125 | }; |
| 126 | |
| 127 | /** |
| 128 | * Deletes a prompt from the database by its ID. |
nothing calls this directly
no outgoing calls
no test coverage detected