Skip to content

Tweet-311-Denver/tweet_311_denver_service

Repository files navigation

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

  • React Native
  • Enzyme / Jest
  • Expo
  • React Navigation

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
  1. 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
  1. 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.
  1. Run the test suite with npm test
  2. 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": "[email protected]"
  },
  "location": {
    "lat": "39.751129",
    "long": "-104.997486"
  }
}

Body/payload attributes:

  • report object required with all attributes category, description, image, email
  • location object required with all attributes lat, long
  • category can only accept other or snow removal
  • description is a string with a limit of 280 characters
  • image is the image path from a device upload
  • email is a string
  • lat can include up to 8 decimal points
  • long can include up to 8 decimal points

Example response:

HTTP 1.1 Status 201 Created
body:
{
  "newReport": {
    "category": "other",
    "description": "A car is blocking the bike lane",
    "email": "[email protected]",
    "image": "path_to_image_in_app_cdn",
    "location_id": "1"
    "id": "1"
  },
  "confirmation311": {
    "caseID": "54389"
    "category": "Other"
    "submittedAs": "[email protected]"
    "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": "[email protected]",
            "location_id": 3
        },
        {
            "id": 4,
            "category": "other",
            "description": "oh noes there's stuff in the road",
            "image": null,
            "email": "[email protected]",
            "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.

About

Backend for Tweet311Denver Turing Project

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published