minervajs-helmet 1.0.0 → 1.0.2
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/LICENSE +24 -0
- package/README.md +2 -0
- package/js/db.js +77 -0
- package/js/db_mysql.js +54 -0
- package/js/db_oracle.js +47 -0
- package/package.json +11 -2
- package/settings.js +32 -0
- package/src/index.js +7 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
BSD 2-Clause License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Alexander E. Escobar
|
|
4
|
+
|
|
5
|
+
Redistribution and use in source and binary forms, with or without
|
|
6
|
+
modification, are permitted provided that the following conditions are met:
|
|
7
|
+
|
|
8
|
+
1. Redistributions of source code must retain the above copyright notice, this
|
|
9
|
+
list of conditions and the following disclaimer.
|
|
10
|
+
|
|
11
|
+
2. Redistributions in binary form must reproduce the above copyright notice,
|
|
12
|
+
this list of conditions and the following disclaimer in the documentation
|
|
13
|
+
and/or other materials provided with the distribution.
|
|
14
|
+
|
|
15
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
|
16
|
+
AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
17
|
+
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
|
|
18
|
+
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
|
|
19
|
+
FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
20
|
+
DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
21
|
+
SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
22
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
|
|
23
|
+
OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
|
|
24
|
+
OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
package/README.md
ADDED
package/js/db.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module
|
|
3
|
+
* @name db
|
|
4
|
+
* @description Modulo gestor de la coneccion a la base de datos
|
|
5
|
+
*
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
var mysql = require('mysql');
|
|
9
|
+
var settings = require('../settings');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @function
|
|
13
|
+
* @name executeSQL
|
|
14
|
+
* @param {string} sql - Sentencia SQL a ejecutar
|
|
15
|
+
* @param {callback} callback - objeto, para retornar la promesa
|
|
16
|
+
* @returns {result} result/err - Devuelve un objeto con el set de datos o un objeto err con la respuesta del error
|
|
17
|
+
* @description Ejecuta una sentencia SQL y devuelve un objeto en un set de datos
|
|
18
|
+
*/
|
|
19
|
+
exports.executeSQL = function (sql, callback)
|
|
20
|
+
{
|
|
21
|
+
var con = new mysql.createConnection(settings.dbConfig);
|
|
22
|
+
|
|
23
|
+
con.connect(function(err)
|
|
24
|
+
{
|
|
25
|
+
if (err)
|
|
26
|
+
{
|
|
27
|
+
callback(null, err);
|
|
28
|
+
//throw err;
|
|
29
|
+
}
|
|
30
|
+
if (settings.servConfig.debug){console.log("Connected!");}
|
|
31
|
+
con.query(sql, function (err, result) {
|
|
32
|
+
if (err)
|
|
33
|
+
{
|
|
34
|
+
callback(null, err);
|
|
35
|
+
//throw err;
|
|
36
|
+
}
|
|
37
|
+
if (settings.servConfig.debug){console.log("Sentencia Ejecutada:"+sql);}
|
|
38
|
+
callback(result);
|
|
39
|
+
|
|
40
|
+
con.end();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* @function
|
|
47
|
+
* @name executeSQLarray
|
|
48
|
+
* @param {string} sql - Sentencia SQL a ejecutar
|
|
49
|
+
* @param {callback} callback - objeto, para retornar la promesa
|
|
50
|
+
* @returns {result} result/err - Devuelve un objeto con el set de datos o un objeto err con la respuesta del error
|
|
51
|
+
* @description Ejecuta una sentencia SQL, basado en una serie de argumentos y devuelve un objeto en un set de datos
|
|
52
|
+
*/
|
|
53
|
+
exports.executeSQLarray = function (sql, array, callback)
|
|
54
|
+
{
|
|
55
|
+
var con = new mysql.createConnection(settings.dbConfig);
|
|
56
|
+
|
|
57
|
+
con.connect(function(err)
|
|
58
|
+
{
|
|
59
|
+
if (err)
|
|
60
|
+
{
|
|
61
|
+
callback(null, err);
|
|
62
|
+
//throw err;
|
|
63
|
+
}
|
|
64
|
+
if (settings.servConfig.debug){console.log("Connected!");}
|
|
65
|
+
con.query(sql, array, function (err, result) {
|
|
66
|
+
if (err)
|
|
67
|
+
{
|
|
68
|
+
callback(null, err);
|
|
69
|
+
//throw err;
|
|
70
|
+
}
|
|
71
|
+
if (settings.servConfig.debug){console.log("Sentencia Ejecutada:"+sql);}
|
|
72
|
+
callback(result);
|
|
73
|
+
|
|
74
|
+
con.end();
|
|
75
|
+
});
|
|
76
|
+
});
|
|
77
|
+
}
|
package/js/db_mysql.js
ADDED
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
var mysql = require('mysql');
|
|
2
|
+
var settings = require('../js/settings');
|
|
3
|
+
|
|
4
|
+
exports.executeSQL = function (sql, callback)
|
|
5
|
+
{
|
|
6
|
+
var con = new mysql.createConnection(settings.dbConfig);
|
|
7
|
+
|
|
8
|
+
con.connect(function(err)
|
|
9
|
+
{
|
|
10
|
+
if (err)
|
|
11
|
+
{
|
|
12
|
+
callback(null, err);
|
|
13
|
+
//throw err;
|
|
14
|
+
}
|
|
15
|
+
if (settings.servConfig.debug){console.log("Connected!");}
|
|
16
|
+
con.query(sql, function (err, result) {
|
|
17
|
+
if (err)
|
|
18
|
+
{
|
|
19
|
+
callback(null, err);
|
|
20
|
+
//throw err;
|
|
21
|
+
}
|
|
22
|
+
if (settings.servConfig.debug){console.log("Sentencia Ejecutada:"+sql);}
|
|
23
|
+
callback(result);
|
|
24
|
+
|
|
25
|
+
con.end();
|
|
26
|
+
});
|
|
27
|
+
});
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.executeSQLarray = function (sql, array, callback)
|
|
31
|
+
{
|
|
32
|
+
var con = new mysql.createConnection(settings.dbConfig);
|
|
33
|
+
|
|
34
|
+
con.connect(function(err)
|
|
35
|
+
{
|
|
36
|
+
if (err)
|
|
37
|
+
{
|
|
38
|
+
callback(null, err);
|
|
39
|
+
//throw err;
|
|
40
|
+
}
|
|
41
|
+
if (settings.servConfig.debug){console.log("Connected!");}
|
|
42
|
+
con.query(sql, array, function (err, result) {
|
|
43
|
+
if (err)
|
|
44
|
+
{
|
|
45
|
+
callback(null, err);
|
|
46
|
+
//throw err;
|
|
47
|
+
}
|
|
48
|
+
if (settings.servConfig.debug){console.log("Sentencia Ejecutada:"+sql);}
|
|
49
|
+
callback(result);
|
|
50
|
+
|
|
51
|
+
con.end();
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
}
|
package/js/db_oracle.js
ADDED
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
var oracledb = require('oracledb');
|
|
2
|
+
var settings = require('../js/settings');
|
|
3
|
+
|
|
4
|
+
oracledb.outFormat = oracledb.OUT_FORMAT_OBJECT;
|
|
5
|
+
|
|
6
|
+
exports.executeSQL = function (sql, callback)
|
|
7
|
+
{
|
|
8
|
+
let con;
|
|
9
|
+
|
|
10
|
+
con = oracledb.getConnection(settings.dbConfig);
|
|
11
|
+
|
|
12
|
+
console.log(sql);
|
|
13
|
+
result = con.execute(sql);
|
|
14
|
+
console.log(result);
|
|
15
|
+
|
|
16
|
+
con.close();
|
|
17
|
+
|
|
18
|
+
callback(result);
|
|
19
|
+
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
exports.executeSQLXX = function (sql, callback)
|
|
24
|
+
{
|
|
25
|
+
var con = new oracledb.getConnection(settings.dbConfig);
|
|
26
|
+
|
|
27
|
+
//con.connect(function(err)
|
|
28
|
+
//{
|
|
29
|
+
// if (err)
|
|
30
|
+
// {
|
|
31
|
+
// callback(null, err);
|
|
32
|
+
// //throw err;
|
|
33
|
+
// }
|
|
34
|
+
if (settings.servConfig.debug){console.log("Connected!");}
|
|
35
|
+
con.execute(sql, function (err, result) {
|
|
36
|
+
if (err)
|
|
37
|
+
{
|
|
38
|
+
callback(null, err);
|
|
39
|
+
//throw err;
|
|
40
|
+
}
|
|
41
|
+
if (settings.servConfig.debug){console.log("Sentencia Ejecutada:"+sql);}
|
|
42
|
+
callback(result);
|
|
43
|
+
|
|
44
|
+
con.close();
|
|
45
|
+
});
|
|
46
|
+
//});
|
|
47
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minervajs-helmet",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"main": "src/index.js",
|
|
5
5
|
"scripts": {
|
|
6
6
|
"test": "echo \"Error: no test specified\" && exit 1"
|
|
@@ -18,5 +18,14 @@
|
|
|
18
18
|
"dependencies": {
|
|
19
19
|
"mysql": "^2.18.1",
|
|
20
20
|
"oracledb": "^6.6.0"
|
|
21
|
-
}
|
|
21
|
+
},
|
|
22
|
+
"devDependencies": {},
|
|
23
|
+
"repository": {
|
|
24
|
+
"type": "git",
|
|
25
|
+
"url": "https://github.com/Alexander-Escobar/MinervaJS.Helmet.git"
|
|
26
|
+
},
|
|
27
|
+
"bug": {
|
|
28
|
+
"url": "https://github.com/Alexander-Escobar/MinervaJS.Helmet.git/issues"
|
|
29
|
+
},
|
|
30
|
+
"homepage": "https://github.com/Alexander-Escobar/MinervaJS.Helmet.git#readme"
|
|
22
31
|
}
|
package/settings.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Configuracion y Parametrizacion general de la Aplicacion & Sitio Web
|
|
3
|
+
|
|
4
|
+
Listado:
|
|
5
|
+
dbConfig Configuracion de la Base de Datos
|
|
6
|
+
servConfig Configuracion del Servidor
|
|
7
|
+
httpConfig Configuracion de las Peticiones URL del Protocolo HTTP
|
|
8
|
+
Google Configuracion para Google Ads
|
|
9
|
+
Image Configuracion General para las imagenes
|
|
10
|
+
pagConfig Configuracion de la Paginacion de los Mantenimientos
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
exports.httpMsgFormat = 'HTML';
|
|
14
|
+
exports.Title = "DB Smarts Docs";
|
|
15
|
+
exports.Rights_Reserved = "2023 © A&C Consultoría Informática";
|
|
16
|
+
|
|
17
|
+
exports.dbConfig =
|
|
18
|
+
{
|
|
19
|
+
// mysql
|
|
20
|
+
// host: "localhost",
|
|
21
|
+
user: "Owlet",
|
|
22
|
+
password: "Password01",
|
|
23
|
+
// database: "DBSisConta"
|
|
24
|
+
connectString : "(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=namehostoip)(PORT=port))(CONNECT_DATA=(SERVICE_NAME=servicename)))"
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
exports.servConfig =
|
|
28
|
+
{
|
|
29
|
+
hostname: "", // http://localhost:9000
|
|
30
|
+
webPort: 9000, // 80
|
|
31
|
+
debug: true
|
|
32
|
+
};
|