@bee.js/node 0.0.36 → 0.0.40
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/beeRequest.js +42 -42
- package/beehive.js +484 -482
- package/index.js +14 -14
- package/lib/DBA/beeDBA.js +119 -119
- package/lib/DEV/beeDEV.js +41 -41
- package/lib/JWT/beeJWT.js +72 -68
- package/lib/ORM/beeORM.js +319 -314
- package/lib/WEB/freeRoute.js +4 -4
- package/lib/WEB/route.js +27 -27
- package/lib/beeHive/create.js +51 -51
- package/lib/beeHive/headers.js +9 -9
- package/lib/beeHive/load.js +19 -19
- package/lib/beeHive/log.js +2 -2
- package/lib/beeHive/routes.js +34 -34
- package/lib/beeHive/start.js +29 -29
- package/package.json +40 -40
- package/security/index.js +8 -8
- package/services/CRON.js +8 -8
- package/services/EMAIL.js +2 -2
- package/services/HTTP.js +32 -32
- package/services/HTTPS.js +31 -31
- package/services/LOGS.js +7 -7
- package/services/SCRIPT.js +13 -13
- package/services/SHELL.js +2 -2
- package/services/index.js +9 -9
- package/tools/beeTools.js +18 -18
- package/tools/guid.js +14 -14
- package/tools/hash.js +12 -12
- package/tools/model.js +20 -20
- package/tools/slug.js +16 -16
- package/tools/string.js +55 -55
package/lib/WEB/route.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
const log = require('../beeHive/log')
|
|
2
|
-
const beeJWT = require('../JWT/beeJWT')
|
|
3
|
-
|
|
4
|
-
module.exports = async function(req, res, next, ignoreMiddlewares = false) {
|
|
5
|
-
log(`Route: ${req.method} ${req.originalUrl}`)
|
|
6
|
-
|
|
7
|
-
req.ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress
|
|
8
|
-
|
|
9
|
-
if(!ignoreMiddlewares) {
|
|
10
|
-
|
|
11
|
-
let token = (req.headers.authorization || '').split(' ').slice(-1)[0]
|
|
12
|
-
let validSession = global.configs.middlewares.session //TODO
|
|
13
|
-
let validPermission = global.configs.middlewares.permission //TODO
|
|
14
|
-
|
|
15
|
-
if(global.configs.jwt) {
|
|
16
|
-
log(`Token verify: ${token}`)
|
|
17
|
-
|
|
18
|
-
token = beeJWT().verify(token)
|
|
19
|
-
|
|
20
|
-
if(!token)
|
|
21
|
-
return res.status(validSession.errorCode || 401).send({data: null, error: {message: validSession.error || 'NOT_AUTHENTICATED'}, action: validSession.failAction || 'NOT_AUTHENTICATED'})
|
|
22
|
-
|
|
23
|
-
req.token = JSON.parse(token)
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
next()
|
|
1
|
+
const log = require('../beeHive/log')
|
|
2
|
+
const beeJWT = require('../JWT/beeJWT')
|
|
3
|
+
|
|
4
|
+
module.exports = async function(req, res, next, ignoreMiddlewares = false) {
|
|
5
|
+
log(`Route: ${req.method} ${req.originalUrl}`)
|
|
6
|
+
|
|
7
|
+
req.ip = req.headers['x-forwarded-for'] || req.connection.remoteAddress
|
|
8
|
+
|
|
9
|
+
if(!ignoreMiddlewares) {
|
|
10
|
+
|
|
11
|
+
let token = (req.headers.authorization || '').split(' ').slice(-1)[0]
|
|
12
|
+
let validSession = global.configs.middlewares.session //TODO
|
|
13
|
+
let validPermission = global.configs.middlewares.permission //TODO
|
|
14
|
+
|
|
15
|
+
if(global.configs.jwt) {
|
|
16
|
+
log(`Token verify: ${token}`)
|
|
17
|
+
|
|
18
|
+
token = beeJWT().verify(token)
|
|
19
|
+
|
|
20
|
+
if(!token)
|
|
21
|
+
return res.status(validSession.errorCode || 401).send({data: null, error: {message: validSession.error || 'NOT_AUTHENTICATED'}, action: validSession.failAction || 'NOT_AUTHENTICATED'})
|
|
22
|
+
|
|
23
|
+
req.token = JSON.parse(token)
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
next()
|
|
28
28
|
}
|
package/lib/beeHive/create.js
CHANGED
|
@@ -1,52 +1,52 @@
|
|
|
1
|
-
const express = require('express')
|
|
2
|
-
const bodyParser = require('body-parser')
|
|
3
|
-
const log = require('./log')
|
|
4
|
-
const headers = require('./headers')
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
module.exports = function(configs) {
|
|
8
|
-
const app = express()
|
|
9
|
-
|
|
10
|
-
app.use(bodyParser.urlencoded({ extended:
|
|
11
|
-
app.use(bodyParser.json({ extended: true }))
|
|
12
|
-
app.use(bodyParser.raw())
|
|
13
|
-
app.use((req, res, next) => headers(req, res, next))
|
|
14
|
-
|
|
15
|
-
log(`Creating ${configs.name || 'Bee.js'}...`)
|
|
16
|
-
log('Optimizing model(s)...')
|
|
17
|
-
|
|
18
|
-
let models = configs.models
|
|
19
|
-
|
|
20
|
-
for(let model in models) //TODO baixo. melhorar otimizador o criador de modelos com outras regras.
|
|
21
|
-
models[model]['table'] = models[model]['table'] || model
|
|
22
|
-
|
|
23
|
-
log('Configuring database(s)...')
|
|
24
|
-
|
|
25
|
-
// TODO talvez usar {... {obj}, {otherObject} }
|
|
26
|
-
// TODO fazer loop em todos os dbs.
|
|
27
|
-
let defaultConfigs = {
|
|
28
|
-
default: {connectionLimit : 100, multipleStatements: true, charset: 'utf8', engine: 'InnoDB', drive: 'mysql', port: 3306}
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
configs.databases.default = Object.assign({}, defaultConfigs.default, configs.databases.default)
|
|
32
|
-
|
|
33
|
-
configs.dev = process.argv.includes("--dev")
|
|
34
|
-
? true
|
|
35
|
-
: configs.debug
|
|
36
|
-
|
|
37
|
-
configs.debug = configs.dev || configs.debug
|
|
38
|
-
|
|
39
|
-
global.configs = configs
|
|
40
|
-
global.models = models
|
|
41
|
-
global.middlewares = configs.middlewares
|
|
42
|
-
global.controllers = configs.controllers
|
|
43
|
-
global.routes = configs.routes
|
|
44
|
-
|
|
45
|
-
delete global.beeDBPool
|
|
46
|
-
|
|
47
|
-
log(`${Object.keys(global.models).length} model(s)`)
|
|
48
|
-
log(`${Object.keys(global.controllers).length} controller(s)`)
|
|
49
|
-
log(`${Object.keys(global.middlewares).length-1} middleware(s)`)
|
|
50
|
-
|
|
51
|
-
return app
|
|
1
|
+
const express = require('express')
|
|
2
|
+
const bodyParser = require('body-parser')
|
|
3
|
+
const log = require('./log')
|
|
4
|
+
const headers = require('./headers')
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
module.exports = function(configs) {
|
|
8
|
+
const app = express()
|
|
9
|
+
|
|
10
|
+
app.use(bodyParser.urlencoded({ limit: "10mb", extended: true, parameterLimit: 50000 }))
|
|
11
|
+
app.use(bodyParser.json({ extended: true, limit: "10mb" }))
|
|
12
|
+
app.use(bodyParser.raw())
|
|
13
|
+
app.use((req, res, next) => headers(req, res, next))
|
|
14
|
+
|
|
15
|
+
log(`Creating ${configs.name || 'Bee.js'}...`)
|
|
16
|
+
log('Optimizing model(s)...')
|
|
17
|
+
|
|
18
|
+
let models = configs.models
|
|
19
|
+
|
|
20
|
+
for(let model in models) //TODO baixo. melhorar otimizador o criador de modelos com outras regras.
|
|
21
|
+
models[model]['table'] = models[model]['table'] || model
|
|
22
|
+
|
|
23
|
+
log('Configuring database(s)...')
|
|
24
|
+
|
|
25
|
+
// TODO talvez usar {... {obj}, {otherObject} }
|
|
26
|
+
// TODO fazer loop em todos os dbs.
|
|
27
|
+
let defaultConfigs = {
|
|
28
|
+
default: {connectionLimit : 100, multipleStatements: true, charset: 'utf8', engine: 'InnoDB', drive: 'mysql', port: 3306}
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
configs.databases.default = Object.assign({}, defaultConfigs.default, configs.databases.default)
|
|
32
|
+
|
|
33
|
+
configs.dev = process.argv.includes("--dev")
|
|
34
|
+
? true
|
|
35
|
+
: configs.debug
|
|
36
|
+
|
|
37
|
+
configs.debug = configs.dev || configs.debug
|
|
38
|
+
|
|
39
|
+
global.configs = configs
|
|
40
|
+
global.models = models
|
|
41
|
+
global.middlewares = configs.middlewares
|
|
42
|
+
global.controllers = configs.controllers
|
|
43
|
+
global.routes = configs.routes
|
|
44
|
+
|
|
45
|
+
delete global.beeDBPool
|
|
46
|
+
|
|
47
|
+
log(`${Object.keys(global.models).length} model(s)`)
|
|
48
|
+
log(`${Object.keys(global.controllers).length} controller(s)`)
|
|
49
|
+
log(`${Object.keys(global.middlewares).length-1} middleware(s)`)
|
|
50
|
+
|
|
51
|
+
return app
|
|
52
52
|
}
|
package/lib/beeHive/headers.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
module.exports = function(req, res, next) {
|
|
2
|
-
// TODO otimizar e buscar do config.
|
|
3
|
-
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
4
|
-
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
|
|
5
|
-
res.setHeader("Access-Control-Allow-Headers", "Origin, Referer, X-Requested-With, Content-Type, Accept, Authorization");
|
|
6
|
-
res.setHeader('Access-Control-Allow-Credentials', true);
|
|
7
|
-
res.setHeader('Content-Type', 'application/json');
|
|
8
|
-
|
|
9
|
-
next();
|
|
1
|
+
module.exports = function(req, res, next) {
|
|
2
|
+
// TODO otimizar e buscar do config.
|
|
3
|
+
res.setHeader('Access-Control-Allow-Origin', '*');
|
|
4
|
+
res.setHeader('Access-Control-Allow-Methods', 'GET, POST, OPTIONS, PUT, PATCH, DELETE');
|
|
5
|
+
res.setHeader("Access-Control-Allow-Headers", "Origin, Referer, X-Requested-With, Content-Type, Accept, Authorization");
|
|
6
|
+
res.setHeader('Access-Control-Allow-Credentials', true);
|
|
7
|
+
res.setHeader('Content-Type', 'application/json');
|
|
8
|
+
|
|
9
|
+
next();
|
|
10
10
|
}
|
package/lib/beeHive/load.js
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
const fs = require('fs');
|
|
2
|
-
const path = require('path');
|
|
3
|
-
//const log = require('./log');
|
|
4
|
-
|
|
5
|
-
module.exports = function(directory) {
|
|
6
|
-
|
|
7
|
-
let obj = {}
|
|
8
|
-
let dir = `${path.dirname(require.main.filename)}/${directory}/`
|
|
9
|
-
|
|
10
|
-
if(fs.existsSync(`${dir}/index.js`))
|
|
11
|
-
obj = require(`${dir}/index.js`)
|
|
12
|
-
else
|
|
13
|
-
fs
|
|
14
|
-
.readdirSync(directory)
|
|
15
|
-
.forEach(function(file) {
|
|
16
|
-
obj = Object.assign(obj, require(`${dir}/${file}`))
|
|
17
|
-
});
|
|
18
|
-
|
|
19
|
-
return obj
|
|
1
|
+
const fs = require('fs');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
//const log = require('./log');
|
|
4
|
+
|
|
5
|
+
module.exports = function(directory) {
|
|
6
|
+
|
|
7
|
+
let obj = {}
|
|
8
|
+
let dir = `${path.dirname(require.main.filename)}/${directory}/`
|
|
9
|
+
|
|
10
|
+
if(fs.existsSync(`${dir}/index.js`))
|
|
11
|
+
obj = require(`${dir}/index.js`)
|
|
12
|
+
else
|
|
13
|
+
fs
|
|
14
|
+
.readdirSync(directory)
|
|
15
|
+
.forEach(function(file) {
|
|
16
|
+
obj = Object.assign(obj, require(`${dir}/${file}`))
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
return obj
|
|
20
20
|
}
|
package/lib/beeHive/log.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports = function(param, error = false) {
|
|
2
|
-
console.log(`# ${new Date().toLocaleString()} - ${(error ? 'ERROR ' : '') + param}`) //TODO optimize
|
|
1
|
+
module.exports = function(param, error = false) {
|
|
2
|
+
console.log(`# ${new Date().toLocaleString()} - ${(error ? 'ERROR ' : '') + param}`) //TODO optimize
|
|
3
3
|
}
|
package/lib/beeHive/routes.js
CHANGED
|
@@ -1,35 +1,35 @@
|
|
|
1
|
-
const express = require('express')
|
|
2
|
-
const log = require('./log')
|
|
3
|
-
const route = require('../WEB/route')
|
|
4
|
-
const freeRoute = require('../WEB/freeRoute')
|
|
5
|
-
|
|
6
|
-
module.exports = function() {
|
|
7
|
-
if(!global.routes) return
|
|
8
|
-
|
|
9
|
-
const routes = global.routes || []
|
|
10
|
-
const router = express.Router()
|
|
11
|
-
const controllers = global.controllers
|
|
12
|
-
|
|
13
|
-
global.routes
|
|
14
|
-
.map((r)=> {
|
|
15
|
-
let controller = typeof(r.controller) !== "string"
|
|
16
|
-
? r.controller
|
|
17
|
-
: r.controller
|
|
18
|
-
.split('.')
|
|
19
|
-
.reduce((obj,i)=> {
|
|
20
|
-
return obj && obj[i]
|
|
21
|
-
? obj[i]
|
|
22
|
-
: (
|
|
23
|
-
log(`The controller '${i}' is not found in '${r.controller}'`, 1),
|
|
24
|
-
()=>null
|
|
25
|
-
)
|
|
26
|
-
}, controllers
|
|
27
|
-
)
|
|
28
|
-
|
|
29
|
-
router[r.method || "get"](r.route, r.free ? freeRoute : route, controller)
|
|
30
|
-
})
|
|
31
|
-
|
|
32
|
-
log(`${Object.keys(global.routes).length} route(s)`)
|
|
33
|
-
|
|
34
|
-
return router
|
|
1
|
+
const express = require('express')
|
|
2
|
+
const log = require('./log')
|
|
3
|
+
const route = require('../WEB/route')
|
|
4
|
+
const freeRoute = require('../WEB/freeRoute')
|
|
5
|
+
|
|
6
|
+
module.exports = function() {
|
|
7
|
+
if(!global.routes) return
|
|
8
|
+
|
|
9
|
+
const routes = global.routes || []
|
|
10
|
+
const router = express.Router()
|
|
11
|
+
const controllers = global.controllers
|
|
12
|
+
|
|
13
|
+
global.routes
|
|
14
|
+
.map((r)=> {
|
|
15
|
+
let controller = typeof(r.controller) !== "string"
|
|
16
|
+
? r.controller
|
|
17
|
+
: r.controller
|
|
18
|
+
.split('.')
|
|
19
|
+
.reduce((obj,i)=> {
|
|
20
|
+
return obj && obj[i]
|
|
21
|
+
? obj[i]
|
|
22
|
+
: (
|
|
23
|
+
log(`The controller '${i}' is not found in '${r.controller}'`, 1),
|
|
24
|
+
()=>null
|
|
25
|
+
)
|
|
26
|
+
}, controllers
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
router[r.method || "get"](r.route, r.free ? freeRoute : route, controller)
|
|
30
|
+
})
|
|
31
|
+
|
|
32
|
+
log(`${Object.keys(global.routes).length} route(s)`)
|
|
33
|
+
|
|
34
|
+
return router
|
|
35
35
|
}
|
package/lib/beeHive/start.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
const log = require('./log')
|
|
2
|
-
const beeDEV = require('../DEV/beeDEV')
|
|
3
|
-
const https = require('https')
|
|
4
|
-
const fs = require('fs')
|
|
5
|
-
|
|
6
|
-
module.exports = function(app) {
|
|
7
|
-
|
|
8
|
-
let ports = (global.configs.port || global.configs.ports || 1987.443).toString().split('.')
|
|
9
|
-
|
|
10
|
-
app.post('/beedev/:action', beeDEV) //TODO check security and create a method for define enable/disable
|
|
11
|
-
|
|
12
|
-
app.listen(ports[0])
|
|
13
|
-
|
|
14
|
-
log(`${configs.name || 'Bee.js'} started.`)
|
|
15
|
-
log(`${configs.name || 'System'} listening at http://localhost:${ports[0]}`)
|
|
16
|
-
|
|
17
|
-
if(ports.length === 1) return
|
|
18
|
-
|
|
19
|
-
let certificate = fs.existsSync(require.main.path + '/server/certificate/cert.pem')
|
|
20
|
-
? {
|
|
21
|
-
key: fs.readFileSync(require.main.path + '/server/certificate/key.pem'),
|
|
22
|
-
cert: fs.readFileSync(require.main.path + '/server/certificate/cert.pem'),
|
|
23
|
-
passphrase: 'beejs.org'
|
|
24
|
-
}
|
|
25
|
-
: {}
|
|
26
|
-
|
|
27
|
-
https.createServer(certificate, app).listen(ports[1])
|
|
28
|
-
|
|
29
|
-
log(`${configs.name || 'Bee.js'} listening at https://localhost:${ports[1]}`)
|
|
1
|
+
const log = require('./log')
|
|
2
|
+
const beeDEV = require('../DEV/beeDEV')
|
|
3
|
+
const https = require('https')
|
|
4
|
+
const fs = require('fs')
|
|
5
|
+
|
|
6
|
+
module.exports = function(app) {
|
|
7
|
+
|
|
8
|
+
let ports = (global.configs.port || global.configs.ports || 1987.443).toString().split('.')
|
|
9
|
+
|
|
10
|
+
app.post('/beedev/:action', beeDEV) //TODO check security and create a method for define enable/disable
|
|
11
|
+
|
|
12
|
+
app.listen(ports[0])
|
|
13
|
+
|
|
14
|
+
log(`${configs.name || 'Bee.js'} started.`)
|
|
15
|
+
log(`${configs.name || 'System'} listening at http://localhost:${ports[0]}`)
|
|
16
|
+
|
|
17
|
+
if(ports.length === 1) return
|
|
18
|
+
|
|
19
|
+
let certificate = fs.existsSync(require.main.path + '/server/certificate/cert.pem')
|
|
20
|
+
? {
|
|
21
|
+
key: fs.readFileSync(require.main.path + '/server/certificate/key.pem'),
|
|
22
|
+
cert: fs.readFileSync(require.main.path + '/server/certificate/cert.pem'),
|
|
23
|
+
passphrase: 'beejs.org'
|
|
24
|
+
}
|
|
25
|
+
: {}
|
|
26
|
+
|
|
27
|
+
https.createServer(certificate, app).listen(ports[1])
|
|
28
|
+
|
|
29
|
+
log(`${configs.name || 'Bee.js'} listening at https://localhost:${ports[1]}`)
|
|
30
30
|
}
|
package/package.json
CHANGED
|
@@ -1,40 +1,40 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@bee.js/node",
|
|
3
|
-
"version": "0.0.
|
|
4
|
-
"description": "A JavaScript framework for making Node.js API´s",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"scripts": {
|
|
7
|
-
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
-
},
|
|
9
|
-
"keywords": [
|
|
10
|
-
"JavaScript",
|
|
11
|
-
"ORM Node",
|
|
12
|
-
"Node",
|
|
13
|
-
"API",
|
|
14
|
-
"MVC",
|
|
15
|
-
"back-end",
|
|
16
|
-
"ORM",
|
|
17
|
-
"MySQL",
|
|
18
|
-
"MySQL UUID",
|
|
19
|
-
"MySQL GUID",
|
|
20
|
-
"JWT",
|
|
21
|
-
"Scheduler",
|
|
22
|
-
"Deploy"
|
|
23
|
-
],
|
|
24
|
-
"author": "Arnaldo Liberal dos Santos - arnaldo.liberal@outlook.com",
|
|
25
|
-
"homepage": "https://beejs.org",
|
|
26
|
-
"license": "MIT",
|
|
27
|
-
"dependencies": {
|
|
28
|
-
"body-parser": "^1.19.0",
|
|
29
|
-
"crypto": "^1.0.1",
|
|
30
|
-
"debug": "^4.1.1",
|
|
31
|
-
"express": "^4.17.1",
|
|
32
|
-
"http": "^0.0.1-security",
|
|
33
|
-
"make-error": "^1.3.6",
|
|
34
|
-
"mysql2": "^2.2.5",
|
|
35
|
-
"nodemon": "^2.0.6",
|
|
36
|
-
"util": "^0.12.2",
|
|
37
|
-
"uuid": "^8.3.2",
|
|
38
|
-
"glob": "^7.1.6"
|
|
39
|
-
}
|
|
40
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@bee.js/node",
|
|
3
|
+
"version": "0.0.40",
|
|
4
|
+
"description": "A JavaScript framework for making Node.js API´s",
|
|
5
|
+
"main": "index.js",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"test": "echo \"Error: no test specified\" && exit 1"
|
|
8
|
+
},
|
|
9
|
+
"keywords": [
|
|
10
|
+
"JavaScript",
|
|
11
|
+
"ORM Node",
|
|
12
|
+
"Node",
|
|
13
|
+
"API",
|
|
14
|
+
"MVC",
|
|
15
|
+
"back-end",
|
|
16
|
+
"ORM",
|
|
17
|
+
"MySQL",
|
|
18
|
+
"MySQL UUID",
|
|
19
|
+
"MySQL GUID",
|
|
20
|
+
"JWT",
|
|
21
|
+
"Scheduler",
|
|
22
|
+
"Deploy"
|
|
23
|
+
],
|
|
24
|
+
"author": "Arnaldo Liberal dos Santos - arnaldo.liberal@outlook.com",
|
|
25
|
+
"homepage": "https://beejs.org",
|
|
26
|
+
"license": "MIT",
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"body-parser": "^1.19.0",
|
|
29
|
+
"crypto": "^1.0.1",
|
|
30
|
+
"debug": "^4.1.1",
|
|
31
|
+
"express": "^4.17.1",
|
|
32
|
+
"http": "^0.0.1-security",
|
|
33
|
+
"make-error": "^1.3.6",
|
|
34
|
+
"mysql2": "^2.2.5",
|
|
35
|
+
"nodemon": "^2.0.6",
|
|
36
|
+
"util": "^0.12.2",
|
|
37
|
+
"uuid": "^8.3.2",
|
|
38
|
+
"glob": "^7.1.6"
|
|
39
|
+
}
|
|
40
|
+
}
|
package/security/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
module.exports = function(req, res) {
|
|
2
|
-
return {
|
|
3
|
-
failLogin: function(identity, params = {}) {
|
|
4
|
-
//TODO colocar protecao de tentativas de login, colocar verificacao no route e freeRoute
|
|
5
|
-
|
|
6
|
-
res.responseError('INVALID_AUTHENTICATION', 403)
|
|
7
|
-
}
|
|
8
|
-
}
|
|
1
|
+
module.exports = function(req, res) {
|
|
2
|
+
return {
|
|
3
|
+
failLogin: function(identity, params = {}) {
|
|
4
|
+
//TODO colocar protecao de tentativas de login, colocar verificacao no route e freeRoute
|
|
5
|
+
|
|
6
|
+
res.responseError('INVALID_AUTHENTICATION', 403)
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
9
|
}
|
package/services/CRON.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
module.exports = (param)=> {
|
|
2
|
-
let a = (param + ' ').split(' ');
|
|
3
|
-
|
|
4
|
-
switch(a[1]) {
|
|
5
|
-
case 'sec': return `*/${a[0]} * * * * *`;
|
|
6
|
-
case 'min': return `*/${a[0]} * * * *`;
|
|
7
|
-
default: return param;
|
|
8
|
-
}
|
|
1
|
+
module.exports = (param)=> {
|
|
2
|
+
let a = (param + ' ').split(' ');
|
|
3
|
+
|
|
4
|
+
switch(a[1]) {
|
|
5
|
+
case 'sec': return `*/${a[0]} * * * * *`;
|
|
6
|
+
case 'min': return `*/${a[0]} * * * *`;
|
|
7
|
+
default: return param;
|
|
8
|
+
}
|
|
9
9
|
}
|
package/services/EMAIL.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
module.exports = (params)=> {
|
|
2
|
-
//TODO
|
|
1
|
+
module.exports = (params)=> {
|
|
2
|
+
//TODO
|
|
3
3
|
}
|
package/services/HTTP.js
CHANGED
|
@@ -1,33 +1,33 @@
|
|
|
1
|
-
const http = require('http')
|
|
2
|
-
|
|
3
|
-
module.exports = async (task, services) => {
|
|
4
|
-
console.log(`# HTTP service getting... ${task.params.method} ${task.params.host + task.params.path}`)
|
|
5
|
-
|
|
6
|
-
const data = JSON.stringify(task.params.data || {})
|
|
7
|
-
|
|
8
|
-
if(task.params.data)
|
|
9
|
-
task.params.headers = {
|
|
10
|
-
'Content-Type': 'application/json'
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
const req = http.request(task.params, async function(response) {
|
|
14
|
-
var str = ''
|
|
15
|
-
|
|
16
|
-
await response.on('data', async function(chunk) {
|
|
17
|
-
str += chunk
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
await response.on('end', async function() {
|
|
21
|
-
if(task.console==2)
|
|
22
|
-
console.log("HTTP result: "+ str)
|
|
23
|
-
});
|
|
24
|
-
|
|
25
|
-
await response.on('error', function(err) {
|
|
26
|
-
// Handle error
|
|
27
|
-
console.log("# HTTP ERROR: "+ err)
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
req.write(data)
|
|
32
|
-
req.end()
|
|
1
|
+
const http = require('http')
|
|
2
|
+
|
|
3
|
+
module.exports = async (task, services) => {
|
|
4
|
+
console.log(`# HTTP service getting... ${task.params.method} ${task.params.host + task.params.path}`)
|
|
5
|
+
|
|
6
|
+
const data = JSON.stringify(task.params.data || {})
|
|
7
|
+
|
|
8
|
+
if(task.params.data)
|
|
9
|
+
task.params.headers = {
|
|
10
|
+
'Content-Type': 'application/json'
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
const req = http.request(task.params, async function(response) {
|
|
14
|
+
var str = ''
|
|
15
|
+
|
|
16
|
+
await response.on('data', async function(chunk) {
|
|
17
|
+
str += chunk
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
await response.on('end', async function() {
|
|
21
|
+
if(task.console==2)
|
|
22
|
+
console.log("HTTP result: "+ str)
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
await response.on('error', function(err) {
|
|
26
|
+
// Handle error
|
|
27
|
+
console.log("# HTTP ERROR: "+ err)
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
req.write(data)
|
|
32
|
+
req.end()
|
|
33
33
|
}
|
package/services/HTTPS.js
CHANGED
|
@@ -1,32 +1,32 @@
|
|
|
1
|
-
const https = require('https')
|
|
2
|
-
|
|
3
|
-
module.exports = async (task, services) => {
|
|
4
|
-
console.log(`# HTTPS service getting... ${task.params.method} ${task.params.host + task.params.path}`)
|
|
5
|
-
|
|
6
|
-
console.log("enviando dados: " + task.params.data.length)
|
|
7
|
-
|
|
8
|
-
const data = JSON.stringify(task.params.data || {})
|
|
9
|
-
|
|
10
|
-
if(task.params.data)
|
|
11
|
-
task.params.headers = {
|
|
12
|
-
'Content-Type': 'application/json'
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
const req = https.request(task.params, async function(response) {
|
|
16
|
-
var str = ''
|
|
17
|
-
|
|
18
|
-
await response.on('data', async function(chunk) {
|
|
19
|
-
str += chunk
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
await response.on('end', async function() {
|
|
23
|
-
if(task.console==2)
|
|
24
|
-
console.log("# HTTPS result: "+ str)
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
req.write(data)
|
|
31
|
-
req.end()
|
|
1
|
+
const https = require('https')
|
|
2
|
+
|
|
3
|
+
module.exports = async (task, services) => {
|
|
4
|
+
console.log(`# HTTPS service getting... ${task.params.method} ${task.params.host + task.params.path}`)
|
|
5
|
+
|
|
6
|
+
console.log("enviando dados: " + task.params.data.length)
|
|
7
|
+
|
|
8
|
+
const data = JSON.stringify(task.params.data || {})
|
|
9
|
+
|
|
10
|
+
if(task.params.data)
|
|
11
|
+
task.params.headers = {
|
|
12
|
+
'Content-Type': 'application/json'
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
const req = https.request(task.params, async function(response) {
|
|
16
|
+
var str = ''
|
|
17
|
+
|
|
18
|
+
await response.on('data', async function(chunk) {
|
|
19
|
+
str += chunk
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
await response.on('end', async function() {
|
|
23
|
+
if(task.console==2)
|
|
24
|
+
console.log("# HTTPS result: "+ str)
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
req.write(data)
|
|
31
|
+
req.end()
|
|
32
32
|
}
|
package/services/LOGS.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
var logs = [];
|
|
2
|
-
|
|
3
|
-
module.exports = (params)=> {
|
|
4
|
-
if(!params)
|
|
5
|
-
return logs;
|
|
6
|
-
|
|
7
|
-
logs.push(params);
|
|
1
|
+
var logs = [];
|
|
2
|
+
|
|
3
|
+
module.exports = (params)=> {
|
|
4
|
+
if(!params)
|
|
5
|
+
return logs;
|
|
6
|
+
|
|
7
|
+
logs.push(params);
|
|
8
8
|
}
|