on f8dd608 help sign in
17 files changed+10−237
since splitsnapshots
unifiedsplit
LICENSE Procfile Setup.hs app.json app/Main.hs+3−6 docs.md docs/Docs.hs+2−2 package.yaml−1 readme.md−223 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 100755 → 100644

Only the mode changed.

Procfilemode 100755 → 100644

Only the mode changed.

Setup.hsmode 100755 → 100644

Only the mode changed.

app.jsonmode 100755 → 100644

Only the mode changed.

app/Main.hsmode 100755 → 100644+3−6
@@ -4,13 +4,10 @@ import Network.Wai.Handler.Warp (run)
44import Servant.Server (serve)
55import System.Environment
66import Lib
7−import Network.Wai.Middleware.Cors
87
98main :: IO ()
109main = do
11− env <- lookupEnv "PORT"
12− let port = maybe 2000 read env :: Int
13− putStrLn $ "Starting on port: " ++ show port
14− print env
10+ env <- getEnvironment
11+ let port = maybe 2000 read $ lookup "PORT" env
1512 srv <- createServer
16− run port $ simpleCors $ serve server srv
13+ run port $ serve server srv
docs.mdmode 100755 → 100644

Only the mode changed.

docs/Docs.hsmode 100755 → 100644+2−2
@@ -26,7 +26,7 @@ instance ToCapture (Capture "first" T.Text) where
2626 toCapture _ = DocCapture "first" "The first name of the user."
2727
2828instance ToSample Foo.Data.Post where
29− toSamples _ = samples $ Post `fmap` [1, 4, 7, 194] <*> [4, 7, 92] <*> ["This is the post body", "This is another post body"]
29+ toSamples _ = samples $ Post <$> [1, 4, 7, 194] <*> [4, 7, 92] <*> ["This is the post body", "This is another post body"]
3030
3131instance ToSample User where
3232 toSamples _ = samples [
@@ -39,7 +39,7 @@ instance ToCapture (Capture "second" T.Text) where
3939 toCapture _ = DocCapture "second" "The second name of the user."
4040
4141instance ToSample (TokenizedResponse [Foo.Data.Post]) where
42− toSamples _ = samples $ TokenizedResponse `fmap` [1, 46, 193, 7] <*> [map snd $ toSamples (Proxy :: Proxy Foo.Data.Post)]
42+ toSamples _ = samples $ TokenizedResponse <$> [1, 46, 193, 7] <*> [map snd $ toSamples (Proxy :: Proxy Foo.Data.Post)]
4343
4444instance ToCapture (Capture "id" Int) where
4545 toCapture _ = DocCapture "id" "The id of the entity you want to query."
package.yamlmode 100755 → 100644−1
@@ -36,7 +36,6 @@ dependencies:
3636- servant-websockets
3737- websockets
3838- lens
39−- wai-cors
4039
4140library:
4241 source-dirs: src
readme.mddeleted−223
@@ -1,223 +0,0 @@
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− "response": [
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−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:
139−
140−```javascript
141−{
142− "token": 1828,
143− "response": {
144− "deleted": [
145− 1819,
146− 1835,
147− 1843
148− ],
149− "added": [
150− 1844,
151− 1845,
152− 1846
153− ]
154− }
155−}
156−```
157−
158−## GET /posts/:id
159−
160−#### If there is no post with the given `id`, the method returns error `404`.
161−
162−### Captures:
163−
164−- *id*: The id of the entity you want to query.
165−
166−### Response:
167−
168−- Status code 200
169−- Headers: []
170−
171−- Supported content types are:
172−
173− - `application/json`
174−
175−- Example (`application/json`):
176−
177−```javascript
178−{
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
192−}
193−```
194−
195−- Example (`application/json`):
196−
197−```javascript
198−{
199− "postBody": "This is the post body",
200− "postAuthor": 7,
201− "postId": 1
202−}
203−```
204−
205−- Example (`application/json`):
206−
207−```javascript
208−{
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
222−}
223−```
src/Data/CyclicBuffer.hsmode 100755 → 100644

Only the mode changed.

src/Data/Error.hsmode 100755 → 100644

Only the mode changed.

src/Foo/Data.hsmode 100755 → 100644+2−2
@@ -92,7 +92,7 @@ type Token = Int
9292
9393data TokenizedResponse d = TokenizedResponse {
9494 token :: Token,
95− response :: d
95+ reponse :: d
9696} deriving Generic
9797
9898instance ToJSON d => ToJSON (TokenizedResponse d)
@@ -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 0)
168+ a <- liftIO $ loremBacon (manager cfg) (Just AllMeat) (Just lim) (Just False)
169169 g <- liftIO newStdGen
170170 let rns = randoms g
171171
src/Lib.hsmode 100755 → 100644

Only the mode changed.

src/Network/Bacon.hsmode 100755 → 100644+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" Int :> Get '[JSON] [Text]
24+type API = QueryParam "type" LoremType :> QueryParam "paras" Int :> QueryParam "start-with-lorem" Bool :> Get '[JSON] [Text]
2525
2626clientAPI :: Proxy API
2727clientAPI = Proxy
2828
29−loremBacon' :: Maybe LoremType -> Maybe Int -> Maybe Int -> ClientM [Text]
29+loremBacon' :: Maybe LoremType -> Maybe Int -> Maybe Bool -> ClientM [Text]
3030loremBacon' = client clientAPI
3131
32−loremBacon :: Manager -> Maybe LoremType -> Maybe Int -> Maybe Int -> IO (Maybe [Text])
32+loremBacon :: Manager -> Maybe LoremType -> Maybe Int -> Maybe Bool -> 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 100755 → 100644

Only the mode changed.

swagger/Swagger.hsmode 100755 → 100644

Only the mode changed.

test/Spec.hsmode 100755 → 100644

Only the mode changed.