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/
- Tech Stack and Team
- Set Up
- API Endpoints
GET /
POST /api/v1/reports
GET /api/v1/reports
- Schema
- Workflow
- Node.js v12.14.1
- Hapi.js v19.1.1
- Knex v0.20.10
- PostgreSQL v11.5
- Puppeteer v2.1.1
- Testing Suite: @hapi/lab, @hapi/code, Sinon, Nock
Cameron MacRae and Garrett Iannuzzi
- React Native
- Enzyme / Jest
- Expo
- React Navigation
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)- If running locally, generate a
SERVICE_KEY
in the.env
file.
- If running locally, generate a
- 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.
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"
}
This reports endpoint executes the following tasks:
- Adds a location to the database
- Adds a report to the database
- Makes a 311 Report
- 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 attributescategory
,description
,image
,email
location
object required with all attributeslat
,long
category
can only acceptother
orsnow 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 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": ""
}
}
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
}
]
}
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.