тестовый middleware:
exports.Test = function (req, res, next) {
var id = 1;
var param = 'test';
var bodyParser = require('body-parser');
var Connection = require('tedious').Connection;
var config = {
// тут конфиг БД
options: {encrypt: true, database: 'database'}
};
var Request = require('tedious').Request;
var TYPES = require('tedious').TYPES;
var connection = new Connection(config);
connection.on('connect', function(err) {
executeStatement();
});
function executeStatement() {
request = new Request("select * from dbo.Table where param= '"+param+"' AND Id= '"+id+"' ", function(err, rowCount) {
res.send(JSON.stringify(menues));
});
var menues = new Array();
request.on('row', function(columns) {
columns.forEach(function(column) {
menues.push(column.value);
});
});
connection.execSql(request);
}
}
получаю json примерно через 3 - 4 секунды!