From 0a296aba07ad832d3e4b8f5a556130c72f586526 Mon Sep 17 00:00:00 2001 From: afrokick Date: Sun, 22 Mar 2020 00:28:50 +0300 Subject: [PATCH] add README for HTTP API --- README.md | 6 +++++- changelog.md | 17 +++++++++++++++++ src/api/README.md | 21 +++++++++++++++++++++ 3 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 src/api/README.md diff --git a/README.md b/README.md index e4da5f9..d50d323 100644 --- a/README.md +++ b/README.md @@ -189,6 +189,10 @@ when the peer can no longer be reached. peerServer.on('disconnect', (client) => { ... }); ``` +## HTTP API + +Read [/src/api/README.md](src/api/README.md) + ## Running tests ```sh @@ -218,7 +222,7 @@ $ docker run -p 9000:9000 -d myimage This will start a peerjs server on port 9000 exposed on port 9000 with key `peerjs` on path `/myapp`. -Open browser with http://localhost:9000/myapp It should returns JSON with name, description and website fields. http://localhost:9000/myapp/peerjs/id - should returns a random string (random client id) +Open your browser with http://localhost:9000/myapp It should returns JSON with name, description and website fields. http://localhost:9000/myapp/peerjs/id - should returns a random string (random client id) ## Problems? diff --git a/changelog.md b/changelog.md index cba69d8..ff2d5ff 100644 --- a/changelog.md +++ b/changelog.md @@ -1,5 +1,22 @@ # PeerServer Changelog + +### vNEXT 0.5.0 + +* Change: use "/" instead of "/myapp" as a default value for config's `path` option + +* New: typescript declaration file + +* Update deps: +```diff +- "cors": "2.8.4", ++ "cors": "^2.8.5", +- "uuid": "3.3.3", ++ "uuid": "^3.4.0", +- "ws": "7.1.2", ++ "ws": "^7.2.3" +``` + ### 0.4.0 * New: Allow passing in custom client ID generation function - #157 Thanks @ajmar diff --git a/src/api/README.md b/src/api/README.md new file mode 100644 index 0000000..60deaa7 --- /dev/null +++ b/src/api/README.md @@ -0,0 +1,21 @@ +## HTTP API + +In progress... + +The API methods available on `YOUR_ROOT_PATH` + `path` option from config. + +So, the base path should be like `http://127.0.0.1:9000/` or `http://127.0.0.1:9000/myapp/` if `path` option was set to `/myapp`. + +Endpoints: + +* GET `/` - return a JSON to test the server. + +This group of methods uses `:key` option from config: +* GET `/:key/id` - return a new user id. required `:key` from config. +* GET `/:key/peers` - return an array of all connected users. required `:key` from config. **IMPORTANT:** You should set `allow_discovery` to `true` in config to enable this method. It disabled by default. + +This group of methods uses `:key` option from config, `:userId` and `:userToken` parameters from user. +* POST `/:key/:userId/:userToken/offer` +* POST `/:key/:userId/:userToken/candidate` +* POST `/:key/:userId/:userToken/answer` +* POST `/:key/:userId/:userToken/leave` \ No newline at end of file