( request: FastifyRequestTypebox<typeof GetPromptByIdSchema>, reply: FastifyReplyTypebox<typeof GetPromptByIdSchema>, )
| 51 | * @returns {Promise<void>} |
| 52 | */ |
| 53 | export const getPromptById = async ( |
| 54 | request: FastifyRequestTypebox<typeof GetPromptByIdSchema>, |
| 55 | reply: FastifyReplyTypebox<typeof GetPromptByIdSchema>, |
| 56 | ) => { |
| 57 | try { |
| 58 | // eslint-disable-next-line @typescript-eslint/ban-ts-comment |
| 59 | // @ts-ignore |
| 60 | const { id } = request.params; |
| 61 | const prompt = await request.server.orm.getRepository(Prompt).findOne({ where: { id: id, isDeleted: false } }); |
| 62 | if (!prompt) { |
| 63 | reply.code(404).send({ message: "Prompt not found" }); |
| 64 | } else { |
| 65 | const prompts = await request.server.orm |
| 66 | .getRepository(Prompt) |
| 67 | .find({ where: { parentPromptId: id, isDeleted: false } }); |
| 68 | reply.code(200).send(prompts); |
| 69 | } |
| 70 | } catch (e: any) { |
| 71 | Sentry.captureException(e); |
| 72 | reply.code(500).send(e); |
| 73 | } |
| 74 | }; |
| 75 | |
| 76 | /** |
| 77 | * Creates a new prompt in the database. |
nothing calls this directly
no outgoing calls
no test coverage detected