Skip to content
Snippets Groups Projects
Commit aebf971f authored by Fernando Gbur dos Santos's avatar Fernando Gbur dos Santos
Browse files

[ADD] Trying to solve the API problem

parent a789af80
Branches
No related tags found
No related merge requests found
services:
simcaq-node:
container_name: simcaq-node
build: .
ports:
- '3000:3000'
develop:
watch:
- action: sync
path: .
target: /API
#!/bin/bash
echo "Starting simcaq-node"
gulp watch &> /dev/null &
cd build
NODE_ENV=production gulp run
const gulp = require('gulp');
const nodemon = require('gulp-nodemon');
gulp.task('run', () => {
// process.chdir('build');
nodemon({
script: 'server.js',
// tasks: ['watch'],
ignore: ["test/test.js", "gulpfile.babel.js"],
ext: 'js html json',
env: { 'NODE_ENV': process.env.NODE_ENV }
});
});
gulp.task('default', () => {
console.log("Não execuatar apenas gulp, execute da forma:");
console.log("\t\tgulp <task>");
});
......@@ -16,6 +16,7 @@ const options = {
dbname: config.monetdb.dbname,
user: config.monetdb.user,
password: config.monetdb.password,
idleTimeoutMillis: 30000
};
// Connection singleton
......
......@@ -40,19 +40,24 @@ const SqlString = require('sqlstring');
function execSqlQuery(sqlQuery, sqlQueryParams = []) {
log.debug(`Executing SQL query '${sqlQuery}' with params '${sqlQueryParams}'`);
let queryStrWithParams = SqlString.format(sqlQuery, sqlQueryParams);
return new Promise((resolve, reject) => {
// Execute query
conn.query(queryStrWithParams, [], true).then((dbResult) => {
// release resources allocated for the prepared statement
conn.query(queryStrWithParams, [], true)
.then((dbResult) => {
resolve(dbResult.data);
},(queryError) => {
})
.catch((queryError) => {
log.error(`SQL query execution error: ${queryError.message}`);
log.error(`SQL query: ${sqlQuery} with params: ${sqlQueryParams}`);
reject(new Error(queryError.message));
})
.finally(() => {
conn.close();
});
});
}
function execMultiQuery(querySet = []) {
// Issue all queries concurrently to the database, for every query object in the iterable
// NOTE: Array.map() returns a copy of the original array with each object 'mapped'.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment