Skip to content

veg-share/backend-api

Repository files navigation

Contributors Forks Stargazers Issues

CircleCI

Garden Party Backend API

Table of Contents
  1. About The Project
  2. Getting Started
  3. GraphQL Endpoint
  4. ReST Endpoints
  5. Contact

About The Project

Garden Party is a social application that allows home gardeners to share their surplus harvest with their communities. A user is able to create a post with images and edit their profile. It is composed of a backend application built using Ruby on Rails and GraphQL and a frontend React application.

The bulk of this project was designed and built by a team of five engineers in under two weeks while attending Turing School of Software and Design. This backend API uses CircleCI for continuous integration and is hosted on Heroku. The frontend repository can be found here.

This project features:

  • Exposing a GraphQL endpoint
  • Exposing RESTful endpoints for uploading images
  • Active Storage
  • Amazon Web Services S3 Buckets
  • Testing API exposure with RSpec and Postman
  • Composing advanced ActiveRecord queries to analyze information stored in PostgreSQL database
  • Write SQL statements without the assistance of an ORM
  • Implement json:api standards
  • Add custom error responses for invalid API requests

Built With

Getting Started

  1. Clone this repo

  2. Install gem packages: bundle

  3. Setup the database. A pgdump is included in ./db to seed the database

    rails db:{create,migrate,seed}

  4. Run the RSpec test suite: bundle exec rspec

  5. Start your local server: rails s

Prerequisites

  • Ruby 2.5.3
  • Rails 5.2.4

GraphQL Endpoint

POST http://localhost:3000/graphql

The following is documentation for the exposed GraphQL schema.

Users:

User Type Fields: id, username, passwordDigest, city, zipCode, state, posts, createdAt, updatedAt

User Queries:

getAllUsers: returns all users

getOneUser: returns one user from an id
Arguments:
id (required)

User Mutations:

updateUser: updates a user’s info specified by id
Arguments:
id (required),
username, city, state, zipCode (optional)

createUser: creates a user with specified information
Arguments:
Username, city, state, zipCode, password, passwordConfirmation (required)
deleteUser: deletes the specified user

Arguments:
id (required)

Posts:

Post Type Fields: id, userId, tags, title, description, createdAt, updatedAt

Post Queries:

getAllPosts: returns all posts

getOnePost: returns one post from an id
Arguments:
id (required)

Post Mutations:

updatePost: updates a post’s info specified by id
Arguments:
id (required),
title, description (optional)

createPost: creates a post with specified information
Arguments:
userId, tags, title, description (required)

deletePost: deletes the specified post
Arguments:
id (required)

REST Endpoints

All image upload functionality is handled through RESTful endpoints.

Upload User Avatar

Required parameters: user id and an image file.

PUT http://localhost:3000/api/v1/users/:id

Below is an example of the response body format for a successful upload:

{
    "success": {
        "message": "Avatar updated"
    }
}

Unsuccessful response:

{
    "error": {
        "message": "Avatar not updated"
    }
}

Upload a Post's Image

Required parameters: post id and an image file.

PUT http://localhost:3000/api/v1/posts/:id

Below is an example of the response body format for a successful upload:

{
    "success": {
        "message": "Image updated"
    }
}

Unsuccessful response:

{
    "error": {
        "message": "Avatar not updated"
    }
}

Contact

Grayson Myers - LinkedIn

Aiden Mendez — LinkedIn

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •