@@ -0,0 +1,221 @@
1+# A server example with WebSockets
2+
3+_url: [`https://websuck1t.herokuapp.com`](https://websuck1t.herokuapp.com)_
4+
5+# Methods
6+
7+## GET /posts/all
8+
9+### Response:
10+
11+- Status code 200
12+- Headers: []
13+
14+- Supported content types are:
15+
16+ - `application/json`
17+
18+- Example (`application/json`):
19+
20+```javascript
21+{
22+ "token": 1,
23+ "reponse": [
24+ {
25+ "postBody": "This is the post body",
26+ "postAuthor": 4,
27+ "postId": 1
28+ },
29+ {
30+ "postBody": "This is another post body",
31+ "postAuthor": 4,
32+ "postId": 2
33+ },
34+ {
35+ "postBody": "This is the post body",
36+ "postAuthor": 7,
37+ "postId": 3
38+ },
39+ {
40+ "postBody": "This is another post body",
41+ "postAuthor": 7,
42+ "postId": 4
43+ },
44+ {
45+ "postBody": "This is the post body",
46+ "postAuthor": 92,
47+ "postId": 5
48+ },
49+ {
50+ "postBody": "This is another post body",
51+ "postAuthor": 92,
52+ "postId": 6
53+ }
54+ ]
55+}
56+```
57+
58+## GET /users/:id
59+
60+Retrieves a user with the given `id`.
61+
62+#### If there is no user with the given `id`, the method returns error `404`.
63+
64+### Captures:
65+
66+- *id*: The id of the entity you want to query.
67+
68+### Response:
69+
70+- Status code 200
71+- Headers: []
72+
73+- Supported content types are:
74+
75+ - `application/json`
76+
77+- Example (`application/json`):
78+
79+```javascript
80+{
81+ "userName": {
82+ "secondName": "Leonidovich",
83+ "firstName": "Seva"
84+ },
85+ "userId": 1
86+}
87+```
88+
89+- Example (`application/json`):
90+
91+```javascript
92+{
93+ "userName": {
94+ "secondName": "Barovich",
95+ "firstName": "Foo"
96+ },
97+ "userId": 42
98+}
99+```
100+
101+- Example (`application/json`):
102+
103+```javascript
104+{
105+ "userName": {
106+ "secondName": "Fooovich",
107+ "firstName": "Bar"
108+ },
109+ "userId": 69
110+}
111+```
112+
113+- Example (`application/json`):
114+
115+```javascript
116+{
117+ "userName": {
118+ "secondName": "Quixovich",
119+ "firstName": "Qux"
120+ },
121+ "userId": 8
122+}
123+```
124+
125+## WebSocket /posts/subscribe/:token
126+
127+Open a web socket from the given `token` for receiving events about new and deleted posts.
128+
129+#### Returns error `498` if the supplied token has expired or is invalid.
130+
131+
132+### Captures:
133+
134+- *token*: The token, received with the previous request.
135+
136+### Response:
137+
138+```javascript
139+{
140+ "token": 1828,
141+ "reponse": {
142+ "deleted": [
143+ 1819,
144+ 1835,
145+ 1843
146+ ],
147+ "added": [
148+ 1844,
149+ 1845,
150+ 1846
151+ ]
152+ }
153+}
154+```
155+
156+## GET /posts/:id
157+
158+#### If there is no post with the given `id`, the method returns error `404`.
159+
160+### Captures:
161+
162+- *id*: The id of the entity you want to query.
163+
164+### Response:
165+
166+- Status code 200
167+- Headers: []
168+
169+- Supported content types are:
170+
171+ - `application/json`
172+
173+- Example (`application/json`):
174+
175+```javascript
176+{
177+ "postBody": "This is the post body",
178+ "postAuthor": 4,
179+ "postId": 1
180+}
181+```
182+
183+- Example (`application/json`):
184+
185+```javascript
186+{
187+ "postBody": "This is another post body",
188+ "postAuthor": 4,
189+ "postId": 1
190+}
191+```
192+
193+- Example (`application/json`):
194+
195+```javascript
196+{
197+ "postBody": "This is the post body",
198+ "postAuthor": 7,
199+ "postId": 1
200+}
201+```
202+
203+- Example (`application/json`):
204+
205+```javascript
206+{
207+ "postBody": "This is another post body",
208+ "postAuthor": 7,
209+ "postId": 1
210+}
211+```
212+
213+- Example (`application/json`):
214+
215+```javascript
216+{
217+ "postBody": "This is the post body",
218+ "postAuthor": 92,
219+ "postId": 1
220+}
221+```