Commit 36a64d12170d283a53853980fac4308877239d7c
Exists in
master
Merge branch 'master' into 'master'
Master(efernandez) See merge request !4
Showing
2 changed files
Show diff stats
data/index.js
| ... | ... | @@ -7,7 +7,17 @@ module.exports = function(config) { |
| 7 | 7 | |
| 8 | 8 | return new Promise(function(resolve, reject) { |
| 9 | 9 | |
| 10 | - knex(message.tableName).where(message.where).select('*').then(function (data) { | |
| 10 | + var promise; | |
| 11 | + | |
| 12 | + if (message.queryString) { | |
| 13 | + | |
| 14 | + promise = knex.schema.raw(message.queryString); | |
| 15 | + } else { | |
| 16 | + | |
| 17 | + promise = knex(message.tableName).where(message.where).select('*'); | |
| 18 | + } | |
| 19 | + | |
| 20 | + promise.then(function (data) { | |
| 11 | 21 | |
| 12 | 22 | message.data = data[0]; |
| 13 | 23 | resolve(message); |
index.js
| 1 | -const express = require('express'); | |
| 2 | -const app = express(); | |
| 3 | - | |
| 4 | 1 | const WebSocketClient = require('ws'); |
| 5 | 2 | const config = require('./config/config.json'); |
| 6 | 3 | const data = require('./data/index')(config.bo); |
| 7 | 4 | |
| 8 | -app.listen(config.port); | |
| 9 | -app.use(express.json({limit: '50mb'})); | |
| 10 | - | |
| 11 | 5 | const client = new WebSocketClient(config.urlHO); |
| 12 | 6 | |
| 13 | 7 | client.on('open', function open() { |
| ... | ... | @@ -33,4 +27,4 @@ client.on('open', function open() { |
| 33 | 27 | }); |
| 34 | 28 | }); |
| 35 | 29 | |
| 36 | -console.log('Sevice open port ' + config.port); | |
| 30 | +console.log('Sevice connected to wsServer: ' + config.urlHO); |