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
Hide 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 @@
...
@@ -2,7 +2,7 @@
--
--
-- see: https://github.com/sol/hpack
-- see: https://github.com/sol/hpack
--
--
-- hash: 4
0e4da714abaf501251279c2ed061b50ad5e31f7e99e84defabf222a04998a2e
-- hash: 4
e7c51f92304a8a22c00c60b641f336bcfa0c3994bd4beac6f2e9eafa90c408a
name: gargantext
name: gargantext
version: 0.1.0.0
version: 0.1.0.0
...
@@ -58,6 +58,7 @@ library
...
@@ -58,6 +58,7 @@ library
other-modules:
other-modules:
Gargantext.API.Count
Gargantext.API.Count
Gargantext.API.Node
Gargantext.API.Node
Gargantext.API.Swagger
Gargantext.Database.Queries
Gargantext.Database.Queries
Gargantext.Utils
Gargantext.Utils
Paths_gargantext
Paths_gargantext
...
...
src/Gargantext/API.hs
View file @
ab2d8adb
...
@@ -45,7 +45,7 @@ import Control.Lens
...
@@ -45,7 +45,7 @@ import Control.Lens
import
Data.Aeson.Encode.Pretty
(
encodePretty
)
import
Data.Aeson.Encode.Pretty
(
encodePretty
)
import
qualified
Data.ByteString.Lazy.Char8
as
BL8
import
qualified
Data.ByteString.Lazy.Char8
as
BL8
import
Data.Swagger
import
Data.Swagger
import
Data.Text
(
Text
)
import
Data.Text
(
Text
,
pack
)
--import qualified Data.Set as Set
--import qualified Data.Set as Set
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
import
Database.PostgreSQL.Simple
(
Connection
,
connect
)
...
@@ -54,14 +54,12 @@ import Network.Wai
...
@@ -54,14 +54,12 @@ import Network.Wai
import
Network.Wai.Handler.Warp
import
Network.Wai.Handler.Warp
import
Servant
import
Servant
--
import Servant.Mock (mock)
import
Servant.Mock
(
mock
)
import
Servant.Swagger
import
Servant.Swagger
import
Servant.Swagger.UI
import
Servant.Swagger.UI
import
Servant.Static.TH
(
createApiAndServerDecs
)
import
Servant.Static.TH
(
createApiAndServerDecs
)
-- import Servant.API.Stream
-- import Servant.API.Stream
-- import Gargantext.API.Auth
import
Gargantext.API.Node
(
Roots
,
roots
import
Gargantext.API.Node
(
Roots
,
roots
,
NodeAPI
,
nodeAPI
,
NodeAPI
,
nodeAPI
,
NodesAPI
,
nodesAPI
,
NodesAPI
,
nodesAPI
...
@@ -70,13 +68,8 @@ import Gargantext.API.Count ( CountAPI, count, Query)
...
@@ -70,13 +68,8 @@ import Gargantext.API.Count ( CountAPI, count, Query)
import
Gargantext.Database.Utils
(
databaseParameters
)
import
Gargantext.Database.Utils
(
databaseParameters
)
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
type
PortNumber
=
Int
type
PortNumber
=
Int
---------------------------------------------------------------------
---------------------------------------------------------------------
---------------------------------------------------------------------
-- | API Global
-- | API Global
...
@@ -116,26 +109,41 @@ type GargAPI = "user" :> Summary "First user endpoint"
...
@@ -116,26 +109,41 @@ type GargAPI = "user" :> Summary "First user endpoint"
-- | Serve front end files
-- | Serve front end files
$
(
createApiAndServerDecs
"FrontEndAPI"
"frontEndServer"
"frontEnd"
)
$
(
createApiAndServerDecs
"FrontEndAPI"
"frontEndServer"
"frontEnd"
)
type
API
=
SwaggerAPI
:<|>
FrontEndAPI
:<|>
GargAPI
type
SwaggerFrontAPI
=
SwaggerAPI
:<|>
FrontEndAPI
type
API
=
SwaggerFrontAPI
:<|>
GargAPI
---------------------------------------------------------------------
---------------------------------------------------------------------
-- | Server declaration
-- | Server declaration
server
::
Connection
->
Server
API
server
::
Connection
->
Server
API
server
conn
=
schemaUiServer
swaggerDoc
server
conn
=
swaggerFront
:<|>
frontEndServer
:<|>
roots
conn
:<|>
roots
conn
:<|>
nodeAPI
conn
:<|>
nodeAPI
conn
:<|>
nodeAPI
conn
:<|>
nodeAPI
conn
:<|>
nodesAPI
conn
:<|>
nodesAPI
conn
:<|>
count
:<|>
count
---------------------------------------------------------------------
swaggerFront
::
Server
SwaggerFrontAPI
swaggerFront
=
schemaUiServer
swaggerDoc
:<|>
frontEndServer
gargMock
::
Server
GargAPI
gargMock
=
mock
apiGarg
Proxy
---------------------------------------------------------------------
---------------------------------------------------------------------
app
::
Connection
->
Application
app
::
Connection
->
Application
app
=
serve
api
.
server
app
=
serve
api
.
server
appMock
::
Application
appMock
=
serve
api
(
swaggerFront
:<|>
gargMock
)
---------------------------------------------------------------------
api
::
Proxy
API
api
::
Proxy
API
api
=
Proxy
api
=
Proxy
apiGarg
::
Proxy
GargAPI
apiGarg
=
Proxy
---------------------------------------------------------------------
---------------------------------------------------------------------
schemaUiServer
::
(
Server
api
~
Handler
Swagger
)
schemaUiServer
::
(
Server
api
~
Handler
Swagger
)
...
@@ -181,19 +189,17 @@ startGargantext port file = do
...
@@ -181,19 +189,17 @@ startGargantext port file = do
print
(
"http://localhost:"
<>
show
port
)
print
(
"http://localhost:"
<>
show
port
)
param
<-
databaseParameters
file
param
<-
databaseParameters
file
conn
<-
connect
param
conn
<-
connect
param
run
port
(
app
conn
)
run
port
(
app
conn
)
--
--startGargantextMock :: PortNumber -> IO ()
startGargantextMock
::
PortNumber
->
IO
()
--startGargantextMock port = do
startGargantextMock
port
=
do
-- print (pack "Starting Mock server")
print
(
pack
"Starting Mock server"
)
-- print (pack $ "curl "
print
(
pack
$
"curl "
-- <> "-H \"content-type: application/json"
<>
"-H
\"
content-type: application/json"
-- <> "-d \'{\"query_query\":\"query\"}\' "
<>
"-d
\'
{
\"
query_query
\"
:
\"
query
\"
}
\'
"
-- <> "-v http://localhost:"
<>
"-v http://localhost:"
-- <> show port
<>
show
port
-- <>"/count"
<>
"/count"
-- )
)
-- run port ( serve api $ mock api Proxy )
run
port
appMock
src/Gargantext/API/Node.hs
View file @
ab2d8adb
...
@@ -49,6 +49,7 @@ import Gargantext.Database.Facet (FacetDoc, getDocFacet)
...
@@ -49,6 +49,7 @@ import Gargantext.Database.Facet (FacetDoc, getDocFacet)
-- | Node API Types management
-- | Node API Types management
type
Roots
=
Get
'[
J
SON
]
[
Node
HyperdataDocument
]
type
Roots
=
Get
'[
J
SON
]
[
Node
HyperdataDocument
]
:<|>
Post
'[
J
SON
]
Int
:<|>
Post
'[
J
SON
]
Int
:<|>
Put
'[
J
SON
]
Int
:<|>
Delete
'[
J
SON
]
Int
:<|>
Delete
'[
J
SON
]
Int
type
NodesAPI
=
Delete
'[
J
SON
]
Int
type
NodesAPI
=
Delete
'[
J
SON
]
Int
...
@@ -56,7 +57,8 @@ type NodesAPI = Delete '[JSON] Int
...
@@ -56,7 +57,8 @@ type NodesAPI = Delete '[JSON] Int
type
NodeAPI
=
Get
'[
J
SON
]
(
Node
HyperdataDocument
)
type
NodeAPI
=
Get
'[
J
SON
]
(
Node
HyperdataDocument
)
:<|>
Delete
'[
J
SON
]
Int
:<|>
Delete
'[
J
SON
]
Int
:<|>
"children"
:>
QueryParam
"type"
NodeType
:<|>
"children"
:>
Summary
" Summary children"
:>
QueryParam
"type"
NodeType
:>
QueryParam
"offset"
Int
:>
QueryParam
"offset"
Int
:>
QueryParam
"limit"
Int
:>
QueryParam
"limit"
Int
:>
Get
'[
J
SON
]
[
Node
HyperdataDocument
]
:>
Get
'[
J
SON
]
[
Node
HyperdataDocument
]
...
@@ -83,6 +85,7 @@ roots :: Connection -> Server Roots
...
@@ -83,6 +85,7 @@ roots :: Connection -> Server Roots
roots
conn
=
liftIO
(
putStrLn
"Log Needed"
>>
getNodesWithParentId
conn
0
Nothing
)
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"
)
:<|>
pure
(
panic
"not implemented yet"
)
:<|>
pure
(
panic
"not implemented yet"
)
nodeAPI
::
Connection
->
NodeId
->
Server
NodeAPI
nodeAPI
::
Connection
->
NodeId
->
Server
NodeAPI
nodeAPI
conn
id
=
liftIO
(
putStrLn
"getNode"
>>
getNode
conn
id
)
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