Skip to content

Commit

Permalink
Set status codes for VC Repo API, fix a credential template
Browse files Browse the repository at this point in the history
  • Loading branch information
waltkb committed Feb 13, 2024
1 parent dad1a95 commit 283a487
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
4 changes: 2 additions & 2 deletions src/content/1.credentials/HotelReservation.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Hotel Reservation
# HotelReservation

```json
{
Expand Down Expand Up @@ -48,4 +48,4 @@
},
"issuanceDate": "<timestamp>"
}
```
```
7 changes: 6 additions & 1 deletion src/server/api/mapping/[name].get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { serverQueryContent } from "#content/server";

export default defineEventHandler(async (event) => {
const name = getRouterParam(event, "name");
if (name === undefined) return "No name set!";
if (name === undefined) {
setResponseStatus(event, 400);
return "error: No name set!";
}

const contentQuery = await serverQueryContent(event).find();

Expand All @@ -19,6 +22,7 @@ export default defineEventHandler(async (event) => {
return content.title;
});

setResponseStatus(event, 400);
return `error: No credential found named: \"${name}\". Available credentials: ${n.join(", ")}`;
}

Expand Down Expand Up @@ -48,5 +52,6 @@ export default defineEventHandler(async (event) => {
}
}

setResponseStatus(event, 400);
return "error: no-mapping";
});
6 changes: 5 additions & 1 deletion src/server/api/vc/[name].get.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@ import { serverQueryContent } from "#content/server";

export default defineEventHandler(async (event) => {
const name = getRouterParam(event, "name");
if (name === undefined) return "error: No name set!";
if (name === undefined) {
setResponseStatus(event, 400);
return "error: No name set!";
}

const contentQuery = await serverQueryContent(event).find();

Expand All @@ -19,6 +22,7 @@ export default defineEventHandler(async (event) => {
return content.title;
});

setResponseStatus(event, 400);
return `error: No credential found named: \"${name}\". Available credentials: ${n.join(", ")}`;
}

Expand Down

0 comments on commit 283a487

Please sign in to comment.