Skip to content

Commit

Permalink
Update main.ts
Browse files Browse the repository at this point in the history
  • Loading branch information
EthanThatOneKid committed Apr 6, 2024
1 parent e96c41c commit a8f9194
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cli/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,21 +63,21 @@ if (import.meta.main) {
// TODO: Use rtx to define the routes. Use htx to define the HTML index page.
.post("/api", async (ctx) => {
if (!isAuthorized(ctx.request.headers)) {
return new Response("Unauthorized", { status: 401 });
return Response.json({ error: "Unauthorized" }, { status: 401 });
}

const body = await ctx.request.json();
await goService.add(body.alias, body.destination, body.force);
return new Response("Shortlink added.", { status: 201 });
return Response.json({ message: "Shortlink created." }, { status: 201 });
})
.delete("/api", async (ctx) => {
if (!isAuthorized(ctx.request.headers)) {
return new Response("Unauthorized", { status: 401 });
return Response.json({ error: "Unauthorized" }, { status: 401 });
}

const body = await ctx.request.json();
await goService.delete(body.alias);
return new Response("Shortlink removed.", { status: 200 });
return Response.json({ message: "Shortlink deleted." });
})
.get("/:path*", async (ctx) => {
const collection = await goService.collection();
Expand Down

0 comments on commit a8f9194

Please sign in to comment.