CS3560-02-03-Fall-2024 / 3560-project

https://3560-project.vercel.app
0 stars 1 forks source link

add: Routes for assignments, callers, and dispatchPersonnel #16

Closed Inevitabby closed 1 week ago

Inevitabby commented 1 week ago

All endpoints support CRUD actions now, and follow the same organization.

  1. Do a GET request to api/<ENDPOINT> to list every entry.
  2. Do a POST request to api/<ENDPOINT> to create a new entry.
  3. Do a DELETE request to api/<ENDPOINT>/<ID> to delete a new entry.
  4. Do a PUT request to api/<ENDPOINT>/<ID> to update an existing entry.

Also, fixed the dynamic routing for incidents (first made in PR #14)

TODO: Validate inputs to ensure they follow specifications.

Some Example Calls

Example I: Listing Entries:

$ curl -X GET http://localhost:3000/api/callers
[
  {
    "caller_ID": 1,
    "first_name": "Billy",
    "last_name": "Joe",
    "address": "3801 W Temple Ave, Pomona, CA 91768",
    "phone_number": "1234567890"
  }
]

$ curl -X GET http://localhost:3000/api/assignments
[
  {
    "assignment_ID": 1,
    "incident_ID": 1,
    "unit_number": 101,
    "unit_type": "Police",
    "backup_needed": 0,
    "status": "Completed"
  }
]

$ curl -X GET http://localhost:3000/api/dispatchPersonnel
[
  {
    "personnel_ID": 1,
    "first_name": "Joe",
    "last_name": "Smith"
  }
]

$ curl -X GET http://localhost:3000/api/incidents
[
  {
    "incident_ID": 1,
    "caller_ID": 1,
    "personnel_ID": 1,
    "address": "123 Oak Blvd, Irvine",
    "priority": "Medium",
    "status": "In Progress",
    "description": "Large fire...",
    "created_at": "2024-11-13T22:30:00.000Z"
  }
]

Example II: Creation

$ curl -X GET http://localhost:3000/api/incidents
[
  {
    "incident_ID": 1,
    "caller_ID": 1,
    "personnel_ID": 1,
    "address": "123 Oak Blvd, Irvine",
    "priority": "Medium",
    "status": "In Progress",
    "description": "Large fire...",
    "created_at": "2024-11-13T22:30:00.000Z"
  }
]

$ curl -X POST http://localhost:3000/api/incidents \
  -H "Content-Type: application/json" \
  -d '{
        "caller_ID": 1,
        "personnel_ID": 1,
        "address": "456 Elm St, Springfield, IL",
        "priority": "Low",
        "description": "Parking violation"
      }'
{
  "message": "Incident created",
  "id": 5
}

$ curl -X GET http://localhost:3000/api/incidents
[
  {
    "incident_ID": 1,
    "caller_ID": 1,
    "personnel_ID": 1,
    "address": "123 Oak Blvd, Irvine",
    "priority": "Medium",
    "status": "In Progress",
    "description": "Large fire...",
    "created_at": "2024-11-13T22:30:00.000Z"
  },
  {
    "incident_ID": 2,
    "caller_ID": 1,
    "personnel_ID": 1,
    "address": "456 Elm St, Springfield, IL",
    "priority": "Low",
    "status": "Pending",
    "description": "Parking violation",
    "created_at": "2024-11-21T04:35:43.000Z"
  }
]
hastiabbasi commented 1 week ago

Great work + documentation!