Skip to content

Latest commit

 

History

History

README.md

Sapling Example

Prerequisites

All instructions are for MacOS / Homebrew, but feel free to use whichever installation methods you would prefer.

  1. Install just

    brew install just
  2. Install pnpm

    corepack enable pnpm # if you use corepack
    
    # or
    
    npm i -g pnpm # if you don't care for version management
  3. Install Postgres (Postgres.app is the easiest to use on MacOS)

    brew install --cask postgres-unofficial
  4. Install migrate

    brew install golang-migrate
    
    # or use the shell install (works on all platforms)
    curl -L https://github.com/golang-migrate/migrate/releases/download/$version/migrate.$os-$arch.tar.gz | tar xvz

Instructions

  1. Copy .env.example to .env and fill it out

  2. If you haven't yet, create the database then run:

    just migrate up
  3. Run the dev server:

    pnpm run dev

Tests

  • Get all todos

    curl -L 'localhost:3000/api/todo'
  • Get todo by ID

    curl -L 'localhost:3000/api/todo/1' # replace the 1 with the todo ID you would like to fetch
  • Create todo (invalid request body)

    curl -L 'localhost:3000/api/todo' \
    -H 'Content-Type: application/json' \
    -d '{}'
  • Create todo (valid request body)

    curl -L 'localhost:3000/api/todo' \
    -H 'Content-Type: application/json' \
    -d '{
        "name": "TodoNow",
        "description": "can be undefined"
    }'
  • Toggle todo

    curl -L -g -X POST 'localhost:3000/api/todo/1/toggle' # replace the 1 with the todo ID you would like to toggle