on master help sign in
updated readme

Added links, some discretional messages and reordered headers

commit7d9280defbe102346bf622a8848de556eebc69e1 authorDarya Rednikina <31587869+dashared@users.noreply.github.com> dateWed 23 Jan 2019, 11:56 (8 years ago) parentda5a84c
1 file changed+86−74
readme.md+86−74
readme.md+86−74
@@ -6,6 +6,10 @@ _url: [`https://websuck1t.herokuapp.com`](https://websuck1t.herokuapp.com)_
66
77## GET /posts/all
88
9+_start with: [`https://websuck1t.herokuapp.com/posts/all`](https://websuck1t.herokuapp.com/posts/all)_
10+
11+Use this _url_ to get the token every time when application begins and previous session was closed
12+
913### Response:
1014
1115- Status code 200
@@ -54,12 +58,48 @@ _url: [`https://websuck1t.herokuapp.com`](https://websuck1t.herokuapp.com)_
5458 ]
5559}
5660```
61+### Captures:
62+- «token» to further use it in subscription to web socket
5763
58−## GET /users/:id
64+- «response» to start with the given number of posts in table
5965
60−Retrieves a user with the given `id`.
66+## WebSocket /posts/subscribe/:token
6167
62−#### If there is no user with the given `id`, the method returns error `404`.
68+You access the web socket with the web socket protocol. I. e. `https://` -> `ws://`.
69+
70+Open a web socket from the given `token` for receiving events about new and deleted posts with `ws://websuck1t.herokuapp.com/posts/subscribe/{token}`
71+
72+#### Returns error `498` if the supplied token has expired or is invalid.
73+
74+### Captures:
75+
76+- *token*: The token, received with the previous request.
77+
78+### Response:
79+
80+```javascript
81+{
82+ «token»: 1828,
83+ «response»: {
84+ «deleted»: [
85+ 1819,
86+ 1835,
87+ 1843
88+ ],
89+ «added»: [
90+ 1844,
91+ 1845,
92+ 1846
93+ ]
94+ }
95+}
96+```
97+
98+## GET /posts/:id
99+
100+_url: [`https://websuck1t.herokuapp.com/posts/{id}`](https://websuck1t.herokuapp.com/posts/1)_
101+
102+#### If there is no post with the given `id`, the method returns error `404`.
63103
64104### Captures:
65105
@@ -78,11 +118,9 @@ Retrieves a user with the given `id`.
78118
79119```javascript
80120{
81− "userName": {
82− "secondName": "Leonidovich",
83− "firstName": "Seva"
84− },
85− "userId": 1
121+ «postBody»: «This is the post body»,
122+ «postAuthor»: 4,
123+ «postId»: 1
86124}
87125```
88126
@@ -90,11 +128,9 @@ Retrieves a user with the given `id`.
90128
91129```javascript
92130{
93− "userName": {
94− "secondName": "Barovich",
95− "firstName": "Foo"
96− },
97− "userId": 42
131+ «postBody»: «This is another post body»,
132+ «postAuthor»: 4,
133+ «postId»: 1
98134}
99135```
100136
@@ -102,11 +138,9 @@ Retrieves a user with the given `id`.
102138
103139```javascript
104140{
105− "userName": {
106− "secondName": "Fooovich",
107− "firstName": "Bar"
108− },
109− "userId": 69
141+ «postBody»: «This is the post body»,
142+ «postAuthor»: 7,
143+ «postId»: 1
110144}
111145```
112146
@@ -114,50 +148,30 @@ Retrieves a user with the given `id`.
114148
115149```javascript
116150{
117− "userName": {
118− "secondName": "Quixovich",
119− "firstName": "Qux"
120− },
121− "userId": 8
151+ «postBody»: «This is another post body»,
152+ «postAuthor»: 7,
153+ «postId»: 1
122154}
123155```
124156
125−## WebSocket /posts/subscribe/:token
126−
127−You access the web socket with the web socket protocol. I. e. `https://` -> `ws://`.
128−
129−Open a web socket from the given `token` for receiving events about new and deleted posts.
130−
131−#### Returns error `498` if the supplied token has expired or is invalid.
132−
133−
134−### Captures:
135−
136−- *token*: The token, received with the previous request.
137−
138−### Response:
157+- Example (`application/json`):
139158
140159```javascript
141160{
142− "token": 1828,
143− "response": {
144− "deleted": [
145− 1819,
146− 1835,
147− 1843
148− ],
149− "added": [
150− 1844,
151− 1845,
152− 1846
153− ]
154− }
161+ «postBody»: «This is the post body»,
162+ «postAuthor»: 92,
163+ «postId»: 1
155164}
156165```
157166
158−## GET /posts/:id
159167
160−#### If there is no post with the given `id`, the method returns error `404`.
168+## GET /users/:id
169+
170+_url: [`https://websuck1t.herokuapp.com/users/{id}`](https://websuck1t.herokuapp.com/users/1)_
171+
172+Retrieves a user with the given `id`.
173+
174+#### If there is no user with the given `id`, the method returns error `404`.
161175
162176### Captures:
163177
@@ -176,19 +190,11 @@ Open a web socket from the given `token` for receiving events about new and dele
176190
177191```javascript
178192{
179− "postBody": "This is the post body",
180− "postAuthor": 4,
181− "postId": 1
182−}
183−```
184−
185−- Example (`application/json`):
186−
187−```javascript
188−{
189− "postBody": "This is another post body",
190− "postAuthor": 4,
191− "postId": 1
193+ "userName": {
194+ "secondName": "Leonidovich",
195+ "firstName": "Seva"
196+ },
197+ "userId": 1
192198}
193199```
194200
@@ -196,9 +202,11 @@ Open a web socket from the given `token` for receiving events about new and dele
196202
197203```javascript
198204{
199− "postBody": "This is the post body",
200− "postAuthor": 7,
201− "postId": 1
205+ "userName": {
206+ "secondName": "Barovich",
207+ "firstName": "Foo"
208+ },
209+ "userId": 42
202210}
203211```
204212
@@ -206,9 +214,11 @@ Open a web socket from the given `token` for receiving events about new and dele
206214
207215```javascript
208216{
209− "postBody": "This is another post body",
210− "postAuthor": 7,
211− "postId": 1
217+ "userName": {
218+ "secondName": "Fooovich",
219+ "firstName": "Bar"
220+ },
221+ "userId": 69
212222}
213223```
214224
@@ -216,8 +226,10 @@ Open a web socket from the given `token` for receiving events about new and dele
216226
217227```javascript
218228{
219− "postBody": "This is the post body",
220− "postAuthor": 92,
221− "postId": 1
229+ "userName": {
230+ "secondName": "Quixovich",
231+ "firstName": "Qux"
232+ },
233+ "userId": 8
222234}
223235```