Dev Journal #3: API list links
June 8, 2023Let’s add an endpoint to get a list of all links that we’ve created. Start with adding a list
function to packages/core/src/link.ts
:
export async function list() {
const result = await LinkEntity.query.byUid({}).go();
return result.data;
}
Add the LinkList
lambda function to the API
stack in stacks/API.ts
as well:
const api = new Api(stack, "api", {
routes: {
"GET /links": {
function: {
functionName: nameFor("LinkList"),
handler: "packages/functions/src/link/list.handler",
},
// ...
}
}
And there we go! You can view this code in the Add link list commit.