This is a Next.js project bootstrapped with create-next-app.
First, run the development server:
npm run dev
# or
yarn dev-
We decided to go with NextJS so we could have our backend coupled with our front-end to be easily deployed to Vercel on the edge. Our original plan for database was to host a postgres database on planetscale but due to some issues with connectivity we have used sqlite, although the infastructure to migrate to planetscale is just a minute away thanks to Prisma. On that point we went with Prisma to talk to our database and make querying a bit easier.
-
Finally we use Google Maps Platform to show users current location and to setup markers at set postions, issues or hazards etc... We didn't exactly manage to get our Authentication for user sign in setup in time although the endpoints are already done shown below.
- GET: api/report/[id]
- GET: api/user/[id]
- POST: api/report/create-report
- POST: api/user/create-user
- DELETE: api/report/[id]
- DELETE: api/user/[id]
- GET: api/user/users
- GET: api/report/reports
Open http://localhost:3000 with your browser to see the result.
You can start editing the page by modifying pages/index.js. The page auto-updates as you edit the file.
CityFi base url: https://grammerhub.vercel.app/
- all endpoints are public access, no restrictions
get all users
-
return JSON format:
{ "users": [ { "id": 3, "name": "guest", "email": "guest@cityfi.gov", "role": "guest" }, { "id": 15, "name": "user1", "email": "user1@cityfi.gov", "role": "user" } ] }
get all reports
- return JSON format:
{
"reports": [
{
"id": 6,
"authorId": 3,
"createdAt": "2022-10-09T09:03:36.975Z",
"updatedAt": "2022-10-09T09:03:36.975Z",
"status": "pending",
"latitude": 26.3749876,
"longitude": -80.103252,
"category": "residential",
"subCategory": "",
"description": "coconuts everywhere!"
},
{
"id": 7,
"authorId": 15,
"createdAt": "2022-10-09T09:56:21.759Z",
"updatedAt": "2022-10-09T09:56:21.759Z",
"status": "pending",
"latitude": 26.3749876,
"longitude": -80.103252,
"category": "hazards",
"subCategory": "park & rec",
"description": "trash bins are full everywhere"
}
]
}get report by id
-
return JSON format:
{ "id": 6, "authorId": 3, "createdAt": "2022-10-09T09:03:36.975Z", "updatedAt": "2022-10-09T09:03:36.975Z", "status": "pending", "latitude": 26.3749876, "longitude": -80.103252, "category": "residential", "subCategory": "", "description": "coconuts everywhere!" }
get user by id
- return JSON format:
{
"id": 3,
"name": "guest",
"email": "guest@cityfi.gov",
"role": "guest"
}create a new report
- return JSON format:
{
"newReport": {
"id": 8,
"authorId": 15,
"createdAt": "2022-10-09T11:01:52.525Z",
"updatedAt": "2022-10-09T11:01:52.525Z",
"status": "pending",
"latitude": 26.3749876,
"longitude": -80.103252,
"category": "hazards",
"subCategory": "park & rec",
"description": "new reporting for the city"
},
"message": "Report# 8 was successfully created!"
}create a new user
- return JSON format:
{
"newUser": {
"id": 19,
"name": "user2",
"email": "user2@cityfi.gov",
"role": "user"
},
"message": "user user2 was successfully created!"
}delete report by id
- return message:
"report id #7 has been successfully deleted"delete user by id
- return JSON format:
{
"deleteUser": {
"id": 19,
"name": "user2",
"email": "user2@cityfi.gov",
"role": "user"
},
"message": "user user2 has been successfully deleted"
}update report by id
- return JSON format