- Database
- Dependencies
- How to use
- Examples
- Authors
The used database is MongoDB (Installation required). The database doesn't require any configuration as it implements automatically with the help of Mongoose.
Packages |
---|
Express |
Mongoose |
Cors |
Morgan |
Typescript |
Tsc-watch |
@types/express |
@types/morgan |
@types/cors |
First command should be the installation:
npm install
Then you can easily run the server with:
npm start
The server will start by default on port 3000.
Send message (url: localhost:3000/message). The message request has this format:
{
"idUser": 1,
"msg": "Message sent",
"date": "25/01/2022"
}
Get a message localhost:3000/messages
Server response:
{
"idUser": 1,
"msg": "Message sent",
"date": "25/01/2022"
}
Delete a message localhost:3000/deletemessage/how are you?
Server response:
{
"res": "message deleted"
}
Add user localhost:3000/user
The user request has this format:
{
"idUser": 1,
"username": "AlexHM",
"name": "Alex"
}
Get users localhost:3000/user
Server response:
{
"idUser": 1,
"msg": "Message sent",
"date": "25/01/2022"
}