Skip to content

Commit 4d052e8

Browse files
committed
Release v2.1.1
1 parent 4265e99 commit 4d052e8

21 files changed

+3083
-1112
lines changed

bin/server

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ nconf.file ({file: IotronicHome + '/settings.json'});
2929

3030
var wampR_url = nconf.get('config:wamp:url')+":"+nconf.get('config:wamp:port');
3131
var wamp_realm = nconf.get('config:wamp:realm');
32-
console.log(wampR_url);
32+
//console.log(wampR_url);
3333

3434
var server = new iotronic.server;
3535
server.start(wampR_url, wamp_realm);

docs/installation_ubuntu_14.04.md

Lines changed: 86 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ if you would like to use HTTPS to expose them you have to specify the "https" se
148148
```
149149
"db":{
150150
"host":"localhost",
151+
"port":3306,
151152
"user":"root",
152153
"password":"<MYSQL-PASSWORD>",
153154
"db_name": "s4t-iotronic"
@@ -160,9 +161,13 @@ if you would like to use HTTPS to expose them you have to specify the "https" se
160161
"email": {
161162
"address": "<SENDER-EMAIL>",
162163
"password": "<SENDER-PASSWORD-EMAIL>"
164+
"smtp":{
165+
"smtp_server": "<SMTP-MAIL-SERVER>"",
166+
"smtp_port": "<SMTP-PORT>"",
167+
"smtp_secure": "[ true | false ]"
168+
}
163169
},
164170
"enable_notify":"[ true | false ]",
165-
"retry":<ATTEMPTS-NUMBER>
166171
}
167172
```
168173

@@ -177,7 +182,7 @@ node /usr/lib/node_modules/@mdslab/iotronic-standalone/utils/createAdminToken.js
177182
"encryptKey": "<ENC-KEY>",
178183
"adminToken": "<GENERATED-BEFORE>",
179184
"backend": "iotronic",
180-
"expire_time": 60
185+
"expire_time": "30m"
181186
}
182187
```
183188
The "encryptKey" field is a user-defined keyword/password used to encrypt/decrypt the users passwords during authentication procedures.
@@ -244,57 +249,115 @@ RESPONSE:
244249

245250

246251
## API documentation management
247-
IoTronic releases its APIs documentation by means of Swagger framework. In particular we used ["swagger-jsdoc"](https://www.npmjs.com/package/swagger-jsdoc) and ["swagger-ui"](https://swagger.io/swagger-ui/) respectively to describe each RESTful API in the source code and publish the produced documentation.
252+
IoTronic releases its APIs documentation by means of Swagger framework. In particular we used ["swagger-jsdoc"](https://www.npmjs.com/package/swagger-jsdoc) and ["swagger-ui"](https://swagger.io/swagger-ui/)
253+
respectively to describe each RESTful API in the source code and publish the produced documentation.
248254

249-
To use swagger-ui we need to clone the git repository from [here](https://github.com/swagger-api/swagger-ui)
250-
and move the "dist" folder where you prefer and specify it inside the "settings.json" configuration file
251-
as showed below:
255+
Iotronic is able to expose the documentation:
256+
1. embedded mode: generate and expose runtime the API documentation
257+
2. exposed mode: only specify the URLs of the web-server that is exposing the documentation
252258

259+
In both cases we need to get the "swagger-ui" cloning the git repository from [here](https://github.com/swagger-api/swagger-ui)
260+
and rename the "dist/" folder in "iotronic-api-docs/".
261+
262+
#### 1. Embedded mode
253263
```
254264
"docs": {
255-
"enable": [ true | false ],
256-
"path": "<SWAGGER-DIST-PATH>"
265+
266+
"embedded":{
267+
"enable": true,
268+
"path": "<SWAGGER-DIST-PATH>"
269+
},
270+
"exposed":{
271+
"enable": false,
272+
"url":"",
273+
"url_spec":""
274+
}
257275
258276
}
277+
259278
```
279+
We have to move the "iotronic-api-docs/" folder in the "/var/lib/iotronic/docs/" and we need to specify it inside the
280+
"settings.json" configuration file, as showed above, in the "path" section substituting "<SWAGGER-DIST-PATH>" variable
281+
and setting to "true" the "enable" flag in the "embedded" section.
260282

261-
You have to edit the "index.html" in <SWAGGER-DIST-PATH> as described in the [official guide](https://swagger.io/docs/swagger-tools/#download-33):
283+
The API documentation will be available at:
262284
```
263-
window.swaggerUi = new SwaggerUi({
264-
url: <URL-SWAGGER-JSON>,
265-
266-
});
285+
http(s)://<IOTRONIC-IP>:<HTTP(S)-API-PORT>/v1/iotronic-api-docs/ (<URL-API-DOCS>)
267286
```
268-
where
287+
and the location of the Swagger JSON file will be:
269288
```
270-
<URL-SWAGGER-JSON> = http(s)://<IOTRONIC-IP>:<HTTP(S)-API-PORT>/<SWAGGER-JSON-LOCATION>/iotronic-swagger.json
289+
http(s)://<IOTRONIC-IP>:<HTTP(S)-API-PORT>/v1/iotronic-swagger.json (<URL-SWAGGER-JSON>)
271290
```
272291

273-
[Link to Official guide](https://swagger.io/docs/swagger-tools/#download-33)
274292

275-
#### Embedded API management
276-
Enabling the above flag ("enable":true) IoTronic will generate end expose the API documentation.
293+
#### 2. Exposed mode
294+
```
295+
"docs": {
277296
278-
The docs will be available at:
297+
"embedded":{
298+
"enable": false,
299+
"path": "<SWAGGER-DIST-PATH>"
300+
},
301+
"exposed":{
302+
"enable": true,
303+
"url":"<URL-API-DOCS>",
304+
"url_spec":"<URL-SWAGGER-JSON>"
305+
}
306+
307+
}
308+
309+
```
310+
In this case we have to
311+
1. move the "iotronic-api-docs/" folder in the web-server public folder to expose the "swagger-ui" (e.g. in Apache we
312+
have to move "iotronic-api-docs/" in "/var/www/html/");
313+
2. generate the swagger json file "iotronic-swagger.json" executing the the script "iotronic-docs-gen.js" provided
314+
by Iotronic in the "docs/" folder; e.g.:
315+
```
316+
node iotronic-docs-gen.js --iotronic=$NODE_PATH"/@mdslab/iotronic-standalone/" -e false -w /var/www/html/iotronic-api-docs/
279317
```
280-
<URL-API-DOCS> = http(s)://<IOTRONIC-IP>:<HTTP(S)-API-PORT>/v1/iotronic-api-docs/
318+
For more information see the below section "Standalone API management".
319+
320+
3. configure the "settings.json" configuration file:
321+
- set to "true" the "enable" flag in the "exposed" section;
322+
- specify the urls of the documentation (<URL-API-DOCS>) and the url that exposes the "iotronic-swagger.json" file
323+
(<URL-SWAGGER-JSON>);
324+
325+
The API documentation will be available at:
326+
```
327+
http(s)://<WEB-SERVER-URL>/iotronic-api-docs/ (<URL-API-DOCS>)
281328
```
282329
and the location of the Swagger JSON file will be:
283330
```
284-
<URL-SWAGGER-JSON> = http(s)://<IOTRONIC-IP>:<HTTP(S)-API-PORT>/v1/iotronic-swagger.json
331+
http(s)://<WEB-SERVER-URL>/iotronic-api-docs/iotronic-swagger.json (<URL-SWAGGER-JSON>)
332+
```
333+
334+
335+
In both the cases you have to edit the "index.html" in <SWAGGER-DIST-PATH> as described in the
336+
[official guide](https://swagger.io/docs/swagger-tools/#download-33):
337+
```
338+
window.swaggerUi = new SwaggerUi({
339+
url: <URL-SWAGGER-JSON>,
340+
341+
});
285342
```
343+
[Link to Official guide](https://swagger.io/docs/swagger-tools/#download-33)
344+
345+
346+
286347

287348
#### Standalone API management
288-
We also provided a NodeJS script ([iotronic-docs-gen.js](iotronic-docs-gen.js)) to do that without using directly IoTronic (we need to set "enable" to false). This script will generate the documentation and will publish it by means of "swagger-ui".
349+
We also provided a NodeJS script ([iotronic-docs-gen.js](iotronic-docs-gen.js)) to do that without using directly
350+
IoTronic or a web-server. This script will generate the documentation and will publish it by means of "swagger-ui".
289351

290352
Script usage:
291353
```
292-
node iotronic-docs-gen.js --iotronic="<IOTRONIC_SOURCE_CODE_PATH>" -e [true|false] [ -p <API_DOCS_PORT> ]
354+
node iotronic-docs-gen.js --iotronic="<IOTRONIC_SOURCE_CODE_PATH>" -e [true|false] [ -p <API_DOCS_PORT> ] [ -w <SWAGGER-JSON-SAVE-PATH>]
293355
```
294356
options:
295357
- -i, --iotronic IoTronic suorce code path. (e.g. "/usr/lib/node_modules/@mdslab/iotronic-standalone/")
296358
- -e, --embedded true | false to spawn API webpage documentation; if "false" the "iotronic-swagger.json" will be created in the <SWAGGER-DIST-PATH> folder specified in the "settings.json" file in the "docs" section.
297359
- -p, --port [only with --embedded=true] Listening port. (this port has to be different from the ports used by IoTronic "http(s)_port")
360+
- -w, --web Web server path: where will be created the swagger json file "iotronic-swagger.json".
298361

299362
The docs will be available at:
300363
```

docs/installation_ubuntu_16.04.md

Lines changed: 87 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ git clone git://github.com/MDSLab/s4t-iotronic-standalone.git
6464
mv s4t-iotronic-standalone/ iotronic-standalone
6565
6666
cp /usr/lib/node_modules/@mdslab/iotronic-standalone/etc/systemd/system/iotronic-standalone.service /etc/systemd/system/
67+
sed -i "s|ExecStart=<IOTRONIC-LAUNCHER>|ExecStart=$NODE_PATH/@mdslab/iotronic-standalone/bin/server|g" /etc/systemd/system/iotronic-standalone.service
6768
chmod +x /etc/systemd/system/iotronic-standalone.service
6869
systemctl daemon-reload
6970
systemctl enable iotronic-standalone.service
@@ -152,6 +153,7 @@ if you would like to use HTTPS to expose them you have to specify the "https" se
152153
```
153154
"db":{
154155
"host":"localhost",
156+
"port":3306,
155157
"user":"root",
156158
"password":"<MYSQL-PASSWORD>",
157159
"db_name": "s4t-iotronic"
@@ -164,6 +166,11 @@ if you would like to use HTTPS to expose them you have to specify the "https" se
164166
"email": {
165167
"address": "<SENDER-EMAIL>",
166168
"password": "<SENDER-PASSWORD-EMAIL>"
169+
"smtp":{
170+
"smtp_server": "<SMTP-MAIL-SERVER>"",
171+
"smtp_port": "<SMTP-PORT>"",
172+
"smtp_secure": "[ true | false ]"
173+
}
167174
},
168175
"enable_notify":"[ true | false ]",
169176
}
@@ -180,7 +187,7 @@ node /usr/lib/node_modules/@mdslab/iotronic-standalone/utils/createAdminToken.js
180187
"encryptKey": "<ENC-KEY>",
181188
"adminToken": "<GENERATED-BEFORE>",
182189
"backend": "iotronic",
183-
"expire_time": 60
190+
"expire_time": "30m"
184191
}
185192
```
186193
The "encryptKey" field is a user-defined keyword/password used to encrypt/decrypt the users passwords during authentication procedures.
@@ -249,57 +256,115 @@ RESPONSE:
249256

250257

251258
## API documentation management
252-
IoTronic releases its APIs documentation by means of Swagger framework. In particular we used ["swagger-jsdoc"](https://www.npmjs.com/package/swagger-jsdoc) and ["swagger-ui"](https://swagger.io/swagger-ui/) respectively to describe each RESTful API in the source code and publish the produced documentation.
259+
IoTronic releases its APIs documentation by means of Swagger framework. In particular we used ["swagger-jsdoc"](https://www.npmjs.com/package/swagger-jsdoc) and ["swagger-ui"](https://swagger.io/swagger-ui/)
260+
respectively to describe each RESTful API in the source code and publish the produced documentation.
253261

254-
To use swagger-ui we need to clone the git repository from [here](https://github.com/swagger-api/swagger-ui)
255-
and move the "dist" folder where you prefer and specify it inside the "settings.json" configuration file
256-
as showed below:
262+
Iotronic is able to expose the documentation:
263+
1. embedded mode: generate and expose runtime the API documentation
264+
2. exposed mode: only specify the URLs of the web-server that is exposing the documentation
257265

266+
In both cases we need to get the "swagger-ui" cloning the git repository from [here](https://github.com/swagger-api/swagger-ui)
267+
and rename the "dist/" folder in "iotronic-api-docs/".
268+
269+
#### 1. Embedded mode
258270
```
259271
"docs": {
260-
"enable": [ true | false ],
261-
"path": "<SWAGGER-DIST-PATH>"
272+
273+
"embedded":{
274+
"enable": true,
275+
"path": "<SWAGGER-DIST-PATH>"
276+
},
277+
"exposed":{
278+
"enable": false,
279+
"url":"",
280+
"url_spec":""
281+
}
262282
263283
}
284+
264285
```
286+
We have to move the "iotronic-api-docs/" folder in the "/var/lib/iotronic/docs/" and we need to specify it inside the
287+
"settings.json" configuration file, as showed above, in the "path" section substituting "<SWAGGER-DIST-PATH>" variable
288+
and setting to "true" the "enable" flag in the "embedded" section.
265289

266-
You have to edit the "index.html" in <SWAGGER-DIST-PATH> as described in the [official guide](https://swagger.io/docs/swagger-tools/#download-33):
290+
The API documentation will be available at:
267291
```
268-
window.swaggerUi = new SwaggerUi({
269-
url: <URL-SWAGGER-JSON>,
270-
271-
});
292+
http(s)://<IOTRONIC-IP>:<HTTP(S)-API-PORT>/v1/iotronic-api-docs/ (<URL-API-DOCS>)
272293
```
273-
where
294+
and the location of the Swagger JSON file will be:
274295
```
275-
<URL-SWAGGER-JSON> = http(s)://<IOTRONIC-IP>:<HTTP(S)-API-PORT>/<SWAGGER-JSON-LOCATION>/iotronic-swagger.json
296+
http(s)://<IOTRONIC-IP>:<HTTP(S)-API-PORT>/v1/iotronic-swagger.json (<URL-SWAGGER-JSON>)
276297
```
277298

278-
[Link to Official guide](https://swagger.io/docs/swagger-tools/#download-33)
279299

280-
#### Embedded API management
281-
Enabling the above flag ("enable":true) IoTronic will generate end expose the API documentation.
300+
#### 2. Exposed mode
301+
```
302+
"docs": {
282303
283-
The docs will be available at:
304+
"embedded":{
305+
"enable": false,
306+
"path": "<SWAGGER-DIST-PATH>"
307+
},
308+
"exposed":{
309+
"enable": true,
310+
"url":"<URL-API-DOCS>",
311+
"url_spec":"<URL-SWAGGER-JSON>"
312+
}
313+
314+
}
315+
316+
```
317+
In this case we have to
318+
1. move the "iotronic-api-docs/" folder in the web-server public folder to expose the "swagger-ui" (e.g. in Apache we
319+
have to move "iotronic-api-docs/" in "/var/www/html/");
320+
2. generate the swagger json file "iotronic-swagger.json" executing the the script "iotronic-docs-gen.js" provided
321+
by Iotronic in the "docs/" folder; e.g.:
322+
```
323+
node iotronic-docs-gen.js --iotronic=$NODE_PATH"/@mdslab/iotronic-standalone/" -e false -w /var/www/html/iotronic-api-docs/
284324
```
285-
<URL-API-DOCS> = http(s)://<IOTRONIC-IP>:<HTTP(S)-API-PORT>/v1/iotronic-api-docs/
325+
For more information see the below section "Standalone API management".
326+
327+
3. configure the "settings.json" configuration file:
328+
- set to "true" the "enable" flag in the "exposed" section;
329+
- specify the urls of the documentation (<URL-API-DOCS>) and the url that exposes the "iotronic-swagger.json" file
330+
(<URL-SWAGGER-JSON>);
331+
332+
The API documentation will be available at:
333+
```
334+
http(s)://<WEB-SERVER-URL>/iotronic-api-docs/ (<URL-API-DOCS>)
286335
```
287336
and the location of the Swagger JSON file will be:
288337
```
289-
<URL-SWAGGER-JSON> = http(s)://<IOTRONIC-IP>:<HTTP(S)-API-PORT>/v1/iotronic-swagger.json
338+
http(s)://<WEB-SERVER-URL>/iotronic-api-docs/iotronic-swagger.json (<URL-SWAGGER-JSON>)
339+
```
340+
341+
342+
In both the cases you have to edit the "index.html" in <SWAGGER-DIST-PATH> as described in the
343+
[official guide](https://swagger.io/docs/swagger-tools/#download-33):
344+
```
345+
window.swaggerUi = new SwaggerUi({
346+
url: <URL-SWAGGER-JSON>,
347+
348+
});
290349
```
350+
[Link to Official guide](https://swagger.io/docs/swagger-tools/#download-33)
351+
352+
353+
291354

292355
#### Standalone API management
293-
We also provided a NodeJS script ([iotronic-docs-gen.js](iotronic-docs-gen.js)) to do that without using directly IoTronic (we need to set "enable" to false). This script will generate the documentation and will publish it by means of "swagger-ui".
356+
We also provided a NodeJS script ([iotronic-docs-gen.js](iotronic-docs-gen.js)) to do that without using directly
357+
IoTronic or a web-server. This script will generate the documentation and will publish it by means of "swagger-ui".
294358

295359
Script usage:
296360
```
297-
node iotronic-docs-gen.js --iotronic="<IOTRONIC_SOURCE_CODE_PATH>" -e [true|false] [ -p <API_DOCS_PORT> ]
361+
node iotronic-docs-gen.js --iotronic="<IOTRONIC_SOURCE_CODE_PATH>" -e [true|false] [ -p <API_DOCS_PORT> ] [ -w <SWAGGER-JSON-SAVE-PATH>]
298362
```
299363
options:
300364
- -i, --iotronic IoTronic suorce code path. (e.g. "/usr/lib/node_modules/@mdslab/iotronic-standalone/")
301365
- -e, --embedded true | false to spawn API webpage documentation; if "false" the "iotronic-swagger.json" will be created in the <SWAGGER-DIST-PATH> folder specified in the "settings.json" file in the "docs" section.
302366
- -p, --port [only with --embedded=true] Listening port. (this port has to be different from the ports used by IoTronic "http(s)_port")
367+
- -w, --web Web server path: where will be created the swagger json file "iotronic-swagger.json".
303368

304369
The docs will be available at:
305370
```

0 commit comments

Comments
 (0)