Dev Journal #2: API get links

Let’s add an endpoint to get links that we’ve created. Start with adding a get function to packages/core/src/link.ts:

export async function get(uid: string) {
  const result = await LinkEntity.get({ uid }).go();
  return result.data;
}

Add the LinkGet lambda function to the API stack in stacks/API.ts as well:

  const api = new Api(stack, "api", {
    routes: {
      "GET /link/{id}": {
        function: {
          functionName: `${stack.stackName}-LinkGet`,
          handler: "packages/functions/src/link/get.handler",
          bind: [table],
        },
      },
      // ...
    }
  }

You can view this code in the Add link get commit.