-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.fbp
116 lines (95 loc) · 3.77 KB
/
app.fbp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
title: Chiχ Flow Server
description: A rest server for flows
Db(mongojs/db), Close(mongojs/close), Log(console/log)
ParseFlowSchema(json/parse), FlowSchema(json/createSchema)
ParseNodeSchema(json/parse), NodeSchema(json/createSchema)
# Collections
FlowCollection(mongojs/collection)
'twigs' -> @collection FlowCollection
Db db -> ^db FlowCollection
NodesCollection(mongojs/collection)
'nodes' -> @collection NodesCollection
Db db -> ^db NodesCollection
# Express
Express(express/app), Listen(express/listen)
BodyParser(express/bodyParser)
CORS(express/cors)
'' -> :start Express
# Stuff like this you do not do in .fbp
# It can be done with an integrating layer?
# Let's only do the main stuff in .fbp
# It's not part of the main functionality.
# Which also defines how to do client side.
# You create flows of functionality, then integrate those.
# Reporting is part of decoration.
# 'Server listening on port %s' -> [0] in ListenMsg(string/sprintf)
# '5000' -> [1] in ListenMsg
# Configure the port to listen on
'5000' -> port Listen
Express app -> app Listen
# Sub Flows
provider ./graphs/{ns}/{name}.fbp as x
GetAll(x:rest/getAll)
GetById(x:rest/getByParam)
PutFlow(x:rest/put)
PostFlow(x:rest/post)
DeleteFlow(x:rest/delete)
GetNodes(x:rest/getNodes)
FindFlows(x:rest/findFlows)
FindNodes(x:rest/find)
# Rather weird construction, more correct this flow
# would handle the stream itself.
Express app -> app BodyParser
Express express -> express BodyParser
Express app -> app CORS
Express express -> express CORS
# Db Setup
'serve' -> connection_string Db
# Setup flow schema, used for validation
'schema.json' ~> in ParseFlowSchema
'node.json' ~> in ParseNodeSchema
ParseFlowSchema out -> in FlowSchema
ParseNodeSchema out -> in NodeSchema
# Serve /flows
'/flows' -> ^path GetAll
Express app -> ^app GetAll
FlowCollection collection -> ^collection GetAll
# Serve /find/flows
'/find/flows' -> path FindFlows
Express app -> ^app FindFlows
#FlowSchema out -> ^schema FindFlows
FlowCollection collection -> ^collection FindFlows
# Serve /find/nodes
'/find/nodes' -> path FindNodes
Express app -> ^app FindNodes
#NodeSchema out -> ^schema FindNodes
NodesCollection collection -> ^collection FindNodes
# Serve /flows/:id
'/flows/:id' -> path GetById
Express app -> ^app GetById
FlowCollection collection -> ^collection GetById
# Serve PUT /flows
'/flows' -> path PutFlow
Express app -> ^app PutFlow
["id"] -> ^pick PutFlow
FlowSchema out -> ^schema PutFlow
FlowCollection collection -> ^collection PutFlow
# Serve POST /flows, ok this just takes the full document
# It should use pick just like put is doing..
'/flows' -> path PostFlow
Express app -> ^app PostFlow
FlowSchema out -> ^schema PostFlow
FlowCollection collection -> ^collection PostFlow
# Serve Delete /flows, should also use pick for id..
# The nice thing is we can use the route param for that.
# so the route determines what we select to delete by.
# hmz, /flows/:id with a put it would be nice if it then just
# picks the :id from the post. I guess middleware could do that.
'/flows' -> path DeleteFlow
Express app -> ^app DeleteFlow
FlowCollection collection -> ^collection DeleteFlow
# Serve /nodes
'/nodes' -> path GetNodes
Express app -> ^app GetNodes
NodesCollection collection -> ^collection GetNodes
#Db db -> ^db Close