#INCIDENT AID SERVER ##RESTFUL API INTERFACE
###GENERAL
- The server is hosted on Digital Ocean
- https://cloud.digitalocean.com/droplets/2289696
- host address: 104:131:135:109:3000
###SERVER LOGIN
ssh root@104.131.135.109
- password: DIGI...
- check if the node process is already running
ps -a
(check for a node process)- whatsapp the team and ask if someone is using it
kill -9 <pid>
(process id)
node server.js
===> IAS server is running on port 3000
###MONGO HQ LOGIN
- url: www.mongohq.com
- login: cecile.peraire@sv.cmu.edu
- password: MONG...
- database name: fire logs
###SCHEMA TRANSLATION
{
user_n: 'Joe123', (String)
r: 1, (Number: 1-commander, 2-responder)
tp: 1, (Number: 1-REQ, 2-ACK, 3-COP)
m: 1, (Number: 1-Vacate, 2-Mayday, 3-Par, 4-RescueInProg,
5-UtilitiesOff, 6-UtilitiesOn, 7-VertVent,
8-CrossVent, 9-AllClear, 10-LifeHaz)
lt: 40.00001, (Number)
lg: -70.00001, (Number)
tk: '0x1234', (Number)
ts: '1405669256973' (String)
}
- job_role =
['firefighter', 'commander']
- contact =
'+16503530259'
- IAS server auto-generates
ts
, no need toPOST
- IAS server returns empty objects
{}
if there is nothing that matches the query. - All non return type endpoints return
200
on success - All endpoints return
400
on failure
###SCHEMAS
####User
{
user_n: String,
password: String,
job_role: String,
r: Number,
contact: String,
engine_name: String
}
####Event
{
user_n: String,
r: Number,
tp: Number,
m: Number,
lt: Number,
lg: Number,
tk: String,
ts: String
}
####Incident
{
incident_name: String,
commander: String,
firefighters: [String],
lt: Number,
lg: Number,
street: String,
city: String,
state: String,
zip: String,
start_time: String,
end_time: String,
ts: String
}
####Engine
{
engine_name: String,
hotspot_name: String
}
####Image
{
incident_id: mongoose.Types.ObjectId() //hidden
contentType: String, ('jpeg')
data: Buffer
}
###COMMANDER DASHBOARD
/
GET
###SMS-TWILIO
- /twilio_send_sms POST expects
{
user_n: String,
r: Number,
tp: Number,
m: Number,
lt: Number,
lg: Number,
tk: String
}
-
/twilio_receive_sms (Invisible to the user, handled by the server)
-
If the job role is a commander, the message will be sent to the firefighters in that particular incident.
-
If the incident role is a firefighter, the message will be sent to the commander in that particular incident.
###CREATE
- /create_user
POST
TESTED expects
{
user_n: String,
password: String
}
- /create_event
POST
TESTED expects
{
user_n: String,
r: Number,
tp: Number,
m: Number,
lt: Number,
lg: Number,
tk: String,
ts: String
}
- /create_incident
POST
TESTED expects
{
incident_name: 'greer',
commander: 'jason',
firefighters: ['rahul', 'yaz', 'gerard'],
street: 'Maiden Lane',
city: 'San Francisco',
state: 'CA',
zip: '94303',
start_time: '10',
end_time: 'empty',
lt: 0,
lg: 0,
ts: '140566925697'
}
- /create_engine
POST
TESTED expects
{
engine_name: 'clifford',
hotspot: 'truck #4'
}
###READ
-
/get_all_users
GET
TESTED- Returns
[{user}, {user}, {user}, ...]
- user object => refert to User schema ^
- Returns
-
/get_all_events
GET
TESTED- Returns
[{event}, {event}, {event}, ...]
- event object ==> refer to Event schema ^
- Returns
-
/get_all_incidents
GET
TESTED- Returns
[{incident}, {incident}, {incident}, ...]
- incident object ==> refer to Incident schema ^
- Returns
-
/get_all_engines
GET
TESTED- Returns
[{engine}, {engine}, ...]
- engine object ==> refer to Engine schema ^
- Returns
-
/get_user_by_user_name
POST
TESTED- Expects
{user_n: 'john'}
- Returns
{user}
- user object ==> refer to User schema ^
- Expects
-
/get_users_by_job_role
POST
TESTED- Expects
{job_role: 'firefighter'} or
{job_role: 'commander'}` - Returns
[{user}, {user}, {user}, ...]
- user object ==> refer to User schema ^
- Expects
-
/get_users_by_engine_name
POST
TESTED- Expects
{engine_name: 'F1'}
- Returns
[{user}, {user}, ...]
- user object ==> refer to User schema ^
- Expects
-
/get_users_by_incident_name
POST
TESTED- Expects
{incident_name: <incident_name>}
- Returns
[{user}, {user}, {user}, ...]
- user object ==> refer to User schema ^
- Expects
-
/get_events_by_incident_name
POST
TESTED- Expects
{incident_name: <incident_name>}
- Returns
[{event}, {event}, {event}, ...]
- event object ==> refer to Event schema ^
- Expects
-
**/get_events_by_current_incident_and_user_name
POST
-
Expects
{user_n: 'rahul'}
-
Returns
[{event}, {event}, {event}, ...]
-
event object ==> refer to Event schema ^
-
/get_events_by_user_name
POST
TESTED -
Expects
{user_n: 'rahul'}
-
Returns
[{event}, {event}, {event}, ...]
-
event object ==> refer to Event schema ^
-
/get_incident_by_incident_name
POST
TESTED -
Expects
{incident_name: <incident_name>}
-
Returns
{incident}
-
incident object ==> refer to Incident schema ^
-
/get_current_incident_by_user_name
POST
TESTED -
Expects
{user_n: <user_name>}
-
Returns the the most recent
{incident}
-
incident object ==> refer to Incident schema ^
-
/get_incidents_by_user_name
POST
TESTED -
Expects
{user_n:'rahul'}
-
Returns
[{incident}, {incident}, ... ]
-
incident object ==> refer to Incident schema ^
-
/get_engine_by_engine_name TESTED
-
Expects
{engine_name: 'F1'}
-
Returns
{engine}
-
engine object ==> refer to Engine schema ^
###COP
-
/get_current_cop_image NOT TESTED
- returns (jpeg file)
-
/post_cop_image_by_current_incident NOT TESTED
- Expects
{file_name: String, data: Buffer}
- Returns success or fail
- Expects
###DELETE
-
/delete_user_by_user_name
POST
TESTED- Expects
{user_n: 'rahul'}
- Returns
200
on success,400
on failure
- Expects
-
/delete_events_by_incident_name
POST
TESTED- Expects
{incident_name: 'fire_1'}
- Returns
200
on success,400
on failure
- Expects
-
/delete_incident_by_incident_name
POST
TESTED- Expects
{incident_name: 'homer'}
- Returns
200
on success,400
on failure
- Expects
-
/delete_engine_by_engine_name
POST
TESTED- Expects
{engine_name: 'F2'}
- Returns
200
on success,400
on failure
- Expects
###UPDATE
-
/update_user_by_user_name
POST
TESTED- Does not update user_name
- Replaces the fields that are passed and leaves the fields that already exist in the database untouched
- Expects
{user_n: 'john', contact: '+16503530259', ...}
- Returns
200
on success,400
on failure
-
/update_incident_by_incident_name
POST
TESTED- Does not update incident_name.
- Replaces the fields that are passed and leaves the fields that already exist in the database untouched.
- Expects
{incident_name: 'homer', end_time: '13:30', 'lg': 34, 'lt': 23, ..}
- Returns
200
on success,400
on failure.
-
/update_incident_commander
POST
TESTED- Moves the old commander into the firefighters array.
- Replaces the old commander with the commander passed.
- Expects
{incident_name: 'fire 3', user_n: 'rahul'}
- Returns
200
on success,400
on failure.
-
/update_engine_by_engine_name
POST
TESTED- Replaces the fields that are passed and leaves the fields that already exist in the database untouched.
- Expects
{engine_name: 'clifford', hotspot_name: 'truck #4'}
###AUTHENTICATE
- /authenticate_user
POST
TESTED- expects
{user_n: 'rahul', password: 'pwd123', engine_name: 'clifford', contact: '+16503530259'}
- updates user with contact information for an incident, this means that any firefighter can use any phone
- returns
200
on success,400
on failure
- expects