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 -dNOTE
For stopping mongodb, use:
<scratchy/docker>$ docker-compose downThen read the next section for server part.
Install the depedencies :
pip install -r requirements.txtInstall the package in developpment :
python setup.py developStart 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.pyRequirements:
- 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 | jqCreate 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/0Get all rooms:
curl http://localhost:5000/api/roomDelete all rooms:
curl -X DELETE http://localhost:5000/api/roomGet User By id:
curl http://localhost:5000/api/user/0 | jqGet User By pseudo:
curl http://localhost:5000/api/user?pseudo=toto | jqCreate 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/0Delete all users:
curl -X DELETE http://localhost:5000/api/userGet Message:
curl http://localhost:5000/api/message/0 | jqCreate 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/0Get all messages for one RoomId:
curl -v http:/localhost:5000/api/message?roomId=6043978fd68dc3fcbf6079d6Delete all messages:
curl -X DELETE http://localhost:5000/api/message