Skip to content

Latest commit

 

History

History
101 lines (84 loc) · 2.23 KB

api_guide.md

File metadata and controls

101 lines (84 loc) · 2.23 KB

Guida per l'API di DGM Direct


Operazioni con gli utenti

  • Inserire un nuovo utente

    Method: POST
    URI: host / api / users / addUser
    body: {
    "firstName" : "...",
    "lastName" : "...",
    "username" : "...",
    "email" : "...",
    "password" : "..."
    }

  • Verifica le credenziali di un utente

    Method: POST
    URI: host / api / users / login
    body: {
    "username": "...",
    "password": "..."
    }

  • Aggiungere un amico alla lista di un utente dati gli username

    Method: POST
    URI: host / api / users / addFriend
    body: {
    "username": "...",
    "newFriend": "..."
    }

  • Rimuovere un amico alla lista di un utente dati gli username

    Method: POST
    URI: host / api / users / removeFriend
    body: {
    "username": "...",
    "friend": "..."
    }

  • Estrarre gli amici di un utente dato il suo username

    Method: POST
    URI: host / api / users / getFriends / :username
    body: null

  • Estrarre tutti gli utenti, escluso l'utente dato e i suoi amici

    Method: POST
    URI: host / api / users / getNotFriends / :username
    body: null

  • Estrarre le chat attive di un utente dato il suo username

    Method: POST
    URI: host / api / users / getChats / :username
    body: null


Operazioni con i messaggi

  • Aggiungere un nuovo messaggio

    Method: POST
    URI: host / api / messages / addMessage
    body: {
    "author" : [ObjectID],
    "receiver" : [ObjectID],
    "text" : "...",
    "time" : [ms]
    }

  • Estrarre una chat fra due utenti dati gli username

    Method: POST
    URI: host / api / messages / :user1 / :user2
    body: null \

  • Eliminare un messaggio dato il suo identificatore

    Method: POST
    URI: host / api / messages / deleteMessage
    body: {
    "id": "..." }


Esempio di richiesta

const newUser = {
  firstName: firstName,
  lastName: lastName,
  username: username,
  email: email,
  password: password
};

axios.post('http://localhost:3001/api/users/addUser', newUser)
    .then(res => {
        console.log("Utente creato con successo")
        console.log(res.data)
    })
    .catch(error => {
        console.error(error);
    });