-
Notifications
You must be signed in to change notification settings - Fork 3
/
bus.yaml
115 lines (111 loc) · 2.65 KB
/
bus.yaml
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
id: nanoblog
version: 0.0.1
spec: apex.axdl
initializers:
blogdb:
uses: nanobus.migrate.postgres/v1
with:
dataSource: "${env:BLOG_DB}"
directory: migrations/
authorization:
blogs.v1.Blogs:
postBlog:
unauthenticated: true
getFeed:
unauthenticated: true
getBlog:
unauthenticated: true
deleteBlog:
unauthenticated: true
transports:
http:
uses: nanobus.transport.http.server/v1
with:
address: ":8080"
middleware:
- uses: nanobus.transport.http.cors/v0
with:
allowedMethods:
- HEAD
- GET
- POST
- PUT
- PATCH
- DELETE
allowCredentials: true
routers:
- uses: nanobus.transport.http.rest/v1
with:
documentation:
swaggerUI: true
postman: true
restClient: true
interfaces:
blogs.v1.Blogs:
postBlog:
steps:
- name: Post a blog
uses: "@postgres/query_one"
with:
resource: blogdb
sql: |-
INSERT INTO blog (user_id, title, body, time)
VALUES ($1, $2, $3, now())
RETURNING *
args:
- input.userId
- input.title
- input.body
getFeed:
steps:
- name: Get blog timeline for multiple users
uses: "@postgres/query"
with:
resource: blogdb
sql: |-
SELECT * FROM blog
WHERE (time < $1 OR $1 IS NULL)
ORDER BY time DESC
LIMIT $2
args:
- input.before
- input.limit
getBlog:
steps:
- name: Get a single blog
uses: "@postgres/query_one"
with:
resource: blogdb
sql: |-
SELECT * FROM blog
WHERE id = $1
args:
- input.id
deleteBlog:
steps:
- name: Remove a blog post
uses: "@postgres/query_one"
with:
resource: blogdb
sql: |-
DELETE FROM blog
WHERE id = $1
AND user_id = $2
RETURNING *
args:
- input.id
- input.userId
editBlog:
steps:
- name: Edit a blog post
uses: "@postgres/query_one"
with:
resource: blogdb
sql: |-
UPDATE blog
SET body = $2
WHERE id = $1
RETURNING *
args:
- input.id
- input.body