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

Function getPromptById

src/controllers/prompt.controller.ts:53–74  ·  view source on GitHub ↗
(
  request: FastifyRequestTypebox<typeof GetPromptByIdSchema>,
  reply: FastifyReplyTypebox<typeof GetPromptByIdSchema>,
)

Source from the content-addressed store, hash-verified

51 * @returns {Promise<void>}
52 */
53export 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.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected