- mlollo.rmoprheus.enseirb.fr
- http
- 80
set DEBUG=seeekfriendback:* & npm start
sudo DEBUG=seeekfriendback:* & npm start
-
expressjs :
- Description : Pour notre API REST, nous avons utilisé le module expressjs (qui permet d'avoir un serveur léger et rapide).
-
mongoose :
- Description : Package qui permet de connecter le serveur à la base de données mongodb (connect dans app.js ligne 58) et permet de créer des models, enregistrer des entrées (save), rechercher des entrées (find), les modifier (findOneAndUpdate) et les supprimer (remove).
-
bcrypt :
- Description : permet d'encrypter un mot de passe (hashSync) et de comparer un mot de passe avec celui encrypté et stocké dans mongodb (compareSync)
-
jsonwebtoken :
- Description : permet de créer un token à partir d'une phrase servant de mot de passe et d'un username (dans notre cas un email) et permet de verifier si le token donné en paramètre correspond à celui stocké dans la base. Cela permet l'authentification des requêtes des users.
- Users :
- String: email
- String: pseudo
- String: password
- Boolean: isLog
- String: token
- Coords :
- String: user_id
- String: lat
- String: lng
- String: date
- Friends :
- String: friends1
- String: friends2
-
GET /users/getall
- Description : Get a json list of all users
- Body Param : None
- Response :
- 200:
- JsonObject:
- String: email
- String: pseudo
- Boolean: isLog
- String: token
- JsonObject:
- 500:
- JsonObject: error
- 200:
-
POST /users/add
- Description : Add a new user to the data base when a app do Register
- Module Use :
- bcrypt : to encrypt the password
- jwt : to create a token for this email
- Body Param :
- String: email
- String: pseudo
- String: password
- Response :
- 200:
- JsonObject:
- Boolean: invalid
- JsonObject:
- 400:
- String: error (all body params are required)
- 500:
- JsonObject: error
- 200:
-
POST /users/login
- Description : Login a user who is in the database (update of islog field) and retrieve the token
- Module Use :
- bcrypt : to check if the password is correct
- Body Param :
- String: email
- String: password
- Response :
- 200:
- JsonObject:
- Boolean: valid
- JsonObject: user
- String: email
- String: pseudo
- String: password
- Boolean: isLog
- String: token
- JsonObject:
- 400:
- String: error (all body params are required)
- 401:
- JsonObject:
- Boolean: valid
- JsonObject:
- 500:
- JsonObject: error
- 200:
-
POST /users/getcoords
- Description : Get all users and coords to show in the sidebar view, used in reloadFriendsList : If you are logged you have every user except you but you can only show the positions of your friends
- Body Param :
- Boolean: islog
- String: user_id
- Response :
- 200:
- JsonArray:
- JsonObject: user
- String: email
- String: pseudo
- String: password
- Boolean: isLog
- String: token
- JsonArray: info
- String: user_id
- String: lat
- String: lng
- String: date
- Boolean: isfriend
- JsonObject: user
- JsonArray:
- 400:
- String: error (islog is required)
- 500:
- JsonObject: error
- 200:
-
POST /users/onsearch
- Description : Get all users and coords that match with search to show in the sidebar view : If you are logged you have every user who match except you
- Body Param :
- Boolean: islog
- String: search
- String: user_id
- Response :
- 200:
- JsonArray:
- JsonObject: user
- String: email
- String: pseudo
- String: password
- Boolean: isLog
- String: token
- JsonArray: info
- String: user_id
- String: lat
- String: lng
- String: date
- Boolean: isfriend
- JsonObject: user
- JsonArray:
- 400:
- String: error (islog and search are required)
- 500:
- JsonObject: error
- 200:
- Use
- Description : use of jwt.verify() methods to require an authentification token for all others routes
- Module :
- jwt : use of verify methods
- Body Param :
- String: token
- String: email
- Response :
- 400:
- String: error (email is required or wrong token)
- 401:
- String: error (token is required)
- 500:
- JsonObject: error
- 400:
-
POST /users/logine
- Description : Login with a token when you choose remember me option (not working yet)
- Body Param :
- String: email
- Response :
- 200:
- JsonObject:
- Boolean: valid
- JsonObject: user
- String: email
- String: pseudo
- String: password
- Boolean: isLog
- String: token
- JsonObject:
- 500:
- JsonObject: error
- 200:
-
POST /users/addcoords
- Description : Add an entry to the coords entity when a user is saving a position
- Body Param :
- String: user_id
- String: lat
- String: lng
- String: date
- Response :
- 200:
- JsonObject:
- String: user_id
- String: lat
- String: lng
- String: date
- JsonObject:
- 500:
- JsonObject: error
- 200:
-
POST /users/onsearchprofil
- Description : Get all coords or all coords which match with search to show in the sidebar profil view when you are logged in
- Body Param :
- String: email
- String: search
- String: user_id
- Response :
- 200:
- JsonArray:
- JsonObject: user
- String: email
- String: pseudo
- Boolean: isLog
- JsonArray: info
- String: user_id
- String: lat
- String: lng
- String: date
- JsonObject: user
- JsonArray:
- 400:
- String: error (user_id and search are required)
- 500:
- JsonObject: error
- 200:
-
POST /users/addfriend
- Description : add a friendship between two users
- Body Param :
- String: friends1
- String: friends2
- Response :
- 200:
- JsonObject:
- String: _id
- String: friends1
- String: friends2
- JsonObject:
- 400:
- String: error (friends1 and friends2 are required)
- 500:
- JsonObject: error
- 200:
-
POST /users/isfriend
- Description : check if two users are friends
- Body Param :
- String: friends1
- String: friends2
- Response :
- 200:
- JsonObject:
- String: isfriend
- JsonObject:
- 400:
- String: error (friends1 and friends2 are required)
- 500:
- JsonObject: error
- 200:
-
POST /users/logout
- Description : logout and update the parameter islog
- Body Param :
- String: email
- Response :
- 200:
- JsonObject:
- String: email
- String: pseudo
- String: password
- Boolean: isLog
- String: token
- JsonObject:
- 400:
- String: error (friends1 and friends2 are required)
- 500:
- JsonObject: error
- 200:
-
POST /users/getbyemail
- Description : get a user who matchs with an email
- Body Param :
- String: email
- Response :
- 200:
- JsonObject:
- String: email
- String: pseudo
- String: password
- Boolean: isLog
- String: token
- JsonObject:
- 500:
- JsonObject: error
- 200:
-
POST /users/getbyid
- Description : get a user who matchs with an id
- Body Param :
- String: user_id
- Response :
- 200:
- JsonObject:
- String: email
- String: pseudo
- String: password
- Boolean: isLog
- String: token
- JsonObject:
- 400:
- String: error (user_id are required)
- 500:
- JsonObject: error
- 200:
-
PUT /users/pw
- Description : update the user's password
- Module :
- bcrypt : compare the old password with database password
- Body Param :
- String: password
- String: newpassword
- String: email
- Response :
- 200:
- JsonObject:
- Boolean: valid
- JsonObject: user
- String: email
- String: pseudo
- String: password
- Boolean: isLog
- String: token
- JsonObject:
- 400:
- String: error (password and newpassword are required)
- 401:
- JsonObject:
- Boolean: valid
- JsonObject:
- 500:
- JsonObject: error
- 200:
-
POST /users/reset
- Description : delete all users not use in the app
- Response :
- 200:
- String: Success
- 500:
- JsonObject: error
- 200:
-
POST /users/rm
- Description : delete one user not used in the app
- Body Param :
- String: email
- Response :
- 200:
- String: Success
- 400:
- String: error (email is required)
- 500:
- JsonObject: error
- 200:
-
POST /users/removeFriend
- Description : delete a friendship by users id, used in the sidebar view in the menu template
- Body Param :
- String: friends1
- String: friends2
- Response :
- 200:
- String: Success
- 400:
- String: error (friends1 and friends2 are required)
- 500:
- JsonObject: error
- 200:
-
POST /coords/reset
- Description : delete all coords not used
- Response :
- 200:
- String: Success
- 500:
- JsonObject: error
- 200:
-
POST /coords/rm
- Description : delete one coord by id, used in profil view when deleting a position record
- Body Param :
- String: id
- Response :
- 200:
- String: Success
- 400:
- String: error (id is required)
- 500:
- JsonObject: error
- 200:
-
POST /friends/reset
- Description : delete all friendships not used
- Response :
- 200:
- String: Success
- 500:
- JsonObject: error
- 200:
-
POST /friends/rm
- Description : delete one friendship by id not used
- Body Param :
- String: id
- Response :
- 200:
- String: Success
- 400:
- String: error (id is required)
- 500:
- JsonObject: error
- 200: