Commit e626c045 authored by Miguel Tavares's avatar Miguel Tavares
Browse files

accelerometer simulator sensor

parent 4cfd5563
Pipeline #182 canceled with stages

Too many changes to show.

To preserve performance only 1000 of 1000+ files are displayed.
FROM node:alpine
ENV ASSET_NAME="efpfaccelerometersensor"
RUN mkdir -p /usr/src/app
WORKDIR /usr/src/app
COPY . .
RUN npm install
RUN chmod +x entrypoint.sh
EXPOSE 4201
LABEL vf-OS=true
LABEL vf-OS.frontendUri=/efpftempsensor/
LABEL vf-OS.icon=img/2.png
LABEL vf-OS.urlprefixReplace=true
LABEL vf-OS.compose.0.depends_on.0="rabbitmq"
LABEL vf-OS.name=efpftempsensor
LABEL vf-OS.version.major=1
LABEL vf-OS.market.price=1
LABEL vf-OS.version.version=1
ENTRYPOINT ["/usr/src/app/entrypoint.sh"]
# efpfaccelerometersensor
# efpftempsensor
## This project simulates a temperature sensor that pushes data into a broker following this format:
```
{
"timestamp":"2022-06-02T14:38:40.289Z",
"sensor":"efpftempsensor",
"temperature":"48"
}
```
var express = require('express');
var path = require('path');
var logger = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
const os = require("os");
const formData = require("express-form-data");
const expressValidator = require('express-validator');
const recursiveReadSync = require('recursive-readdir-sync')
const contains = require("string-contains")
var app = express();
/**
* Options are the same as multiparty takes.
* But there is a new option "autoClean" to clean all files in "uploadDir" folder after the response.
* By default, it is "false".
*/
const uploadOptions = {
uploadDir: os.tmpdir(),
autoClean: true
};
app.listen(process.env.PORT || 4201);
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookieParser());
app.use(express.static(path.join(__dirname, 'public')));
app.use(expressValidator());
app.use('/',express.static(path.join(path.normalize(__dirname), '../../views')));
// parse data with connect-multiparty.
app.use(formData.parse(uploadOptions));
// clear from the request and delete all empty files (size == 0)
app.use(formData.format());
// change file objects to stream.Readable
app.use(formData.stream());
// union body and files
app.use(formData.union());
try {
recursiveReadSync(path.join(path.normalize(__dirname), '../../logic/processes')).forEach(file => {
if (!contains(file, '.gitkeep') && !contains(file, '.deps')) {
app.use('/api', require(file)(app));
}
});
} catch (err) {
if (err.errno === 34) {
console.log(err);
console.log('Path does not exist');
} else {
console.log(err);
throw err;
}
}
/**
* avoid cors
*/
app.use(function(req, res, next) {
res.header("Access-Control-Allow-Origin", "*");
res.header("Access-Control-Allow-Headers", "Origin, X-Requested-With, Content-Type, Accept");
next();
});
/**
* welcome backend route
*/
app.get('/', (req, res) => {
res.json({
message : 'vApp backend is running',
data: new Date()
});
});
// catch 404 and forward to error handler
app.use(function (req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});
// error handler
app.use(function (err, req, res, next) {
// set locals, only providing error in development
res.locals.message = err.message;
res.locals.error = req.app.get('env') === 'development' ? err : {};
// render the error page
res.status(err.status || 500);
res.render('error');
});
// This block of code is used to print the provided routes by this vApp
function split (thing) {
if (typeof thing === 'string') {
return thing.split('/')
} else if (thing.fast_slash) {
return ''
} else {
var match = thing.toString()
.replace('\\/?', '')
.replace('(?=\\/|$)', '$')
.match(/^\/\^((?:\\[.*+?^${}()|[\]\\\/]|[^.*+?^${}()|[\]\\\/])*)\$\//)
return match
? match[1].replace(/\\(.)/g, '$1').split('/')
: '<complex:' + thing.toString() + '>'
}
}
// This block of code is used to print the provided routes by this vApp
function print (path, layer) {
if (layer.route) {
layer.route.stack.forEach(print.bind(null, path.concat(split(layer.route.path))))
} else if (layer.name === 'router' && layer.handle.stack) {
layer.handle.stack.forEach(print.bind(null, path.concat(split(layer.regexp))))
} else if (layer.method) {
console.log('%s /%s',
layer.method.toUpperCase(),
path.concat(split(layer.regexp)).filter(Boolean).join('/'))
}
}
// This block of code is used to print the provided routes by this vApp
app._router.stack.forEach(print.bind(null, []));
module.exports = app;
\ No newline at end of file
# Internal-SDK-Libraries
var Db = require('./src/api/DatabasesApi')
// console.log('Log ', Db);
module.exports = {
Database: require('./src/api/DatabasesApi'),
Tables: require('./src/api/TablesApi.js'),
Rows: require('./src/api/RowsApi'),
Views: require('./src/api/ViewsApi'),
Indexes: require('./src/api/IndexesApi')
}
\ No newline at end of file
{
"requires": true,
"lockfileVersion": 1,
"dependencies": {
"async": {
"version": "2.6.2",
"resolved": "https://registry.npmjs.org/async/-/async-2.6.2.tgz",
"integrity": "sha512-H1qVYh1MYhEEFLsP97cVKqCGo7KfCyTt6uEWqsTBr9SO84oK9Uwbyd/yCW+6rKJLHksBNUVWZDAjfS+Ccx0Bbg==",
"requires": {
"lodash": "^4.17.11"
}
},
"asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha1-x57Zf380y48robyXkLzDZkdLS3k="
},
"combined-stream": {
"version": "1.0.7",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.7.tgz",
"integrity": "sha512-brWl9y6vOB1xYPZcpZde3N9zDByXTosAeMDo4p1wzo6UMOX4vumB+TP1RZ76sfE6Md68Q0NJSrE/gbezd4Ul+w==",
"requires": {
"delayed-stream": "~1.0.0"
}
},
"component-emitter": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/component-emitter/-/component-emitter-1.2.1.tgz",
"integrity": "sha1-E3kY1teCg/ffemt8WmPhQOaUJeY="
},
"cookiejar": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/cookiejar/-/cookiejar-2.1.2.tgz",
"integrity": "sha512-Mw+adcfzPxcPeI+0WlvRrr/3lGVO0bD75SxX6811cxSh1Wbxx7xZBGK1eVtDf6si8rg2lhnUjsVLMFMfbRIuwA=="
},
"debug": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.1.0.tgz",
"integrity": "sha512-heNPJUJIqC+xB6ayLAMHaIrmN9HKa7aQO8MGqKpvCA+uJYVcvR6l5kgdrhRuwPFHU7P5/A1w0BjByPHwpfTDKg==",
"requires": {
"ms": "^2.1.1"
}
},
"delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha1-3zrhmayt+31ECqrgsp4icrJOxhk="
},
"form-data": {
"version": "2.3.3",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-2.3.3.tgz",
"integrity": "sha512-1lLKB2Mu3aGP1Q/2eCOx0fNbRMe7XdwktwOruhfqqd0rIJWwN4Dh+E3hrPSlDCXnSR7UtZ1N38rVXm+6+MEhJQ==",
"requires": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.6",
"mime-types": "^2.1.12"
}
},
"formidable": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/formidable/-/formidable-1.2.1.tgz",
"integrity": "sha512-Fs9VRguL0gqGHkXS5GQiMCr1VhZBxz0JnJs4JmMp/2jL18Fmbzvv7vOFRU+U8TBkHEE/CX1qDXzJplVULgsLeg=="
},
"inherits": {
"version": "2.0.3",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz",
"integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4="
},
"lodash": {
"version": "4.17.11",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.11.tgz",
"integrity": "sha512-cQKh8igo5QUhZ7lg38DYWAxMvjSAKG0A8wGSVimP07SIUEK2UO+arSRKbRZWtelMtN5V0Hkwh5ryOto/SshYIg=="
},
"methods": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz",
"integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4="
},
"mime": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/mime/-/mime-2.3.1.tgz",
"integrity": "sha512-OEUllcVoydBHGN1z84yfQDimn58pZNNNXgZlHXSboxMlFvgI6MXSWpWKpFRra7H1HxpVhHTkrghfRW49k6yjeg=="
},
"mime-db": {
"version": "1.37.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.37.0.tgz",
"integrity": "sha512-R3C4db6bgQhlIhPU48fUtdVmKnflq+hRdad7IyKhtFj06VPNVdk2RhiYL3UjQIlso8L+YxAtFkobT0VK+S/ybg=="
},
"mime-types": {
"version": "2.1.21",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.21.tgz",
"integrity": "sha512-3iL6DbwpyLzjR3xHSFNFeb9Nz/M8WDkX33t1GFQnFOllWk8pOrh/LSrB5OXlnlW5P9LH73X6loW/eogc+F5lJg==",
"requires": {
"mime-db": "~1.37.0"
}
},
"ms": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz",
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg=="
},
"qs": {
"version": "6.5.2",
"resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz",
"integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA=="
},
"readable-stream": {
"version": "3.0.6",
"resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.0.6.tgz",
"integrity": "sha512-9E1oLoOWfhSXHGv6QlwXJim7uNzd9EVlWK+21tCU9Ju/kR0/p2AZYPz4qSchgO8PlLIH4FpZYfzwS+rEksZjIg==",
"requires": {
"inherits": "^2.0.3",
"string_decoder": "^1.1.1",
"util-deprecate": "^1.0.1"
}
},
"safe-buffer": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz",
"integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g=="
},
"string_decoder": {
"version": "1.1.1",
"resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz",
"integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==",
"requires": {
"safe-buffer": "~5.1.0"
}
},
"superagent": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/superagent/-/superagent-4.0.0.tgz",
"integrity": "sha512-qaGDf+QUYxgMYdJBWCezHnc3UjrCUwxm5bCfxBhTXI5BbCluVzmVNYzxvCw1jP9PXmwUZeOW2yPpGm9fLbhtFg==",
"requires": {
"component-emitter": "^1.2.0",
"cookiejar": "^2.1.2",
"debug": "^4.0.0",
"form-data": "^2.3.2",
"formidable": "^1.2.0",
"methods": "^1.1.1",
"mime": "^2.0.3",
"qs": "^6.5.1",
"readable-stream": "^3.0.3"
}
},
"util-deprecate": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
"integrity": "sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8="
}
}
}
let tables = require('./src/api/TablesApi')
let auth = 'Basic cG9zdGdyZXM6dmZvcw=='
tables.listTables('benfica', auth, (err, data) => {
if(err){
console.log('Error its ', err)
}else{
console.log('Data ', data)
}
});
tables.describeTable('benfica', 'cars', auth, (err, data) => {
if(err){
console.log('Error its ', err)
}else{
console.log('Data ', data)
}
});
\ No newline at end of file
/**
* vf-OS relational storage service
* This is the vf-OS service for storing relational data.
*
* OpenAPI spec version: 1.0.0
* Contact: osaiz@ikerlan.es
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
*/
let ApiClient = require("../../api_client");
let Error = require('../model/Error');
/**
* Databases service.
* @module api/DatabasesApi
* @version 1.0.0
*/
let DatabasesApi = function () {
/**
* Constructs a new DatabasesApi.
* @alias module:api/DatabasesApi
* @class
* @param {module:ApiClient} [apiClient] Optional API client implementation to use,
* default to {@link module:ApiClient#instance} if unspecified.
*/
this.apiClient = ApiClient;
this.init = function (apiClient) {
this.apiClient = apiClient || ApiClient.instance;
}
/**
* Callback function to receive the result of the addDatabase operation.
* @callback module:api/DatabasesApi~addDatabaseCallback
* @param {String} error Error message, if any.
* @param {module:model/Error} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Creates a new relational database
* @param {String} database Database name to be created
* @param {String} authorization Http Basic authorization
* @param {module:api/DatabasesApi~addDatabaseCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/Error}
*/
this.addDatabase = function(database, authorization, callback) {
let postBody = database;
// verify the required parameter 'database' is set
if (database === undefined || database === null) {
throw new Error("Missing the required parameter 'database' when calling addDatabase");
} else {
postBody = {
"database_name":postBody
}
}
// verify the required parameter 'authorization' is set
if (authorization === undefined || authorization === null) {
throw new Error("Missing the required parameter 'authorization' when calling addDatabase");
}
let pathParams = {};
let queryParams = {};
let headerParams = {
'Authorization': authorization
};
let formParams = {};
let authNames = ['basicAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = Error;
return this.apiClient.callApi(
'/databases', 'POST',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
/**
* Callback function to receive the result of the dropDatabase operation.
* @callback module:api/DatabasesApi~dropDatabaseCallback
* @param {String} error Error message, if any.
* @param {module:model/Error} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Drops an existing relational database
* @param {String} databaseName Database name to be deleted
* @param {String} authorization Http Basic authorization
* @param {module:api/DatabasesApi~dropDatabaseCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/Error}
*/
this.dropDatabase = function(databaseName, authorization, callback) {
let postBody = null;
// verify the required parameter 'databaseName' is set
if (databaseName === undefined || databaseName === null) {
throw new Error("Missing the required parameter 'databaseName' when calling dropDatabase");
}
// verify the required parameter 'authorization' is set
if (authorization === undefined || authorization === null) {
throw new Error("Missing the required parameter 'authorization' when calling dropDatabase");
}
let pathParams = {
'databaseName': databaseName
};
let queryParams = {};
let headerParams = {
'Authorization': authorization
};
let formParams = {};
let authNames = ['basicAuth'];
let contentTypes = [];
let accepts = ['application/json'];
let returnType = Error;
return this.apiClient.callApi(
'/databases/{databaseName}', 'DELETE',
pathParams, queryParams, headerParams, formParams, postBody,
authNames, contentTypes, accepts, returnType, callback
);
}
}
module.exports = new DatabasesApi()
/**
* vf-OS relational storage service
* This is the vf-OS service for storing relational data.
*
* OpenAPI spec version: 1.0.0
* Contact: osaiz@ikerlan.es
*
* NOTE: This class is auto generated by the swagger code generator program.
* https://github.com/swagger-api/swagger-codegen.git
* Do not edit the class manually.
*
*/
let ApiClient = require("../../api_client");
let Error = require('../model/Error');
let IndexDefinition = require('../model/IndexDefinition');
let ListOfStringAndError = require('../model/ListOfStringAndError');
let ViewDescriptionAndError = require('../model/ViewDescriptionAndError');
/**
* Indexes service.
* @module api/IndexesApi
* @version 1.0.0
*/
let IndexesApi = function () {
this.apiClient = ApiClient;
this.init = function (apiClient) {
this.apiClient = apiClient || ApiClient.instance;
}
/**
* Callback function to receive the result of the addIndex operation.
* @callback module:api/IndexesApi~addIndexCallback
* @param {String} error Error message, if any.
* @param {module:model/Error} data The data returned by the service call.
* @param {String} response The complete HTTP response.
*/
/**
* Creates a new index on a relational table
* @param {String} databaseName Database name
* @param {String} tableName Table name
* @param {module:model/IndexDefinition} indexDef Index definition
* @param {String} authorization Http Basic authorization
* @param {module:api/IndexesApi~addIndexCallback} callback The callback function, accepting three arguments: error, data, response
* data is of type: {@link module:model/Error}
*/
this.addIndex = function (databaseName, tableName, indexDef, authorization, callback) {
let postBody = indexDef;
// verify the required parameter 'databaseName' is set
if (databaseName === undefined || databaseName === null) {
throw new Error("Missing the required parameter 'databaseName' when calling addIndex");
}
// verify the required parameter 'tableName' is set
if (tableName === undefined || tableName === null) {
throw new Error("Missing the required parameter 'tableName' when calling addIndex");
}
// verify the required parameter 'indexDef' is set
if (indexDef === undefined || indexDef === null) {
throw new Error("Missing the required parameter 'indexDef' when calling addIndex");
}
// verify the required parameter 'authorization' is set
if (authorization === undefined || authorization === null) {