Commit 1fd46635 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[API] WebSockets (WIP)

parent a3caa26a
Pipeline #1442 failed with stage
...@@ -217,6 +217,7 @@ library: ...@@ -217,6 +217,7 @@ library:
- servant-static-th - servant-static-th
- servant-swagger - servant-swagger
- servant-swagger-ui - servant-swagger-ui
- servant-websockets
- servant-xml - servant-xml
- simple-reflect - simple-reflect
- singletons # (IGraph) - singletons # (IGraph)
......
...@@ -178,9 +178,6 @@ makeDevMiddleware mode = do ...@@ -178,9 +178,6 @@ makeDevMiddleware mode = do
-- | API Global -- | API Global
--------------------------------------------------------------------- ---------------------------------------------------------------------
---------------------------
-- TODO-SECURITY admin only: withAdmin -- TODO-SECURITY admin only: withAdmin
-- Question: How do we mark admins? -- Question: How do we mark admins?
{- {-
...@@ -226,4 +223,4 @@ type family GenericTypeName t (r :: *) :: Symbol where ...@@ -226,4 +223,4 @@ type family GenericTypeName t (r :: *) :: Symbol where
GenericTypeName t (D1 ('MetaData name mod pkg nt) f x) = name GenericTypeName t (D1 ('MetaData name mod pkg nt) f x) = name
type Desc t n = Description (AppendSymbol (TypeName t) (AppendSymbol " | " n)) type Desc t n = Description (AppendSymbol (TypeName t) (AppendSymbol " | " n))
-} -}
\ No newline at end of file
...@@ -26,6 +26,12 @@ module Gargantext.API.Routes ...@@ -26,6 +26,12 @@ module Gargantext.API.Routes
import Control.Concurrent (threadDelay) import Control.Concurrent (threadDelay)
import Control.Lens (view) import Control.Lens (view)
import Data.Text (Text) import Data.Text (Text)
import Data.Aeson (Value)
import Data.Conduit (ConduitT)
import Servant.API.WebSocketConduit (WebSocketConduit, WebSocketSource)
import qualified Data.Conduit.List as CL
import Data.Validity import Data.Validity
import Gargantext.API.Admin.Auth.Types (AuthRequest, AuthResponse, AuthenticatedUser(..), PathId(..)) import Gargantext.API.Admin.Auth.Types (AuthRequest, AuthResponse, AuthenticatedUser(..), PathId(..))
import Gargantext.API.Admin.Auth (withAccess) import Gargantext.API.Admin.Auth (withAccess)
...@@ -168,6 +174,10 @@ type GargPrivateAPI' = ...@@ -168,6 +174,10 @@ type GargPrivateAPI' =
:> Capture "x" Int :> Capture "x" Int
:> WaitAPI -- Get '[JSON] Int :> WaitAPI -- Get '[JSON] Int
-} -}
:<|> "ws" :> Summary "WebSocket Test Route"
:> WebSocketConduit Value Value
-- /mv/<id>/<id> -- /mv/<id>/<id>
-- /merge/<id>/<id> -- /merge/<id>/<id>
-- /rename/<id> -- /rename/<id>
...@@ -239,7 +249,12 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid)) ...@@ -239,7 +249,12 @@ serverPrivateGargAPI' (AuthenticatedUser (NodeId uid))
-- :<|> New.info uid -- TODO-SECURITY -- :<|> New.info uid -- TODO-SECURITY
:<|> List.api :<|> List.api
-- :<|> waitAPI -- :<|> waitAPI
:<|> echo
-- FIXME which Monad type it is ?
-- echo :: ConduitT Value Value ?? ()
echo = CL.map identity
---------------------------------------------------------------------- ----------------------------------------------------------------------
-- For Tests -- For Tests
......
...@@ -90,7 +90,10 @@ fisWithSize n f is = case n of ...@@ -90,7 +90,10 @@ fisWithSize n f is = case n of
fisWith :: Maybe ([Item] -> Bool) -> Frequency -> [[Item]] -> [Fis] fisWith :: Maybe ([Item] -> Bool) -> Frequency -> [[Item]] -> [Fis]
fisWith s f is = case filter (not . null) is of fisWith s f is = case filter (not . null) is of
[] -> [] [] -> []
js -> catMaybes $ map items2fis $ filter' $ runLCMmatrix js f js -> catMaybes
$ map items2fis
$ filter'
$ runLCMmatrix js f
-- drop unMaybe -- drop unMaybe
where where
filter' = case s of filter' = case s of
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment