Git Product home page Git Product logo

sheltertech-go's Introduction

sheltertech-go

This repository contains the beginnings of a Golang implementation of https://github.com/ShelterTechSF/askdarcel-api/

Integrate with askdarcel-api and askdarcel-web stack

This repository requires running the docker-compose setup inside https://github.com/ShelterTechSF/askdarcel-api/blob/master/docker-compose.yml

The docker-compose in this repository links to the same docker network askdarcel and connects to the database defined at https://github.com/ShelterTechSF/askdarcel-api/blob/master/docker-compose.yml#L4

To start the server in the docker network connected to the existing askdarcel-web and askdarcel-api services

make run

To test, you just need to provide the v2 path param in front of any existing API route for Rails API.

curl -s localhost:8080/api/v2/categories | jq

Implementation

Currently supports

GET /api/categories
GET /api/categories/{id}
GET /api/categories/subcategories/{id}
GET /api/categories/featured

Compare against Rails API

You can make the same API calls against the Rails API on port 3000 and compare

curl -s localhost:3000/categories | jq 
curl -s localhost:3000/categories/150 | jq 
curl -s localhost:3000/categories/subcategories/150 | jq 
curl -s localhost:3000/categories/featured | jq 

sheltertech-go's People

Contributors

dependabot[bot] avatar katerina-kossler avatar lgarofalo avatar richardxia avatar waynekoepcke avatar wkoepcke avatar zen-gineer avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

sheltertech-go's Issues

GET /categories/hierarchy

Migrate GET /categories/hierarchy to GO
This endpoint queries the 'categories' table and where top_level=true, a nested query to the 'category-relationships' table finds child categories. The response body is an object with the "categories" prefix, followed by an array of empty slices for categories with no children, and sub-arrays of child objects if they exist, ordered (optionally) by rank.

'Folders' API in Go - Delete Folder for User

Acceptance: Route to delete a folder associated with the current user

Design notes: feature requirements

Notes:

  • folders cannot be nested
  • object model: schema.rb

Open Question:

  • do we want to remove all bookmarks in the folder, just move them to be associated with the user (no folder), or give the User the choice between the two?

Make sure that PUT endpoints update the updated_at field

Without an ORM like Rails' ActiveRecord, ensuring that the updated_at field is updated every time a row is modified is up to us. We are not consistently doing this, and we should at least make sure that all existing endpoints are updating the updated_at field.

'Folders' API in Go - Get Folders for User

Acceptance: Route to return all folders (with name and order for the current user)

Design notes: figma

Notes:

  • auth aware
  • object model: schema.rb
  • returned in increasing order number with name
  • endpoint does not need to list all bookmarks per folder

Folder API should return updated_at

The design mockups state that the dashboard should display the date/time at which a bookmark folder was most recently updated, but the API doesn't currently return the updated_at field, so there is no way for the frontend to display this information.

Clean up error handling in all endpoints

The error handling in the recently added Bookmarks, Folders, and Saved Search endpoints is fairly inconsistent. A few baseline things that we should do are:

  • Make sure that failures actually result in 4xx or 5xx status codes so that API clients are aware that an error occurred
  • Make sure client-side errors result in 4xx (usually 400) status codes
  • Make sure that server-side errors result in 5xx status codes

Complete Categories API Go Implementation

There is a mostly done implementation in the repo currently. We should do these things:

  1. Verify all routes and logic from those different HTTP method have been migrated over. Rout]

Route Definitions
Rails: https://github.com/ShelterTechSF/askdarcel-api/blob/master/config/routes.rb#L7-L13
Go: https://github.com/ShelterTechSF/sheltertech-go/blob/main/cmd/sheltertech-go/main.go#L30-L33

  1. Complete automated tests to cover all those changes

Couple examples here: https://github.com/ShelterTechSF/sheltertech-go/blob/main/cmd/sheltertech-go/integration_test.go

They do require having the DB from the Rails repo running, we may need to chat about that setup.

Work on Bookmarks API in Go

We don't have a technical specification, so part of this task is to also figure out which endpoints we need and how they should be implemented.

See https://docs.google.com/document/d/1XsgVEfRH9zn4XMQlhtqgfhaJAoL8TV8F6yNlLFa2MA4/edit#bookmark=id.qedtweia4g1e for the high level feature requirement, and https://www.figma.com/file/XUttHGa1csIpbSiurbYmjo/Case-Worker?type=design&node-id=7168-4476&mode=design&t=hcGEvgxPwD4YO79c-0 for the Figma Designs.

The main UI interactions are being able to create new bookmarks, create new folders, and reordering bookmarks within folders.

Enforce authorization checks for Bookmarks, Folders, and Saved Search APIs

The first pass at these endpoints are probably going to be merged without performing authorization checks. This ticket is meant to track the task of actually enforcing authorization checks for these endpoints, which we'll want before launch.

Specifically, for the MVP, we want to enforce that the authenticated user (via the JWT) matches the user in the actual database user_id foreign key column for each of these resources.

Post-MVP, we may want to loosen this if we want to enable a feature for users to share bookmarks, folders, or saved searches with each other, but we need a lot more discussion about how that should work in our app.

Disallow duplicate bookmarks?

There is nothing in the DB or API endpoint preventing a user from creating a duplicate bookmark, not even when present in the same folder. This probably isn't desirable, and we should probably disallow this.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.