on master help sign in
17 files changed+79−91
since splitsnapshots
unifiedsplit
LICENSE Procfile Setup.hs app.json app/Main.hs docs.md docs/Docs.hs package.yaml readme.md+74−86 src/Data/CyclicBuffer.hs src/Data/Error.hs src/Foo/Data.hs+2−2 src/Lib.hs src/Network/Bacon.hs+3−3 stack.yaml swagger/Swagger.hs test/Spec.hs
LICENSEmode 100644 → 100755

Only the mode changed.

Procfilemode 100644 → 100755

Only the mode changed.

Setup.hsmode 100644 → 100755

Only the mode changed.

app.jsonmode 100644 → 100755

Only the mode changed.

app/Main.hsmode 100644 → 100755

Only the mode changed.

docs.mdmode 100644 → 100755

Only the mode changed.

docs/Docs.hsmode 100644 → 100755

Only the mode changed.

package.yamlmode 100644 → 100755

Only the mode changed.

readme.mdmode 100644 → 100755+74−86
@@ -6,10 +6,6 @@ _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−
139### Response:
1410
1511- Status code 200
@@ -58,48 +54,12 @@ Use this _url_ to get the token every time when application begins and previous
5854 ]
5955}
6056```
61−### Captures:
62−- «token» to further use it in subscription to web socket
63−
64−- «response» to start with the given number of posts in table
65−
66−## WebSocket /posts/subscribe/:token
67−
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.
7757
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
58+## GET /users/:id
9959
100−_url: [`https://websuck1t.herokuapp.com/posts/{id}`](https://websuck1t.herokuapp.com/posts/1)_
60+Retrieves a user with the given `id`.
10161
102−#### If there is no post with the given `id`, the method returns error `404`.
62+#### If there is no user with the given `id`, the method returns error `404`.
10363
10464### Captures:
10565
@@ -118,9 +78,11 @@ _url: [`https://websuck1t.herokuapp.com/posts/{id}`](https://websuck1t.herokuapp
11878
11979```javascript
12080{
121− «postBody»: «This is the post body»,
122− «postAuthor»: 4,
123− «postId»: 1
81+ "userName": {
82+ "secondName": "Leonidovich",
83+ "firstName": "Seva"
84+ },
85+ "userId": 1
12486}
12587```
12688
@@ -128,9 +90,11 @@ _url: [`https://websuck1t.herokuapp.com/posts/{id}`](https://websuck1t.herokuapp
12890
12991```javascript
13092{
131− «postBody»: «This is another post body»,
132− «postAuthor»: 4,
133− «postId»: 1
93+ "userName": {
94+ "secondName": "Barovich",
95+ "firstName": "Foo"
96+ },
97+ "userId": 42
13498}
13599```
136100
@@ -138,9 +102,11 @@ _url: [`https://websuck1t.herokuapp.com/posts/{id}`](https://websuck1t.herokuapp
138102
139103```javascript
140104{
141− «postBody»: «This is the post body»,
142− «postAuthor»: 7,
143− «postId»: 1
105+ "userName": {
106+ "secondName": "Fooovich",
107+ "firstName": "Bar"
108+ },
109+ "userId": 69
144110}
145111```
146112
@@ -148,30 +114,50 @@ _url: [`https://websuck1t.herokuapp.com/posts/{id}`](https://websuck1t.herokuapp
148114
149115```javascript
150116{
151− «postBody»: «This is another post body»,
152− «postAuthor»: 7,
153− «postId»: 1
117+ "userName": {
118+ "secondName": "Quixovich",
119+ "firstName": "Qux"
120+ },
121+ "userId": 8
154122}
155123```
156124
157−- Example (`application/json`):
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:
158139
159140```javascript
160141{
161− «postBody»: «This is the post body»,
162− «postAuthor»: 92,
163− «postId»: 1
142+ "token": 1828,
143+ "response": {
144+ "deleted": [
145+ 1819,
146+ 1835,
147+ 1843
148+ ],
149+ "added": [
150+ 1844,
151+ 1845,
152+ 1846
153+ ]
154+ }
164155}
165156```
166157
158+## GET /posts/:id
167159
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`.
160+#### If there is no post with the given `id`, the method returns error `404`.
175161
176162### Captures:
177163
@@ -190,11 +176,9 @@ Retrieves a user with the given `id`.
190176
191177```javascript
192178{
193− "userName": {
194− "secondName": "Leonidovich",
195− "firstName": "Seva"
196− },
197− "userId": 1
179+ "postBody": "This is the post body",
180+ "postAuthor": 4,
181+ "postId": 1
198182}
199183```
200184
@@ -202,11 +186,9 @@ Retrieves a user with the given `id`.
202186
203187```javascript
204188{
205− "userName": {
206− "secondName": "Barovich",
207− "firstName": "Foo"
208− },
209− "userId": 42
189+ "postBody": "This is another post body",
190+ "postAuthor": 4,
191+ "postId": 1
210192}
211193```
212194
@@ -214,11 +196,9 @@ Retrieves a user with the given `id`.
214196
215197```javascript
216198{
217− "userName": {
218− "secondName": "Fooovich",
219− "firstName": "Bar"
220− },
221− "userId": 69
199+ "postBody": "This is the post body",
200+ "postAuthor": 7,
201+ "postId": 1
222202}
223203```
224204
@@ -226,10 +206,18 @@ Retrieves a user with the given `id`.
226206
227207```javascript
228208{
229− "userName": {
230− "secondName": "Quixovich",
231− "firstName": "Qux"
232− },
233− "userId": 8
209+ "postBody": "This is another post body",
210+ "postAuthor": 7,
211+ "postId": 1
212+}
213+```
214+
215+- Example (`application/json`):
216+
217+```javascript
218+{
219+ "postBody": "This is the post body",
220+ "postAuthor": 92,
221+ "postId": 1
234222}
235223```
src/Data/CyclicBuffer.hsmode 100644 → 100755

Only the mode changed.

src/Data/Error.hsmode 100644 → 100755

Only the mode changed.

src/Foo/Data.hsmode 100644 → 100755+2−2
@@ -85,7 +85,7 @@ createConfig :: IO Config
8585createConfig = do
8686 mng <- newManager tlsManagerSettings
8787 cfg <- atomically $ Config <$> newTVar 0 <*> newTVar 0 <*> newTVar M.empty <*> newTVar M.empty <*> return mng <*> newTVar M.empty <*> newTVar 0 <*> newTVar (CB.empty 20)
88− forkIO . forever $ threadDelay 7000000 >> (runHandler . createApp cfg $ startAddingPosts 20 cfg >>= uncurry sendUpdate)
88+ forkIO . forever $ threadDelay 2000000 >> (runHandler . createApp cfg $ startAddingPosts 20 cfg >>= uncurry sendUpdate)
8989 return cfg
9090
9191type Token = Int
@@ -165,7 +165,7 @@ startAddingPosts lim cfg = do
165165 let us = users cfg
166166 let ps = posts cfg
167167
168− a <- liftIO $ loremBacon (manager cfg) (Just AllMeat) (Just lim) (Just False)
168+ a <- liftIO $ loremBacon (manager cfg) (Just AllMeat) (Just lim) (Just 0)
169169 g <- liftIO newStdGen
170170 let rns = randoms g
171171
src/Lib.hsmode 100644 → 100755

Only the mode changed.

src/Network/Bacon.hsmode 100644 → 100755+3−3
@@ -21,15 +21,15 @@ instance ToHttpApiData LoremType where
2121 toQueryParam MeatAndFiller = "meat-and-filler"
2222 toQueryParam AllMeat = "all-meat"
2323
24−type API = QueryParam "type" LoremType :> QueryParam "paras" Int :> QueryParam "start-with-lorem" Bool :> Get '[JSON] [Text]
24+type API = QueryParam "type" LoremType :> QueryParam "paras" Int :> QueryParam "start-with-lorem" Int :> Get '[JSON] [Text]
2525
2626clientAPI :: Proxy API
2727clientAPI = Proxy
2828
29−loremBacon' :: Maybe LoremType -> Maybe Int -> Maybe Bool -> ClientM [Text]
29+loremBacon' :: Maybe LoremType -> Maybe Int -> Maybe Int -> ClientM [Text]
3030loremBacon' = client clientAPI
3131
32−loremBacon :: Manager -> Maybe LoremType -> Maybe Int -> Maybe Bool -> IO (Maybe [Text])
32+loremBacon :: Manager -> Maybe LoremType -> Maybe Int -> Maybe Int -> IO (Maybe [Text])
3333loremBacon mng a b c = do
3434 let env = mkClientEnv mng (BaseUrl Https "baconipsum.com" 443 "api")
3535 res <- runClientM (loremBacon' a b c) env
stack.yamlmode 100644 → 100755

Only the mode changed.

swagger/Swagger.hsmode 100644 → 100755

Only the mode changed.

test/Spec.hsmode 100644 → 100755

Only the mode changed.