@cocreate/api 1.10.13 → 1.10.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/FUNDING.yml +3 -3
- package/.github/workflows/automated.yml +95 -95
- package/.github/workflows/manual.yml +44 -44
- package/CHANGELOG.md +1443 -1429
- package/CONTRIBUTING.md +96 -96
- package/CoCreate.config.js +26 -26
- package/LICENSE +660 -660
- package/README.md +85 -85
- package/demo/client.js +38 -38
- package/demo/index.html +60 -52
- package/docs/form.html +216 -216
- package/docs/index.html +241 -241
- package/docs/module.html +206 -206
- package/docs/server.html +217 -217
- package/package.json +9 -9
- package/release.config.js +21 -21
- package/src/client.js +189 -189
- package/src/index.js +13 -13
- package/src/server.js +108 -108
- package/webpack.config.js +84 -84
package/docs/form.html
CHANGED
|
@@ -1,216 +1,216 @@
|
|
|
1
|
-
<!DOCTYPE html>
|
|
2
|
-
<html lang="en">
|
|
3
|
-
|
|
4
|
-
<head>
|
|
5
|
-
<meta charset="utf-8">
|
|
6
|
-
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
|
-
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
|
-
<title>CoCreate-api form Documentation | CoCreateJS </title>
|
|
9
|
-
<link rel="icon" type="image/png" sizes="32x32" href="https://cocreate.app/images/favicon.ico">
|
|
10
|
-
<meta name="description" content="An api helper component in vanilla javascript to setup thirdparty api intergrations. Apis can be accessible using HTML5 attributes and/or JavaScript API" />
|
|
11
|
-
<meta name="keywords" content="drag and drop, colaboration, dnd utility, drag and drop utility" />
|
|
12
|
-
<meta name="robots" content="index,follow" />
|
|
13
|
-
<meta property="og:image" content="https://cdn.cocreate.app/docs/api.png">
|
|
14
|
-
<!-- CoCreate CSS -->
|
|
15
|
-
<!-- CoCreate CSS -->
|
|
16
|
-
<link rel="stylesheet" href="https://cdn.cocreate.app/latest/CoCreate.min.css" type="text/css" />
|
|
17
|
-
<link rel="stylesheet" href="/docs/index.css" collection="files" document_id="60888216117c640e7596303f" name="src" type="text/css" save="true" />
|
|
18
|
-
<link rel="manifest" href="/manifest.webmanifest" />
|
|
19
|
-
</head>
|
|
20
|
-
|
|
21
|
-
<body>
|
|
22
|
-
<nav class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px" content_id="content" scroll="sticky-nav,hide-nav" scroll-up="10" scroll-down="10" collection="files" document_id="60395ef42b3ac232657040fd" name="src">
|
|
23
|
-
</nav>
|
|
24
|
-
<sidenav id="menuL" class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl" resizable resize-target="[content_id='content']" resize-property="margin-left" resize-value="width">
|
|
25
|
-
<menu collection="files" document_id="603717b07de7fb350ae9fec8" name="src"></menu>
|
|
26
|
-
<div resize="right"></div>
|
|
27
|
-
</sidenav>
|
|
28
|
-
<main class="padding-top:15px padding:15px@lg@xl" content_id="content" id="CoCreate-api-form">
|
|
29
|
-
<div class="display:flex flex-wrap:wrap justify-content:space-between position:relative margin:10px">
|
|
30
|
-
<div class="display:flex align-items:center">
|
|
31
|
-
<h2>CoCreate-api form</h2>
|
|
32
|
-
</div>
|
|
33
|
-
<div class="display:flex align-items:center font-size:20px position:absolute right:0 padding:5px background:white">
|
|
34
|
-
<div class="display:flex align-items:center transition:0.3s padding-left:10px" share-network="true" share-text="An api helper component in vanilla javascript to setup thirdparty api intergrations. Apis can be accessible using HTML5 attributes and/or JavaScript API"
|
|
35
|
-
share-title="CoCreate API form" share-height="600" share-width="700" share-media="https://cdn.cocreate.app/docs/api.png" hover="display:block!important" hover-target=".social-networks">
|
|
36
|
-
<div class="display:none social-networks">
|
|
37
|
-
<a class="margin-right:15px" share-network=
|
|
38
|
-
<a class="margin-right:15px" share-network=
|
|
39
|
-
<a class="margin-right:15px" share-network=
|
|
40
|
-
</div>
|
|
41
|
-
<a class="margin-right:15px" share-network=
|
|
42
|
-
</div>
|
|
43
|
-
<a href="https://github.com/CoCreate-app/CoCreate-dnd" target="_blank" class=""><i class="height:20px fill:#505050" src="/assets/svg/github.svg"></i></a>
|
|
44
|
-
</div>
|
|
45
|
-
</div>
|
|
46
|
-
<h1 class="max-width:500px margin:20px_10px line-height:1.5 font-size:16px font-weight:100">CoCreate-api is a simple api helper component in vanilla javascript used by JavaScript developers to create thirdparty api intergrations. Thirdparty apis can be accessible using HTML5 attributes and/or JavaScript API. CoCreate-api includes the
|
|
47
|
-
client component and server side for api processing.</
|
|
48
|
-
<div id="api-section" class="display:flex flex-wrap:wrap">
|
|
49
|
-
<div class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px">
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
<div id="api-install" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#api-install-section">
|
|
53
|
-
<span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target=
|
|
54
|
-
<h2 class="padding:5px_0px">Install</h2>
|
|
55
|
-
<a class="margin-left:10px display:none" href="#api-install"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
|
|
56
|
-
</span>
|
|
57
|
-
</div>
|
|
58
|
-
|
|
59
|
-
<p class="padding:10px_0px line-height:1.5">
|
|
60
|
-
<pre><code class="language-bash">npm i @cocreate/api</code></pre>
|
|
61
|
-
</p>
|
|
62
|
-
<p class="padding:10px_0px line-height:1.5">Or you can use cdn link:</p>
|
|
63
|
-
<pre><code class="language-html"><script>https://cdn.cocreate.app/api/latest/CoCreate-api.min.js</script></code></pre>
|
|
64
|
-
|
|
65
|
-
<div>
|
|
66
|
-
<h2 id="api-server-run" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey padding:5px_0px">Server run</h2>
|
|
67
|
-
<a class="display:none" href="#api-server-run"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
|
|
68
|
-
</div>
|
|
69
|
-
<pre><code class="language-javascript">npm run start</code></pre>
|
|
70
|
-
|
|
71
|
-
<div>
|
|
72
|
-
<h2 id="api-dependencies" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Dependencies components</h2>
|
|
73
|
-
<a class="display:none" href="#api-dependencies"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
|
|
74
|
-
</div>
|
|
75
|
-
<p class="padding:10px_0px line-height:1.5">
|
|
76
|
-
<strong>CoCreate.js</strong>,
|
|
77
|
-
<strong>CoCreate-api.js</strong>,
|
|
78
|
-
</p>
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
<div>
|
|
82
|
-
<h2 id="api-development" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Development Guide</h2>
|
|
83
|
-
<a class="display:none" href="#api-development"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
|
|
84
|
-
</div>
|
|
85
|
-
|
|
86
|
-
<h3 class="margin-top:20px padding:5px_0px">1. Directory structure</h3>
|
|
87
|
-
<pre><code class="language-javascript">
|
|
88
|
-
|- server
|
|
89
|
-
|- apis
|
|
90
|
-
|- {module_name} //. module directory
|
|
91
|
-
CoCreate-{module_name}.js
|
|
92
|
-
|- ...
|
|
93
|
-
crud.js
|
|
94
|
-
index.js
|
|
95
|
-
WSManger.js
|
|
96
|
-
</code></pre>
|
|
97
|
-
<h3 class="margin-top:20px padding:5px_0px">2. Development stage</h3>
|
|
98
|
-
<h4>(1). Add the module direcotry into server/apis</h4>
|
|
99
|
-
<h4>(2). Create CoCreate-{module}.js from CoCreate-xxx.js template</h4>
|
|
100
|
-
<h4>(3). Register the module in crud.js</h4>
|
|
101
|
-
<pre><code class="language-javascript">
|
|
102
|
-
const CoCreateStripe = require('./apis/stripe/Cocreate-stripe')
|
|
103
|
-
module.exports.WSManager = function(manager) {
|
|
104
|
-
new CoCreate.stripe(manager) //. register
|
|
105
|
-
}
|
|
106
|
-
</code></pre>
|
|
107
|
-
<h4>(4). Rebuild CoCreate-{moudle}.js by endpoint and action</h4>
|
|
108
|
-
<pre><code class="language-javascript">
|
|
109
|
-
var utils= require('../utils');
|
|
110
|
-
class CoCreateStripe {
|
|
111
|
-
constructor(wsManager) {
|
|
112
|
-
this.module_id="stripe";
|
|
113
|
-
....
|
|
114
|
-
}
|
|
115
|
-
init() {
|
|
116
|
-
if (this.wsManager) {
|
|
117
|
-
//. endpoint = module_name (ex: stripe)
|
|
118
|
-
this.wsManager.on(this.module_id, (socket, data)
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
async sendStripe(socket, data) {
|
|
122
|
-
let type = data['type'];
|
|
123
|
-
switch (type) {
|
|
124
|
-
case 'CreateCustomer': //. action name
|
|
125
|
-
... Get result by processing
|
|
126
|
-
utils.send_response(this.wsManager, socket, {"type":type,"response":result}, this.module_id)
|
|
127
|
-
break;
|
|
128
|
-
....
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
}//end Class
|
|
132
|
-
module.exports = CoCreateStripe;
|
|
133
|
-
</code></pre>
|
|
134
|
-
|
|
135
|
-
<h3 class="margin-top:20px padding:5px_0px">3. Notes</h3>
|
|
136
|
-
<h4>(1). Response should be object that have <code class="language-js">type</code> and <code class="language-js">response</code> </h4>
|
|
137
|
-
<div class="padding-left:1rem">
|
|
138
|
-
<p><code class="language-js">type</code>: action name</p>
|
|
139
|
-
<p><code class="language-js">response</code>: result</p>
|
|
140
|
-
<pre><code class="language-javascript">{
|
|
141
|
-
type: action_name, //. string
|
|
142
|
-
response: result //. object or array
|
|
143
|
-
}
|
|
144
|
-
</code></pre>
|
|
145
|
-
</div>
|
|
146
|
-
<h4>(2). Endpoint and moudle_id is same</h4>
|
|
147
|
-
<h4>(3). Send response</h4>
|
|
148
|
-
<pre><code class="language-javascript">
|
|
149
|
-
utils.send_response(that.wsManager, socket, {"type":action_name,"response":result}, moudle_id)
|
|
150
|
-
</code></pre>
|
|
151
|
-
<h4>(4). Request data structure </h4>
|
|
152
|
-
<pre><code class="language-javascript">{
|
|
153
|
-
type: action_name, //. string
|
|
154
|
-
data: request_data //. object or array
|
|
155
|
-
}
|
|
156
|
-
</code></pre>
|
|
157
|
-
|
|
158
|
-
<h2 class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">How Does It Works</h2>
|
|
159
|
-
<p>CoCreate-api server module works based on cocreate.api. </p>
|
|
160
|
-
|
|
161
|
-
<p>xxxxxx <code class="language-js">action_{action_name}</code>. <code class="language-js">pre_{action_name}</code></p>
|
|
162
|
-
|
|
163
|
-
<h2 class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">Effects and Styles</h2>
|
|
164
|
-
|
|
165
|
-
<h2 class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">Events</h2>
|
|
166
|
-
<h4><span></span><span class="cocreate-badge success"></span></h4>
|
|
167
|
-
|
|
168
|
-
</div>
|
|
169
|
-
|
|
170
|
-
<div class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey">
|
|
171
|
-
|
|
172
|
-
<!-- SandBox -->
|
|
173
|
-
<div id="api-demo" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#api-demo-section">
|
|
174
|
-
<span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target=
|
|
175
|
-
<h2 class="padding:5px_0px">Demo</h2>
|
|
176
|
-
<a class="margin-left:10px display:none" href="#api-demo"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
|
|
177
|
-
</span>
|
|
178
|
-
</div>
|
|
179
|
-
|
|
180
|
-
<div class="position:sticky top:0 padding:15px_0px height:100vh">
|
|
181
|
-
<!-- SandBox -->
|
|
182
|
-
<div class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px" id="playground">
|
|
183
|
-
|
|
184
|
-
<div id="demo-code" resizable class="position:relative height:50%">
|
|
185
|
-
<textarea type="code" lang="html" collection="demos" document_id="" name="demo" save="false" id="demo" class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
|
|
186
|
-
<div resize="bottom" class="background:lightgrey"></div>
|
|
187
|
-
</div>
|
|
188
|
-
|
|
189
|
-
<div id="demo-preview" class="position:relative overflow:auto background-color:white">
|
|
190
|
-
<div class="demopreview
|
|
191
|
-
</div>
|
|
192
|
-
|
|
193
|
-
<div class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
|
|
194
|
-
<a class="margin-right:10px" id="eye" show="#eye-slash" hide="#eye, #demo-preview" toggle="code-height" toggle-target="#demo-code"><i class="height:18px fill:#505050" src="/assets/svg/eye.svg"></i></a>
|
|
195
|
-
<a class="margin-right:10px" hidden id="eye-slash" show="#eye, #demo-preview" hide="#eye-slash" toggle="code-height" toggle-target="#demo-code"><i class="height:20px fill:#505050" src="/assets/svg/eye-slash.svg"></i></a>
|
|
196
|
-
<a class="margin-right:10px" id="code" show="#code-slash" hide="#code, #demo-code"><i class="height:20px fill:#505050" src="/assets/svg/code.svg"></i></a>
|
|
197
|
-
<a class="margin-right:10px" hidden id="code-slash" show="#code, #demo-code" hide="#code-slash"><i class="display:flex height:18px fill:#505050" src="/assets/svg/code.svg"></i></a>
|
|
198
|
-
<a class="margin-right:5px" fullscreen fullscreen-target="#playground"></a>
|
|
199
|
-
</div>
|
|
200
|
-
|
|
201
|
-
</div>
|
|
202
|
-
<!-- End SandBox -->
|
|
203
|
-
</div>
|
|
204
|
-
</div>
|
|
205
|
-
</div>
|
|
206
|
-
<button href="https://github.com/CoCreate-app/CoCreate-api/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..." target="_blank" class="position:fixed bottom:15px right:15px padding:15px background:dodgerblue color:#fff font-size:1.5rem grow-hover border-radius:50% border-width:0 box-shadow:0px_2px_10px_0px_rgba(0,_0,_0,_0.4)">
|
|
207
|
-
<i class="height:20px fill:#505050" src="/assets/svg/pencil-alt.svg"></i>
|
|
208
|
-
</button>
|
|
209
|
-
</main>
|
|
210
|
-
|
|
211
|
-
<script src="./apikey.js"></script>
|
|
212
|
-
<script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
|
|
213
|
-
|
|
214
|
-
</body>
|
|
215
|
-
|
|
216
|
-
</html>
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html lang="en">
|
|
3
|
+
|
|
4
|
+
<head>
|
|
5
|
+
<meta charset="utf-8">
|
|
6
|
+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
7
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
8
|
+
<title>CoCreate-api form Documentation | CoCreateJS </title>
|
|
9
|
+
<link rel="icon" type="image/png" sizes="32x32" href="https://cocreate.app/images/favicon.ico">
|
|
10
|
+
<meta name="description" content="An api helper component in vanilla javascript to setup thirdparty api intergrations. Apis can be accessible using HTML5 attributes and/or JavaScript API" />
|
|
11
|
+
<meta name="keywords" content="drag and drop, colaboration, dnd utility, drag and drop utility" />
|
|
12
|
+
<meta name="robots" content="index,follow" />
|
|
13
|
+
<meta property="og:image" content="https://cdn.cocreate.app/docs/api.png">
|
|
14
|
+
<!-- CoCreate CSS -->
|
|
15
|
+
<!-- CoCreate CSS -->
|
|
16
|
+
<link rel="stylesheet" href="https://cdn.cocreate.app/latest/CoCreate.min.css" type="text/css" />
|
|
17
|
+
<link rel="stylesheet" href="/docs/index.css" collection="files" document_id="60888216117c640e7596303f" name="src" type="text/css" save="true" />
|
|
18
|
+
<link rel="manifest" href="/manifest.webmanifest" />
|
|
19
|
+
</head>
|
|
20
|
+
|
|
21
|
+
<body>
|
|
22
|
+
<nav class="nav display:flex align-items:center left:0px background:whitesmoke padding-top:10px padding-bottom:10px" content_id="content" scroll="sticky-nav,hide-nav" scroll-up="10" scroll-down="10" collection="files" document_id="60395ef42b3ac232657040fd" name="src">
|
|
23
|
+
</nav>
|
|
24
|
+
<sidenav id="menuL" class="position:fixed top:0px left:0px overflow:hidden background:whitesmoke height:100vh width:0px width:300px@xl" resizable resize-target="[content_id='content']" resize-property="margin-left" resize-value="width">
|
|
25
|
+
<menu collection="files" document_id="603717b07de7fb350ae9fec8" name="src"></menu>
|
|
26
|
+
<div resize="right"></div>
|
|
27
|
+
</sidenav>
|
|
28
|
+
<main class="padding-top:15px padding:15px@lg@xl" content_id="content" id="CoCreate-api-form">
|
|
29
|
+
<div class="display:flex flex-wrap:wrap justify-content:space-between position:relative margin:10px">
|
|
30
|
+
<div class="display:flex align-items:center">
|
|
31
|
+
<h2>CoCreate-api form</h2>
|
|
32
|
+
</div>
|
|
33
|
+
<div class="display:flex align-items:center font-size:20px position:absolute right:0 padding:5px background:white">
|
|
34
|
+
<div class="display:flex align-items:center transition:0.3s padding-left:10px" share-network="true" share-text="An api helper component in vanilla javascript to setup thirdparty api intergrations. Apis can be accessible using HTML5 attributes and/or JavaScript API"
|
|
35
|
+
share-title="CoCreate API form" share-height="600" share-width="700" share-media="https://cdn.cocreate.app/docs/api.png" hover="display:block!important" hover-target=".social-networks">
|
|
36
|
+
<div class="display:none social-networks">
|
|
37
|
+
<a class="margin-right:15px" share-network="twitter" title="Share on twitter"><i class="height:20px fill:#505050" src="/assets/svg/twitter.svg"></i></a>
|
|
38
|
+
<a class="margin-right:15px" share-network="facebook" title="Share on Facebook"><i class="height:20px fill:#505050" src="/assets/svg/facebook.svg"></i></a>
|
|
39
|
+
<a class="margin-right:15px" share-network="instagram" title="Share on instagram"><i class="height:20px fill:#505050" src="/assets/svg/instagram.svg"></i></a>
|
|
40
|
+
</div>
|
|
41
|
+
<a class="margin-right:15px" share-network="share" title="Share on share"><i class="height:20px fill:#505050" src="/assets/svg/share-alt.svg"></i></a>
|
|
42
|
+
</div>
|
|
43
|
+
<a href="https://github.com/CoCreate-app/CoCreate-dnd" target="_blank" class=""><i class="height:20px fill:#505050" src="/assets/svg/github.svg"></i></a>
|
|
44
|
+
</div>
|
|
45
|
+
</div>
|
|
46
|
+
<h1 class="max-width:500px margin:20px_10px line-height:1.5 font-size:16px font-weight:100">CoCreate-api is a simple api helper component in vanilla javascript used by JavaScript developers to create thirdparty api intergrations. Thirdparty apis can be accessible using HTML5 attributes and/or JavaScript API. CoCreate-api includes the
|
|
47
|
+
client component and server side for api processing.</h1>
|
|
48
|
+
<div id="api-section" class="display:flex flex-wrap:wrap">
|
|
49
|
+
<div class="flex-grow:1 width:400px width:300px@xs padding:0px_10px margin-top:60px">
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
<div id="api-install" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#api-install-section">
|
|
53
|
+
<span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target="[href='#api-install']">
|
|
54
|
+
<h2 class="padding:5px_0px">Install</h2>
|
|
55
|
+
<a class="margin-left:10px display:none" href="#api-install"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
|
|
56
|
+
</span>
|
|
57
|
+
</div>
|
|
58
|
+
|
|
59
|
+
<p class="padding:10px_0px line-height:1.5">
|
|
60
|
+
<pre><code class="language-bash">npm i @cocreate/api</code></pre>
|
|
61
|
+
</p>
|
|
62
|
+
<p class="padding:10px_0px line-height:1.5">Or you can use cdn link:</p>
|
|
63
|
+
<pre><code class="language-html"><script>https://cdn.cocreate.app/api/latest/CoCreate-api.min.js</script></code></pre>
|
|
64
|
+
|
|
65
|
+
<div>
|
|
66
|
+
<h2 id="api-server-run" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey padding:5px_0px">Server run</h2>
|
|
67
|
+
<a class="display:none" href="#api-server-run"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
|
|
68
|
+
</div>
|
|
69
|
+
<pre><code class="language-javascript">npm run start</code></pre>
|
|
70
|
+
|
|
71
|
+
<div>
|
|
72
|
+
<h2 id="api-dependencies" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Dependencies components</h2>
|
|
73
|
+
<a class="display:none" href="#api-dependencies"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
|
|
74
|
+
</div>
|
|
75
|
+
<p class="padding:10px_0px line-height:1.5">
|
|
76
|
+
<strong>CoCreate.js</strong>,
|
|
77
|
+
<strong>CoCreate-api.js</strong>,
|
|
78
|
+
</p>
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
<div>
|
|
82
|
+
<h2 id="api-development" hover="display:block" hover-target="" class="border-bottom:1px_solid_lightgrey margin-top:80px padding:5px_0px">Development Guide</h2>
|
|
83
|
+
<a class="display:none" href="#api-development"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
|
|
84
|
+
</div>
|
|
85
|
+
|
|
86
|
+
<h3 class="margin-top:20px padding:5px_0px">1. Directory structure</h3>
|
|
87
|
+
<pre><code class="language-javascript">
|
|
88
|
+
|- server
|
|
89
|
+
|- apis
|
|
90
|
+
|- {module_name} //. module directory
|
|
91
|
+
CoCreate-{module_name}.js
|
|
92
|
+
|- ...
|
|
93
|
+
crud.js
|
|
94
|
+
index.js
|
|
95
|
+
WSManger.js
|
|
96
|
+
</code></pre>
|
|
97
|
+
<h3 class="margin-top:20px padding:5px_0px">2. Development stage</h3>
|
|
98
|
+
<h4>(1). Add the module direcotry into server/apis</h4>
|
|
99
|
+
<h4>(2). Create CoCreate-{module}.js from CoCreate-xxx.js template</h4>
|
|
100
|
+
<h4>(3). Register the module in crud.js</h4>
|
|
101
|
+
<pre><code class="language-javascript">
|
|
102
|
+
const CoCreateStripe = require('./apis/stripe/Cocreate-stripe')
|
|
103
|
+
module.exports.WSManager = function(manager) {
|
|
104
|
+
new CoCreate.stripe(manager) //. register
|
|
105
|
+
}
|
|
106
|
+
</code></pre>
|
|
107
|
+
<h4>(4). Rebuild CoCreate-{moudle}.js by endpoint and action</h4>
|
|
108
|
+
<pre><code class="language-javascript">
|
|
109
|
+
var utils= require('../utils');
|
|
110
|
+
class CoCreateStripe {
|
|
111
|
+
constructor(wsManager) {
|
|
112
|
+
this.module_id="stripe";
|
|
113
|
+
....
|
|
114
|
+
}
|
|
115
|
+
init() {
|
|
116
|
+
if (this.wsManager) {
|
|
117
|
+
//. endpoint = module_name (ex: stripe)
|
|
118
|
+
this.wsManager.on(this.module_id, (socket, data) = this.sendStripe(socket, data));
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
async sendStripe(socket, data) {
|
|
122
|
+
let type = data['type'];
|
|
123
|
+
switch (type) {
|
|
124
|
+
case 'CreateCustomer': //. action name
|
|
125
|
+
... Get result by processing
|
|
126
|
+
utils.send_response(this.wsManager, socket, {"type":type,"response":result}, this.module_id)
|
|
127
|
+
break;
|
|
128
|
+
....
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
}//end Class
|
|
132
|
+
module.exports = CoCreateStripe;
|
|
133
|
+
</code></pre>
|
|
134
|
+
|
|
135
|
+
<h3 class="margin-top:20px padding:5px_0px">3. Notes</h3>
|
|
136
|
+
<h4>(1). Response should be object that have <code class="language-js">type</code> and <code class="language-js">response</code> </h4>
|
|
137
|
+
<div class="padding-left:1rem">
|
|
138
|
+
<p><code class="language-js">type</code>: action name</p>
|
|
139
|
+
<p><code class="language-js">response</code>: result</p>
|
|
140
|
+
<pre><code class="language-javascript">{
|
|
141
|
+
type: action_name, //. string
|
|
142
|
+
response: result //. object or array
|
|
143
|
+
}
|
|
144
|
+
</code></pre>
|
|
145
|
+
</div>
|
|
146
|
+
<h4>(2). Endpoint and moudle_id is same</h4>
|
|
147
|
+
<h4>(3). Send response</h4>
|
|
148
|
+
<pre><code class="language-javascript">
|
|
149
|
+
utils.send_response(that.wsManager, socket, {"type":action_name,"response":result}, moudle_id)
|
|
150
|
+
</code></pre>
|
|
151
|
+
<h4>(4). Request data structure </h4>
|
|
152
|
+
<pre><code class="language-javascript">{
|
|
153
|
+
type: action_name, //. string
|
|
154
|
+
data: request_data //. object or array
|
|
155
|
+
}
|
|
156
|
+
</code></pre>
|
|
157
|
+
|
|
158
|
+
<h2 class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">How Does It Works</h2>
|
|
159
|
+
<p>CoCreate-api server module works based on cocreate.api. </p>
|
|
160
|
+
|
|
161
|
+
<p>xxxxxx <code class="language-js">action_{action_name}</code>. <code class="language-js">pre_{action_name}</code></p>
|
|
162
|
+
|
|
163
|
+
<h2 class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">Effects and Styles</h2>
|
|
164
|
+
|
|
165
|
+
<h2 class="border-bottom:1px_solid_lightgrey margin-top:20px padding:5px_0px">Events</h2>
|
|
166
|
+
<h4><span></span><span class="cocreate-badge success"></span></h4>
|
|
167
|
+
|
|
168
|
+
</div>
|
|
169
|
+
|
|
170
|
+
<div class="flex-grow:1 width:300px padding:0px_10px margin-top:60px border-bottom:1px_solid_lightgrey">
|
|
171
|
+
|
|
172
|
+
<!-- SandBox -->
|
|
173
|
+
<div id="api-demo" class="border-bottom:1px_solid_lightgrey" scroll scroll-intersect="color:dodgerblue" scroll-target="#api-demo-section">
|
|
174
|
+
<span class="display:flex align-items:center width:fit-content" hover="display:block!important" hover-target="[href='#api-demo']">
|
|
175
|
+
<h2 class="padding:5px_0px">Demo</h2>
|
|
176
|
+
<a class="margin-left:10px display:none" href="#api-demo"><i class="height:20px fill:#505050" src="/assets/svg/link.svg"></i></a>
|
|
177
|
+
</span>
|
|
178
|
+
</div>
|
|
179
|
+
|
|
180
|
+
<div class="position:sticky top:0 padding:15px_0px height:100vh">
|
|
181
|
+
<!-- SandBox -->
|
|
182
|
+
<div class="display:flex flex-direction:column position:relative overflow:hidden card border-radius:2px width:auto height:600px margin-top:20px" id="playground">
|
|
183
|
+
|
|
184
|
+
<div id="demo-code" resizable class="position:relative height:50%">
|
|
185
|
+
<textarea type="code" lang="html" collection="demos" document_id="" name="demo" save="false" id="demo" class="height:100% width:100% outline:none border:none resize:none padding:5px"></textarea>
|
|
186
|
+
<div resize="bottom" class="background:lightgrey"></div>
|
|
187
|
+
</div>
|
|
188
|
+
|
|
189
|
+
<div id="demo-preview" class="position:relative overflow:auto background-color:white">
|
|
190
|
+
<div class="demopreview padding:20px"></div>
|
|
191
|
+
</div>
|
|
192
|
+
|
|
193
|
+
<div class="font-size:20px position:absolute top:10px right:10px opacity:0.6">
|
|
194
|
+
<a class="margin-right:10px" id="eye" show="#eye-slash" hide="#eye, #demo-preview" toggle="code-height" toggle-target="#demo-code"><i class="height:18px fill:#505050" src="/assets/svg/eye.svg"></i></a>
|
|
195
|
+
<a class="margin-right:10px" hidden id="eye-slash" show="#eye, #demo-preview" hide="#eye-slash" toggle="code-height" toggle-target="#demo-code"><i class="height:20px fill:#505050" src="/assets/svg/eye-slash.svg"></i></a>
|
|
196
|
+
<a class="margin-right:10px" id="code" show="#code-slash" hide="#code, #demo-code"><i class="height:20px fill:#505050" src="/assets/svg/code.svg"></i></a>
|
|
197
|
+
<a class="margin-right:10px" hidden id="code-slash" show="#code, #demo-code" hide="#code-slash"><i class="display:flex height:18px fill:#505050" src="/assets/svg/code.svg"></i></a>
|
|
198
|
+
<a class="margin-right:5px" fullscreen fullscreen-target="#playground"></a>
|
|
199
|
+
</div>
|
|
200
|
+
|
|
201
|
+
</div>
|
|
202
|
+
<!-- End SandBox -->
|
|
203
|
+
</div>
|
|
204
|
+
</div>
|
|
205
|
+
</div>
|
|
206
|
+
<button href="https://github.com/CoCreate-app/CoCreate-api/tree/master/docs/index.html?message=docs%3A%20describe%20your%20change..." target="_blank" class="position:fixed bottom:15px right:15px padding:15px background:dodgerblue color:#fff font-size:1.5rem grow-hover border-radius:50% border-width:0 box-shadow:0px_2px_10px_0px_rgba(0,_0,_0,_0.4)">
|
|
207
|
+
<i class="height:20px fill:#505050" src="/assets/svg/pencil-alt.svg"></i>
|
|
208
|
+
</button>
|
|
209
|
+
</main>
|
|
210
|
+
|
|
211
|
+
<script src="./apikey.js"></script>
|
|
212
|
+
<script src="https://cdn.cocreate.app/latest/CoCreate.min.js"></script>
|
|
213
|
+
|
|
214
|
+
</body>
|
|
215
|
+
|
|
216
|
+
</html>
|