Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
158
Issues
158
List
Board
Labels
Milestones
Merge Requests
11
Merge Requests
11
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
haskell-gargantext
Commits
ab2d8adb
Commit
ab2d8adb
authored
Mar 02, 2018
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[STATIC+SWAGGER+MOCK] startGargantextMock 8008
parent
69293cfc
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
39 additions
and
29 deletions
+39
-29
gargantext.cabal
gargantext.cabal
+2
-1
API.hs
src/Gargantext/API.hs
+33
-27
Node.hs
src/Gargantext/API/Node.hs
+4
-1
No files found.
gargantext.cabal
View file @
ab2d8adb
...
...
@@ -2,7 +2,7 @@
--
-- see: https://github.com/sol/hpack
--
-- hash: 4
0e4da714abaf501251279c2ed061b50ad5e31f7e99e84defabf222a04998a2e
-- hash: 4
e7c51f92304a8a22c00c60b641f336bcfa0c3994bd4beac6f2e9eafa90c408a
name: gargantext
version: 0.1.0.0
...
...
@@ -58,6 +58,7 @@ library
other-modules:
Gargantext.API.Count
Gargantext.API.Node
Gargantext.API.Swagger
Gargantext.Database.Queries
Gargantext.Utils
Paths_gargantext
...
...
src/Gargantext/API.hs
View file @
ab2d8adb
...
...
@@ -45,7 +45,7 @@ import Control.Lens
import
Data.Aeson.Encode.Pretty
(
encodePretty
)
import
qualified
Data.ByteString.Lazy.Char8
as
BL8
import
Data.Swagger
import
Data.Text
(
Text
)
import
Data.Text
(
Text
,
pack
)
--import qualified Data.Set as Set
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
...
...
@@ -54,14 +54,12 @@ import Network.Wai
import
Network.Wai.Handler.Warp
import
Servant
--
import Servant.Mock (mock)
import
Servant.Mock
(
mock
)
import
Servant.Swagger
import
Servant.Swagger.UI
import
Servant.Static.TH
(
createApiAndServerDecs
)
-- import Servant.API.Stream
-- import Gargantext.API.Auth
import
Gargantext.API.Node
(
Roots
,
roots
,
NodeAPI
,
nodeAPI
,
NodesAPI
,
nodesAPI
...
...
@@ -70,13 +68,8 @@ import Gargantext.API.Count ( CountAPI, count, Query)
import
Gargantext.Database.Utils
(
databaseParameters
)
---------------------------------------------------------------------
---------------------------------------------------------------------
type
PortNumber
=
Int
---------------------------------------------------------------------
---------------------------------------------------------------------
-- | API Global
...
...
@@ -116,26 +109,41 @@ type GargAPI = "user" :> Summary "First user endpoint"
-- | Serve front end files
$
(
createApiAndServerDecs
"FrontEndAPI"
"frontEndServer"
"frontEnd"
)
type
API
=
SwaggerAPI
:<|>
FrontEndAPI
:<|>
GargAPI
type
SwaggerFrontAPI
=
SwaggerAPI
:<|>
FrontEndAPI
type
API
=
SwaggerFrontAPI
:<|>
GargAPI
---------------------------------------------------------------------
-- | Server declaration
server
::
Connection
->
Server
API
server
conn
=
schemaUiServer
swaggerDoc
:<|>
frontEndServer
server
conn
=
swaggerFront
:<|>
roots
conn
:<|>
nodeAPI
conn
:<|>
nodeAPI
conn
:<|>
nodesAPI
conn
:<|>
count
---------------------------------------------------------------------
swaggerFront
::
Server
SwaggerFrontAPI
swaggerFront
=
schemaUiServer
swaggerDoc
:<|>
frontEndServer
gargMock
::
Server
GargAPI
gargMock
=
mock
apiGarg
Proxy
---------------------------------------------------------------------
app
::
Connection
->
Application
app
=
serve
api
.
server
appMock
::
Application
appMock
=
serve
api
(
swaggerFront
:<|>
gargMock
)
---------------------------------------------------------------------
api
::
Proxy
API
api
=
Proxy
apiGarg
::
Proxy
GargAPI
apiGarg
=
Proxy
---------------------------------------------------------------------
schemaUiServer
::
(
Server
api
~
Handler
Swagger
)
...
...
@@ -181,19 +189,17 @@ startGargantext port file = do
print
(
"http://localhost:"
<>
show
port
)
param
<-
databaseParameters
file
conn
<-
connect
param
run
port
(
app
conn
)
--
--startGargantextMock :: PortNumber -> IO ()
--startGargantextMock port = do
-- print (pack "Starting Mock server")
-- print (pack $ "curl "
-- <> "-H \"content-type: application/json"
-- <> "-d \'{\"query_query\":\"query\"}\' "
-- <> "-v http://localhost:"
-- <> show port
-- <>"/count"
-- )
-- run port ( serve api $ mock api Proxy )
run
port
(
app
conn
)
startGargantextMock
::
PortNumber
->
IO
()
startGargantextMock
port
=
do
print
(
pack
"Starting Mock server"
)
print
(
pack
$
"curl "
<>
"-H
\"
content-type: application/json"
<>
"-d
\'
{
\"
query_query
\"
:
\"
query
\"
}
\'
"
<>
"-v http://localhost:"
<>
show
port
<>
"/count"
)
run
port
appMock
src/Gargantext/API/Node.hs
View file @
ab2d8adb
...
...
@@ -49,6 +49,7 @@ import Gargantext.Database.Facet (FacetDoc, getDocFacet)
-- | Node API Types management
type
Roots
=
Get
'[
J
SON
]
[
Node
HyperdataDocument
]
:<|>
Post
'[
J
SON
]
Int
:<|>
Put
'[
J
SON
]
Int
:<|>
Delete
'[
J
SON
]
Int
type
NodesAPI
=
Delete
'[
J
SON
]
Int
...
...
@@ -56,7 +57,8 @@ type NodesAPI = Delete '[JSON] Int
type
NodeAPI
=
Get
'[
J
SON
]
(
Node
HyperdataDocument
)
:<|>
Delete
'[
J
SON
]
Int
:<|>
"children"
:>
QueryParam
"type"
NodeType
:<|>
"children"
:>
Summary
" Summary children"
:>
QueryParam
"type"
NodeType
:>
QueryParam
"offset"
Int
:>
QueryParam
"limit"
Int
:>
Get
'[
J
SON
]
[
Node
HyperdataDocument
]
...
...
@@ -83,6 +85,7 @@ roots :: Connection -> Server Roots
roots
conn
=
liftIO
(
putStrLn
"Log Needed"
>>
getNodesWithParentId
conn
0
Nothing
)
:<|>
pure
(
panic
"not implemented yet"
)
:<|>
pure
(
panic
"not implemented yet"
)
:<|>
pure
(
panic
"not implemented yet"
)
nodeAPI
::
Connection
->
NodeId
->
Server
NodeAPI
nodeAPI
conn
id
=
liftIO
(
putStrLn
"getNode"
>>
getNode
conn
id
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment