This web api displays two services for mobile application clients. It aims to help people sharing a taxi ride.
- Manage account profile: sign in, sign up, update, delete, etc.
- Manage ride: create ride, get rides, join ride, get ride data, etc.
- Manage database: show, import, export, etc.
Use this command to install locally all the dependencies needed:
npm install
Use this command to install globally forever module:
npm install forever -g
Several tests are provided, execute them using the following command:
npm test
Execute the following command for launching server:
npm start
If you want to launch server in production mode, run the following command:
forever start ./bin/start.js
Several scripts are provided for managing database
node ./bin/show user
node ./bin/show ride
Just pipe it with grep command to look at a particular entry !
node ./bin/show user | grep id:8
node ./bin/import --format csv --type users "user sample.csv"
node ./bin/import --format json --type users "user sample.json"
node ./bin/import --format csv --type stops "ratp_stops_with_routes.csv"
node ./bin/export --format csv users.csv
node ./bin/export --format csv stops.csv
If the email and password are correct, a session cookie is returned to the client
url: domain/usr/signin
Paramètres: {"email", "password"}
Retour: { "result": bool, "data": null }
Allows client to check password before allowing client user to reset critical information
url: domain/usr/checkpassword
Paramètres: {"password"}
Retour: { "result": bool, "data": null }
Client user can sign up with an email and password if the email is not already used
url: domain/usr/signup
Paramètres: {"email", "password"}
Retour: { "result": bool, "data": null }
Just destroying the cookie session
url: domain/usr/signout
Paramètres: {}
Retour: { "result": bool, "data": null }
As the email is set as index in user database, it needs special treatments
url: domain/usr/updateemail
Paramètres: {"email"}
Retour: { "result": bool, "data": null }
This request allows client to update user data as password but not email and id
url: domain/usr/update
Paramètres: {"image", "lastName", "firstName", "birthDate", "gender", "weight", "address", "zipCode", "city", "country", "phone", "password", "latitude", "longitude", "lastKnownPositionDate", "bac", "lastBacKnownDate" }
Retour: { "result": bool, "data": null}
Client will get user data without password
url: domain/usr/get
Paramètres: {}
Retour: { "result": bool, "data": userObject }
A user can get data of another user by providing user's id
url: domain/usr/getbyid
Paramètres: { "id" }
Retour: { "result": bool, "data": ["id", "image", "lastName", "firstName", "birthDate", "gender", "phone"] }
Delete all user data in user database if he hasn't got a ride in progress
url: domain/usr/delete
Paramètres: {}
Retour: { "result": bool, "data": null }
Allows client to know if the user has a ride in progress
url: domain/rd/has
Paramètres: {}
Retour: { "result": bool, "data": null }
Client can search rides available based on user's preference
url: domain/rd/search
Paramètres: { "latStart", "lonStart", "latEnd", "lonEnd", "dateTime", "numberOfPeople" }
Retour: { "result": bool, "data": [ { "id", "distanceToStart", "distanceToEnd", "addressStart", "latStart", "lonStart", "addressEnd", "latEnd", "lonEnd", "dateTime", "numberOfPassenger", "maxPrice" }, ... ] }
User can join an existing ride by providing its id and the numberOfPeople. If the ride is no longer available, the user will be notified in this way.
url: domain/rd/join
Paramètres: { "id", "numberOfPeople" }
Retour: { "result": bool, "data": null }
If the user doesn't want to join an existing ride, he can create his own one by providing the essential data requested
url: domain/rd/create
Paramètres: { "addressStart", "latStart", "lonStart", "addressEnd", "latEnd", "lonEnd", "dateTime", "numberOfPeople" }
Retour: { "result": bool, "data": null }
Once a user has joined or created a ride, he can access all the ride data such as passengers id
url: domain/rd/get
Paramètres: {}
Retour: { "result": bool, "data": { "id", "addressStart", "latStart", "lonStart", "addressEnd", "latEnd", "lonEnd", "dateTime", "maxPrice", "numberOfPassenger", "passenger_1", "passenger_2", "passenger_3", "passenger_4" } }
All users can access a part of the ride data by providing ride id
url: domain/rd/getbyid
Paramètres: { "id" }
Retour: { "result": bool, "data": { "id", "addressStart", "latStart", "lonStart", "addressEnd", "latEnd", "lonEnd", "dateTime", "maxPrice", "numberOfPassenger" } }
User namespace key: "users:#{id}:#{property}"
Properties: "email", "image", "lastName", "firstName", "birthDate", "gender", "weight", "address", "zipCode", "city", "country", "phone", "password", "latitude", "longitude", "lastKnownPositionDate", "bac" and "lastBacKnownDate"
birthDate format: 'DD-MM-YYYY'
User namespace index: "usersEmailIndex:#{email}:#{property}"
property: "id"
Ride namespace key: "rides:#{id}:#{property}"
Properties: "addressStart", "latStart", "lonStart", "addressEnd", "latEnd", "lonEnd", "dateTime", "price", "numberOfPassenger", "passenger_1", "passenger_2", "passenger_3" and "passenger_4"
dateTime format: 'DD-MM-YYYY H:mm'
Ride namespace index: "ridesPassengerIndex:#{userId}:#{id}:#{property}"
property: "dateTime"
Ridesearch namespace key: "ridesearch:#{userId}:#{distance}:#{rideId}"
Stop namespace key: "stops:#{id}:#{property}"
Properties: "name", "desc", "lat", "lon", "lineType" and "lineName"
Stop namespace index: "stops:#{lineType}:#{id}"