MCPcopy Index your code
hub / github.com/callumalpass/tasknotes / handleNLPCreate

Method handleNLPCreate

src/api/SystemController.ts:97–131  ·  view source on GitHub ↗
(req: HTTPRequestLike, res: HTTPResponseLike)

Source from the content-addressed store, hash-verified

95
96 @Post("/api/nlp/create")
97 async handleNLPCreate(req: HTTPRequestLike, res: HTTPResponseLike): Promise<void> {
98 try {
99 const body = await this.parseRequestBody(req);
100
101 if (!body.text || typeof body.text !== "string") {
102 this.sendResponse(
103 res,
104 400,
105 this.errorResponse("Text field is required and must be a string")
106 );
107 return;
108 }
109
110 // Parse the natural language input
111 const parsedData = this.nlParser.parseInput(body.text);
112
113 const taskData = buildTaskCreationDataFromParsed(this.plugin, parsedData, {
114 creationContext: "api",
115 });
116
117 // Create the task - TaskService.createTask() applies defaults automatically
118 const result = await this.taskService.createTask(taskData);
119
120 this.sendResponse(
121 res,
122 201,
123 this.successResponse({
124 task: result.taskInfo,
125 parsed: parsedData,
126 })
127 );
128 } catch (error: unknown) {
129 this.sendResponse(res, 400, this.errorResponse(this.getErrorMessage(error)));
130 }
131 }
132
133 @Get("/api/docs")
134 async handleOpenAPISpec(req: HTTPRequestLike, res: HTTPResponseLike): Promise<void> {

Calls 7

sendResponseMethod · 0.80
errorResponseMethod · 0.80
successResponseMethod · 0.80
parseInputMethod · 0.65
createTaskMethod · 0.65
getErrorMessageMethod · 0.45

Tested by

no test coverage detected