blob: 41f90f3473f47bfdb973a5be96e7bb4014a46273 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
|
module Fig.Web.Module.Sentiment
( public
) where
import Fig.Prelude
import Fig.Web.Utils
import Fig.Web.Types
import qualified Fig.Web.DB as DB
public :: PublicModule
public a = do
onGet "/api/sentiment" do
s <- DB.run a.db (DB.get "sentiment") >>= \case
Nothing -> pure "0"
Just x -> pure x
respondText $ decodeUtf8 s
onPost "/api/sentiment/green" do
DB.run a.db $ DB.incr "sentiment"
onPost "/api/sentiment/red" do
DB.run a.db $ DB.decr "sentiment"
|