diff options
Diffstat (limited to 'source')
| -rw-r--r-- | source/index.js | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/source/index.js b/source/index.js index 616c237..9d4a9e2 100644 --- a/source/index.js +++ b/source/index.js @@ -5,7 +5,7 @@ export default { switch (url.pathname) { // return a simple hello world message case "/": - return Response.json({ + return Respond({ message: "Hello, World! :3", }); @@ -33,19 +33,28 @@ export default { ]; if (acceptedServices.includes(service)) - return Response.json({ + return Respond({ status: "ok", }); - return Response.json({ + return Respond({ error: `service not found`, }); // default case default: - return Response.json({ + return Respond({ error: "not found", }); } }, }; + +function Respond(body) { + return new Response(JSON.stringify(body), { + headers: { + "Access-Control-Allow-Origin": "*", + "Content-Type": "application/json", + }, + }); +} |
