Tweet-311-Denver / tweet_311_denver_service

Backend for Tweet311Denver Turing Project
MIT License
1 stars 0 forks source link

Tweet311Denver Service

This api for Tweet311Denver app uses Puppeteer to automate making Denver 311 Reports, fetches verified location information from the Google Geocoding API, and returns confirmation of 311 reports made to the City of Denver through the Tweet311Denver app.

This api is deployed on Heroku at https://tweet311denver-service.herokuapp.com/

Table of Contents

Tech Stack

Back End

Alice Post and Dustin Mikusko

Front End

Cameron MacRae and Garrett Iannuzzi

Set Up

  1. git clone this repository and move into the directory

  2. Run npm install to install dependencies

  3. Set up development and test databases with postgres

    psql -U postgres
    CREATE DATABASE tweet_311_service_dev;
    CREATE DATABASE tweet_311_service_test;
    exit
  4. Run knex migrations and seeds for both dev and test in the terminal

    knex migrate:latest; knex migrate:latest --env test
    knex seed:run; knex seed:run --env test
  5. Create a .env file and add environment variables:

    • GOOGLE_GEOCODE_KEY= API key for Google Geocoding API
    • SERVICE_KEY= API key for this service (contact contributors for access)
    • If running locally, generate a SERVICE_KEY in the .env file.
  6. Run the test suite with npm test

  7. Deploy locally to port 3000 with npm start

API Endpoints

Endpoints are hosted at https://tweet311denver-service.herokuapp.com. Append the following routes to the url to access the api.

All POST endpoints require query param serviceKey to equal your secret SERVICE_KEY.

GET /

This root endpoint allows developers to quickly check deployment of this api without a body or service key.

Example request: GET https://tweet311denver-service.herokuapp.com/

Example response:

HTTP 1.1 Status 200
body:
{
  "message": "Welcome to Tweet311Denver Service",
  "documentation": "https://github.com/Tweet-311-Denver/tweet_311_denver_service"
}

POST /api/v1/reports

This reports endpoint executes the following tasks:

  1. Adds a location to the database
  2. Adds a report to the database
  3. Makes a 311 Report
  4. Returns the confirmation information of the report as json

Example request:

POST /api/v1/reports?serviceKey=[SERVICE_KEY]
body:
{ "report": {
    "category": "other",
    "description": "A car is blocking the bike lane",
    "image": "//path_to_image_from_device.jpg",
    "email": "test@test.com"
  },
  "location": {
    "lat": "39.751129",
    "long": "-104.997486"
  }
}

Body/payload attributes:

Example response:

HTTP 1.1 Status 201 Created
body:
{
  "newReport": {
    "category": "other",
    "description": "A car is blocking the bike lane",
    "email": "test@test.com",
    "image": "path_to_image_in_app_cdn",
    "location_id": "1"
    "id": "1"
  },
  "confirmation311": {
    "caseID": "54389"
    "category": "Other"
    "submittedAs": "test@test.com"
    "submittedAt": "202002181810"
    "notes": ""
  }
}

GET /api/v1/reports

This endpoint returns all the reports in the Tweet311Denver Service database.

Example request: GET /api/v1/reports

Example response:

{
    "reports": [
        {
            "id": 3,
            "category": "other",
            "description": "big hole",
            "image": null,
            "email": "test@test.com",
            "location_id": 3
        },
        {
            "id": 4,
            "category": "other",
            "description": "oh noes there's stuff in the road",
            "image": null,
            "email": "test2@test.com",
            "location_id": 3
        }
    ]
}

Schema

schema_tweet311denver_service

Project Board

The team at Tweet311Denver followed an agile workflow with mini-sprints over the course of two weeks. Our team used a GitHub projects board with issues that were tracked by every member of the team.

Tweet311Denver encouraged code review processes by following a pull request template. It was encouraged that pull requests contain sections for what was happening, where to start, linked issues, testing, and any relevant notes.

Check out our project board here.