- Getting Started
- Usage
- Testing the application
- Linter
- API
- Logging
- Authors
- Project Structure and Conventions
The following instructions allow you to setting up your project locally. To get a local copy up and running follow these simple example steps.
This is an example of how to list things you need to use the software and how to install them.
-
node
curl -fsSL https://deb.nodesource.com/setup_17.x | sudo -E bash - sudo apt-get install -y nodejs
-
yarn (optional)
npm global add yarn
-
Clone the repo
git clone https://git.fe.up.pt/sdle/2021/t3/g16/proj1.git
-
Install the project via
npm
oryarn
# with npm npm install # or # with yarn yarn
The next command is going to start the peer.
# with npm
npm run start <port> <username>
#or
# with yarn
yarn start <port> <username>
There are two required arguments:
- port: the port to listen on the REST application
- username: the username of the peer
In order to test the application you need to run the following command:
# with npm
npm run test
# or
# with yarn
yarn test
To check code conventions you can use the following command:
# with npm
npm run lint
# or
# with yarn
yarn lint
Prerequisites: peer is online
curl -X DELETE http://peerip:peerport/peer/remove
Prerequisites: peer is online
curl -X DELETE http://peerip:peerport/peer/stop
Prerequisites: peer is online
curl -X DELETE http://peerip:peerport/peer/unsubscribe
--header 'Content-Type: application/json' \
--data-raw '{"user":"username"}'
Prerequisites: peer is online
curl -X GET http://peerip:peerport/peer/cache
Prerequisites: peer is online
curl -X GET http://peerip:peerport/peer/database
Prerequisites: peer is online
curl -X GET http://peerip:peerport/peer/feed
Prerequisites: peer is online
curl -X GET http://peerip:peerport/peer/profile
--header 'Content-Type: application/json' \
--data-raw '{"id":"b25958f6-ca99-49b3-be50-c791f8658dc6username"}'
Prerequisites: peer is online
curl -X GET http://peerip:peerport/peer/profile
or
curl -X GET http://peerip:peerport/peer/profile
--header 'Content-Type: application/json' \
--data-raw '{"user":"username"}'
curl -X GET http://peerip:peerport/peer/token
Prerequisites: peer is online
curl -X GET http://peerip:peerport/peer/token
Prerequisites: peer is online
curl -X POST http://peerip:peerport/peer/post \
--header 'Content-Type: application/json' \
--data-raw '{"message":"Hello, world!"}'
curl -X PUT http://peerip:peerport/peer/start
or with private key and token
curl -X PUT http://peerip:peerport/peer/start \
--header 'Content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XFIFvJvKw52q+9qYPRFqfV8J6uKZi6LGogeTfKzEuSgyHs5FFfb\n2jF1em5fCjkbNqtwH0Uy1cqXkm/wd77Ots/YXpsUwrKjzkbeat2utukwjrgbFBcQ\nA1kA43GaHRcqns0oLV+xgLmLZk6a\n-----END PRIVATE KEY-----\n"
}'
Prerequisites: peer is online
curl -X DELETE http://peerip:peerport/peer/subscribe
--header 'Content-Type: application/json' \
--data-raw '{"user":"username"}'
Every peer execution is logged into the terminal with information about the execution of the program. An example is:
tp2p:peer peer created +0ms
tp2p:peer peer created +1ms
tp2p:peer peer created +1ms
tp2p:storage peer id file not found +0ms
tp2p:storage cache file not found +1ms
tp2p:peer peer has now started +469ms
tp2p:storage failed to recover following list, subscriptions file is not found +2s
tp2p:storage peer id file not found +33ms
tp2p:storage cache file not found +0ms
tp2p:storage peer id file not found +1ms
tp2p:storage cache file not found +0ms
PUT /peer/start 201 1861.730 ms - 4204
GET /peer/token 200 1.368 ms - 333
- Henrique Pereira (up201806538)
- Luรญs Tavares (up201809679)
- Mรกrcio Duarte (up201909936)
- Ricardo Nunes (up201706860)
- Code conventions based on standard ESLint config Standard;
- README template based on Best-README-Template.