Skip to content

EPIC: Basic REST API #256

@nelsonic

Description

@nelsonic

As discussed in: dwyl/app#273 having a REST and WebSocket API is a Top Priority for us. 🔝
We want anyone to be able to securely query their data using the API and an AUTH_API_KEY or JWT; this is our API Roadmap. For now we just need something super basic so that we can get moving on the Flutter MVP: dwyl/product-roadmap#40

Todo

We are breaking down this EPIC into 3 stages, an attempt chunk the work
so that we can ship each stage as fast as possible.
We expect there to be 3 separate Pull Requests; one for each stage.

Rather than extending the already very long BUILDIT.md file,
which is 75 pages at the latest viewing:

buildit-log-is-75-pages

We will instead:

  • Create a new file: API.md in the root of the project where we write-up the details of the `API

Stage 1: No Auth 📖

  • Create an unauthenticated API endpoint [:authOptional] in the MVP App
    that enables the basic CRUD operations for items and timers:
  • POST to create an item anonymously, /api/items/new
    should only accept the text data and return an item.id, e.g: 200 '{"id":42}'
  • PATCH to Edit/Update an item.text: `/api/items/:id/update
  • GET to READ the contents of the item, e.g: /api/items/:id

You'll notice that we are not doing tags in the first stage; this is deliberate because there's quite a lot going on in the tags and we want to get the first

!important

The purpose of this first stage is to ensure we have a good foundation for testing the API.
That means having automated:

Stage 2: Tags 🏷️

Creating tags and associating them to items is a bit more involved because it can require multiple API requests if we follow traditional REST conventions. We should definitely do that for completeness. But for UX we should also allow people to create an item and specify the tags in a single API request. 💭

  • Create the /api/tags resource with:
  • POST for /api/tags/new
  • GET for /api/tags/:id and
  • PATCH for /api/tags/:id/update

Next:

  • Retrofit the POST /api/items/new and PATCH /api/items/:id/update endpoints to allow sending the tags on item creation and update.
    e.g: {"text": "my awesome update", "tags": "awesome, priority-1"} This will add some complexity so make sure you break it down into tiny + testable functions.
  • Modify the GET /api/items/:id to return the tags with the item e.g: {"text": "Learn elixir", "tags": "learn"}

This is definitely a denormalisation and potentially "frowned upon" by some REST purists. But we don't care. We only care about UX. If the person using the API can make fewer requests and get their data faster, we are happy. 😊

Stage 3: With Authentication! 🔐

Once the Basic REST API is working [deployed!] we will allow people to view a JWT within the App which they can use to make authenticated API Requests. There are a few extra steps to enable this so as soon as the previous 2 stages are complete (PRs merged & deployed) we will re-visit and expand on this stage. 👌

Note: What we will eventually do is have an api.dwyl.com similar to how GitHub does it: https://docs.github.com/en/rest/overview/resources-in-the-rest-api so the API will run on a completely different server/service

@LuchoTurtle please take a look at this and LMK if it's clear enough for you to start work on it today. 🙏

Metadata

Metadata

Assignees

Labels

T1dTime Estimate 1 DaydiscussShare your constructive thoughts on how to make progress with this issueenhancementNew feature or enhancement of existing functionalityepicA feature idea that is large enough to require a sprint (5 days) or more and has smaller sub-issues.help wantedIf you can help make progress with this issue, please comment!priority-1Highest priority issue. This is costing us money every minute that passes.technicalA technical issue that requires understanding of the code, infrastructure or dependencies

Type

No type

Projects

Status

🏗 In progress

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions