-
Notifications
You must be signed in to change notification settings - Fork 22
/
index.html
214 lines (207 loc) · 9.76 KB
/
index.html
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta name="description" content="" />
<meta name="author" content="Maxim Sokhatsky" />
<title>REST</title>
<link rel="stylesheet" href="https://n2o.dev/blank.css" />
<link rel="stylesheet" href="https://n2o.dev/zima.css" />
</head>
<body>
<nav>
<a href="https://n2o.dev">DEV</a>
<a href="#" style="background:#ededed;">REST</a>
<a href="https://n2o.dev/deps/rest/man/ua/index.html">UA</a>
<a href="#" style="background:#ededed;">EN</a>
</nav>
<header>
<a href="https://github.com/synrc/rest"><img src="https://openmoji.org/data/color/svg/2615.svg" /></a>
<h1>REST</h1>
</header>
<aside>
<article>
<section>
<h3>SYNOPSIS</h3>
<div>REST is a framework with typed JSON. Features and Goals:
<ul><li>Fastest possible Record <-> Proplists transformations</li>
<li>Smallest REST framework in the world (3 files drop).</li>
<li>ETS/KVS/Any storage selection by scaffolding</li></ul>
We've achived first goal by providing parse_transform code generation for tuple transformations.
And second requirement was achieved by not including routing bullshit and other uncertain features.
</div>
</section>
<section>
<a name="usage"></a><h3>USAGE</h3>
<div>Just plug REST endpoint directly to your Cowboy router in order
to gain the JSON access for both in-memory ETS and persistent
KVS databases:</div><br/>
<figure>
<code> {"/:res",rest_cowboy,[]},
{"/:res/:id",rest_cowboy,[]},
{"/kvs/0/[...]",rest_kvs,[]},
{"/kvs/1/:id/[...]",rest_kvs,[]},</code>
</figure><br/>
<div>
NOV 2021 © <a href="https://github.com/5HT">5HT</a> <a href="https://5ht.co/license.htm">ISC</a><br/>
VER 6.11 6.1 5.10
</div>
</section>
</article>
</aside>
<main>
<section>
<a name="ets"></a><h3>ETS JSON</h3>
<p>Simple table-oriented service implementation:</p>
<figure>
<code>
-module(users).
-behaviour(rest).
-compile({parse_transform, rest}).
-include("users.hrl").
-export([init/0, populate/1, exists/1, get/0, get/1, post/1, delete/1]).
-rest_record(user).
init() -> ets:new(users, [public, named_table, {keypos, #user.id}]).
populate(Users) -> ets:insert(users, Users).
exists(Id) -> ets:member(users, wf:to_list(Id)).
get() -> ets:tab2list(users).
get(Id) -> [User] = ets:lookup(users, wf:to_list(Id)), User.
delete(Id) -> ets:delete(users, wf:to_list(Id)).
post(#user{} = User) -> ets:insert(users, User);
post(Data) -> post(from_json(Data, #user{})).
</code>
</figure>
</section>
<section>
<h3>METHODS</h3>
<figure><code>
$ curl -i -X POST -d "id=vlad" localhost:8005/rest/users
$ curl -i -X POST -d "id=doxtop" localhost:8005/rest/users
$ curl -i -X GET localhost:8005/rest/users
$ curl -i -X PUT -d "id=5HT" localhost:8005/rest/users/vlad
$ curl -i -X GET localhost:8005/rest/users/5HT
$ curl -i -X DELETE localhost:8005/rest/users/5HT
</code></figure>
</section>
<section>
<a name="kvs"></a><h3>KVS JSON</h3>
<p>Automatiс chain-oriented API service implementation. Plug your Erlang HRL schema to
<b>mix.exs</b></p>
<figure><code>
{:bpe, "~> 4.9.18"},
{:erp, "~> 0.10.3"},
</code></figure>
<p>or <b>rebar.config</b>:</p>
<figure><code>
{bpe, ".*", {git, "git://github.com/synrc/bpe", {tag,"master"}}},
{erp, ".*", {git, "git://github.com/erpuno/erp", {tag,"master"}}},
</code></figure>
</section>
<section>
<a name="kvs"></a><h3>ERP JSON</h3>
<p>Retrieve ERP organizational structure:</p>
<figure><code>
$ curl -X GET http://localhost:8005/rest/kvs/0/erp/group
{"\/erp\/group":[{"name":"Quanterall","url":"quanterall.com",
"location":[],"type":[]}]}
</code></figure>
<p>Retrive all invoice payments for Stamp project of FinaTech company:</p>
<figure><code>
$ curl -X GET http://localhost:8005/rest/kvs/0/plm/FinaTech-Stamps/income
{"\/plm\/FinaTech-Stamps\/income":[{"invoice":"APR-2018-PAY-FTST","account":[],
"subaccount":[],"volume":{"fraction":0,"digits":12000},"price":{"fraction":0,
"digits":1},"instrument":"USD","type":"crypto","from":[],"to":[]},{"invoice":
"AUG-2018-PAY-FTST","account":[],"subaccount":[],"volume":{"fraction":0,
"digits":12000},"price":{"fraction":0,"digits":1},"instrument":"USD","type":
"crypto","from":[],"to":[]},{"invoice":"FEB-2018-PAY-FTST","account":[],
"subaccount":[],"volume":{"fraction":0,"digits":7000},"price":{"fraction":0,
"digits":1},"instrument":"USD","type":"crypto","from":[],"to":[]},{"invoice":
"JAN-2018-PAY-FTST","account":[],"subaccount":[],"volume":{"fraction":0,"digits":
5000},"price":{"fraction":0,"digits":1},"instrument":"USD","type":"crypto","from":
[],"to":[]},{"invoice":"JUL-2018-PAY-FTST","account":[],"subaccount":[],"volume":
{"fraction":0,"digits":10000},"price":{"fraction":0,"digits":1},"instrument":
"USD","type":"crypto","from":[],"to":[]},{"invoice":"JUN-2018-PAY-FTST",
"account":[],"subaccount":[],"volume":{"fraction":0,"digits":10000},"price":
{"fraction":0,"digits":1},"instrument":"USD","type":"crypto","from":[],"to":[]},
{"invoice":"MAR-2018-PAY-FTST","account":[],"subaccount":[],"volume":
{"fraction":0,"digits":10000},"price":{"fraction":0,"digits":1},"instrument":
"USD","type":"crypto","from":[],"to":[]},{"invoice":"MAY-2018-PAY-FTST",
"account":[],"subaccount":[],"volume":{"fraction":0,"digits":15000},
"price":{"fraction":0,"digits":1},"instrument":"USD","type":"crypto",
"from":[],"to":[]},{"invoice":"SEP-2018-PAY-FTST","account":[],"subaccount":
[],"volume":{"fraction":0,"digits":15000},"price":{"fraction":0,"digits":1},
"instrument":"USD","type":"crypto","from":[],"to":[]}]}
</code></figure>
</section>
<section>
<a name="kvs"></a><h3>BPE JSON</h3>
<p>Retrieve All History from Process 288117946539000:</p>
<figure><code>
curl -X GET http://localhost:8005/rest/kvs/0/bpe/hist/288117946539000
{"\/bpe\/hist\/288117946539000":[{"id":{"id":0,"proc":"288117946539000"},
"container":"feed","feed_id":[],"prev":[],"next":[],"name":[],"task":"Created",
"docs":[],"time":{"time":"{{2019,10,5},{21,21,44}}"}},{"id":{"id":1,"proc":
"288117946539000"},"container":"feed","feed_id":[],"prev":[],"next":[],
"name":[],"task":"Init","docs":[],"time":{"time":"{{2019,10,5},{21,21,50}}"}},
{"id":{"id":2,"proc":"288117946539000"},"container":"feed","feed_id":[],
"prev":[],"next":[],"name":[],"task":"Upload","docs":[],"time":{"time":
"{{2019,10,5},{21,21,51}}"}},{"id":{"id":3,"proc":"288117946539000"},
"container":"feed","feed_id":[],"prev":[],"next":[],"name":[],"task":
"Payment","docs":[],"time":{"time":"{{2019,10,5},{21,21,51}}"}}]}
</code></figure>
<p>Retrieve Step 2 from process 288117946539000:</p>
<figure><code>
curl -X GET localhost:8005/rest/kvs/1/step,0,288117946539000/bpe/hist/288117946539000
{"id":{"id":2,"proc":"288117946539000"},"container":"feed","feed_id":[],
"prev":[],"next":[],"name":[],"task":"Upload","docs":[],"time":
{"time":"{{2019,10,5},{21,21,51}}"}}
</code></figure>
<p>Retrieve all processes:</p>
<figure><code>
$ curl -X GET http://localhost:8005/rest/kvs/0/bpe/proc
{"\/bpe\/proc":[{"id":"288117946539000","container":"feed","feed_id":[],
"prev":[],"next":[],"name":"IBAN Account","feeds":[],"roles":[],"tasks":
[{"name":"Created","module":"bpe_account","prompt":[],"etc":[]},{"name":
"Init","module":"bpe_account","prompt":[],"roles":[],"etc":[]},{"name":
"Upload","module":"bpe_account","prompt":[],"roles":[],"etc":[]},{"name":
"Signatory","module":"bpe_account","prompt":[],"roles":[],"etc":[]},{"name":
"Payment","module":"bpe_account","prompt":[],"roles":[],"etc":[]},{"name":
"Process","module":"bpe_account","prompt":[],"roles":[],"etc":[]},{"name":
"Final","module":"bpe_account","prompt":[],"etc":[]}],"events":[{"name":
"PaymentReceived","module":[],"prompt":[],"etc":[],"payload":[],"timeout":[]},
{"name":"*","module":[],"prompt":[],"etc":[],"payload":[],"timeout":
{"spec":"{0,{10,0,10}}"},"timeDate":[],"timeDuration":[],"timeCycle":[]}],
"hist":[],"flows":[{"name":[],"condition":[],"source":"Created","target":
"Init"},{"name":[],"condition":[],"source":"Init","target":"Upload"},
{"name":[],"condition":[],"source":"Upload","target":"Payment"},
{"name":[],"condition":[],"source":"Payment","target":["Signatory",
"Process"]},{"name":[],"condition":[],"source":"Process","target":
["Process","Final"]},{"name":[],"condition":[],"source":"Signatory",
"target":["Process","Final"]}],"rules":[],"docs":[],"options":[],
"task":"Created","timer":[],"notifications":"undefined","result":[],
"started":{"time":"{{2019,10,5},{22,5,20}}"},"beginEvent":"Created",
"endEvent":"Final"}]}
</code></figure>
</section>
<section>
<h3>MODULES</h3>
<p>Module <b>rest</b> is an Erlang/OTP application, while
<b>rest_cowboy</b> and <b>rest_kvs</b> are the access/routing/gate/plugin-modules
to other systems.</p>
<ul><li><b><a href="man/rest.htm">rest</a></b> — rest</li>
<li><b><a href="man/rest_cowboy.htm">rest_cowboy</a></b> — rest_cowboy</li>
<li><b><a href="man/rest_kvs.htm">rest_kvs</a></b> — rest_kvs</li></ul>
</section>
<section>
<a name="credits"></a><h3>CREDTIS</h3>
<ul><li>Dmitry Bushmelev</li>
<li>Maxim Sokhatsky</li></ul>
</section>
</main>
<footer>
Made with <span class="heart">❤</span> to Erlang
</footer>
</body>
</html>