114 lines
3.2 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
Сервис интеграции ПП Парус 8 с WEB API
Точка входа в сервер приложений
*/
//----------------------
// Подключение библиотек
//----------------------
require("module-alias/register");
const cfg = require("./config.js");
const { Logger } = require("@core/logger.js");
const db = require("@core/db_connector.js");
const { ServerError } = require("@core/server_errors.js");
const parus = require("@modules/parus_db.js");
const utls = require("@core/utils.js");
//------------
// Тело модуля
//------------
let a = new db.DBConnector(cfg.dbConnect);
a.connect()
.then(res => {
console.log("CONNECTED");
a.getServices()
.then(res => {
console.log(res);
a.putLog("Сервер приложений подключен")
.then(res => {
console.log(res);
a.disconnect()
.then(res => {
console.log("DISCONNECTED");
})
.catch(e => {
console.log(e.code + ": " + e.message);
});
})
.catch(e => {
console.log(e.code + ": " + e.message);
a.disconnect()
.then(res => {
console.log("DISCONNECTED");
})
.catch(e => {
console.log(e.code + ": " + e.message);
});
});
})
.catch(e => {
console.log(e.code + ": " + e.message);
a.disconnect()
.then(res => {
console.log("DISCONNECTED");
})
.catch(e => {
console.log(e.code + ": " + e.message);
});
});
})
.catch(e => {
console.log(e.code + ": " + e.message);
});
/*
const log = new Logger();
log.error("Это ошибка");
log.warn("Предупреждение это");
log.info("Просто информация");
const test = async prms => {
return new Promise((resolve, reject) => {
if (prms == 0) {
reject(new ServerError(1234, "Ошибка!"));
} else {
setTimeout(() => {
resolve(prms + 1);
}, 1000);
}
});
};
const callTest = async prms => {
try {
console.log("in async before");
let a = await test(prms);
console.log("in async after " + a);
return a;
} catch (e) {
console.log("in async I'm here: " + e.code + " - " + e.message);
throw e;
}
};
process.on("unhandledRejection", err => {
console.error("PROCESS ERROR: " + err.code + " - " + err.message);
process.exit(0);
});
console.log("BEFORE");
callTest(0)
.then(result => {
console.log("MAIN RESULT: " + result);
})
.catch(err => {
console.error("MAIN ERROR: " + err.code + " - " + err.message);
});
console.log("AFTER");
*/