Scratchy is composed of:
- front: VueJS
- server: scratchy_server in Python
- database: mongodb in docker
You can go to http://localhost:5000/swagger-ui/ after launching the server to do your request
Start mongodb:
- prerequisites:
- install docker: see Install Docker Engine
- install docker-compose: see Install Docker-compose or use the package management of your GNU/Linux distribution (Ubuntu for example)
NB : if you have a error, retry with the SUDO prefix ( on some computer we need the SUDO privileges for use this commands)
- build images in server directory
<scratchy/server>$ make build
- go to docker directory
<scratchy root>$ cd docker
- start mongodb using docker-compose:
<scratchy/docker>$ docker-compose up -d
NOTE
For stopping mongodb, use:
<scratchy/docker>$ docker-compose down
Then read the next section for server part.
Install the depedencies :
pip install -r requirements.txt
Install the package in developpment :
python setup.py develop
Start the serveur :
scratchy-server
- Go to docker directory:
<scratchy root>$ cd docker
- Stop mongodb using docker-compose:
<scratchy/docker>$ docker-compose down
- Remove data file:
<scratchy/docker>$ sudo rm -r data
- Restore git file:
<scratchy/docker>$ git restore data/.gitignore
- Restart mongodb using docker-compose:
<scratchy/docker>$ docker-compose up -d
<scratchy/server/scratchy-server/test>$ python test.py
Requirements:
- curl
- jq
On ubuntu/debian, simply run : sudo apt install curl jq
Get Swagger:
curl http://localhost:5000/swagger/
Get Room:
curl http://localhost:5000/api/room/0 | jq
Create Room:
curl http://localhost:5000/api/room -H "Content-Type: application/json" --data '{"title": "mon title", "description": "ma description"}'
Update Room (update title and description)
curl -X PUT http://localhost:5000/api/room/6071ac5176e5bd456a859d9d -H "Content-Type: application/json" --data '{"title":"un autre titre", "description": "une nouvelle description"}'
Delete Room:
curl -X DELETE http://localhost:5000/api/room/0
Get all rooms:
curl http://localhost:5000/api/room
Delete all rooms:
curl -X DELETE http://localhost:5000/api/room
Get User By id:
curl http://localhost:5000/api/user/0 | jq
Get User By pseudo:
curl http://localhost:5000/api/user?pseudo=toto | jq
Create User:
curl http://localhost:5000/api/user -H "Content-Type: application/json" --data '{"pseudo": "mon pseudo", "profileImage": "https://http.cat/204"}'
Update User:
curl -X PUT http://localhost:5000/api/user/607ae876f59d21d5a50ac3c9 -H "Content-Type: application/json" --data '{"pseudo":"un autre pseudo", "profileImage": "https://http.cat/202"}'
Delete User:
curl -X DELETE http://localhost:5000/api/user/0
Delete all users:
curl -X DELETE http://localhost:5000/api/user
Get Message:
curl http://localhost:5000/api/message/0 | jq
Create Message:
curl http://localhost:5000/api/message -H "Content-Type: application/json" --data '{"author": "the author id", "content": "write what you want its your message","roomId": "the ids of the rooms you are in"}'
Update Message:
curl -X PUT http://localhost:5000/api/message/607ae94b589238d93e33715d -H "Content-Type: application/json" --data '{"author": "the new author id", "content": "write what you want its your message and now", "roomId": "the id of the new room you are in"}'
Delete Message:
curl -X DELETE http://localhost:5000/api/message/0
Get all messages for one RoomId:
curl -v http:/localhost:5000/api/message?roomId=6043978fd68dc3fcbf6079d6
Delete all messages:
curl -X DELETE http://localhost:5000/api/message