Dev Journal #3: API list links

Let’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();

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.