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/
GET /
POST /api/v1/reports
GET /api/v1/reports
Cameron MacRae and Garrett Iannuzzi
git clone
this repository and move into the directory
Run npm install
to install dependencies
Set up development and test databases with postgres
psql -U postgres
CREATE DATABASE tweet_311_service_dev;
CREATE DATABASE tweet_311_service_test;
exit
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
Create a .env
file and add environment variables:
GOOGLE_GEOCODE_KEY
= API key for Google Geocoding APISERVICE_KEY
= API key for this service (contact contributors for access)SERVICE_KEY
in the .env
file. Run the test suite with npm test
Deploy locally to port 3000 with npm start
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:
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:
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 charactersimage
is the image path from a device uploademail
is a stringlat
can include up to 8 decimal pointslong
can include up to 8 decimal pointsExample 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
}
]
}
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.