MCPcopy Create free account
hub / github.com/awslabs/llrt / apiResponse

Function apiResponse

example/functions/src/ssr.ts:58–89  ·  view source on GitHub ↗
(
  pathParams: string[],
  method: Method,
  body?: string
)

Source from the content-addressed store, hash-verified

56});
57
58const apiResponse = async (
59 pathParams: string[],
60 method: Method,
61 body?: string
62) => {
63 const [id] = pathParams;
64 if (id) {
65 if (method === "DELETE") {
66 await API.delete(id);
67 return response("", {
68 contentType: "application/json",
69 });
70 }
71 if (method === "PUT") {
72 const { text, completedDate } = JSON.parse(body);
73 const item = await API.update({ id, text, completedDate });
74 return response(JSON.stringify(item), {
75 contentType: "application/json",
76 });
77 }
78 }
79
80 if (pathParams.length == 0 && method === "POST") {
81 const { text } = JSON.parse(body);
82 const item = await API.create(text);
83 return response(JSON.stringify(item), {
84 contentType: "application/json",
85 });
86 }
87
88 throw new HttpError(404, "Not found");
89};
90
91const appResponse = async () => {
92 let todoItems;

Callers 1

handlerFunction · 0.85

Calls 5

responseFunction · 0.85
createMethod · 0.80
parseMethod · 0.65
deleteMethod · 0.45
updateMethod · 0.45

Tested by

no test coverage detected