@orxataguy/tyr 1.0.49 → 1.0.51
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/package.json +1 -1
- package/src/core/Kernel.ts +3 -1
- package/src/lib/SQLManager.ts +0 -45
package/package.json
CHANGED
package/src/core/Kernel.ts
CHANGED
|
@@ -53,7 +53,9 @@ export class Kernel {
|
|
|
53
53
|
public async boot(args: string[]): Promise<void> {
|
|
54
54
|
this.isDebug = args.includes('--debug');
|
|
55
55
|
|
|
56
|
-
|
|
56
|
+
if (this.isDebug) {
|
|
57
|
+
args.splice(args.indexOf('--debug'), 1);
|
|
58
|
+
}
|
|
57
59
|
|
|
58
60
|
(dotenv as any).config({ path: path.join(this.userRoot, '.env'), quiet: true });
|
|
59
61
|
|
package/src/lib/SQLManager.ts
CHANGED
|
@@ -50,51 +50,6 @@ export class SQLManager {
|
|
|
50
50
|
return result.recordset;
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
-
/**
|
|
54
|
-
* @method searchBrokerOnDB
|
|
55
|
-
* @description Looks up a broker by hostname using the encoded query.
|
|
56
|
-
* @param {string | URL} url - URL or string to extract the hostname from.
|
|
57
|
-
* @returns {Promise<string>} Broker name.
|
|
58
|
-
* @example
|
|
59
|
-
* const broker = await db.searchBrokerOnDB('https://www.foo.com');
|
|
60
|
-
*/
|
|
61
|
-
public async searchBrokerOnDB(url: string | URL): Promise<string> {
|
|
62
|
-
let urlString = url.toString();
|
|
63
|
-
|
|
64
|
-
if (!urlString.startsWith("http://") && !urlString.startsWith("https://")) {
|
|
65
|
-
urlString = "https://" + urlString;
|
|
66
|
-
}
|
|
67
|
-
let urlObj = new URL(urlString).hostname;
|
|
68
|
-
|
|
69
|
-
if (urlObj.split('.').length < 3) {
|
|
70
|
-
urlObj = ['www', urlObj].join('.');
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
const isWeb = urlObj.startsWith('www') ||
|
|
74
|
-
urlObj.startsWith('horizon') ||
|
|
75
|
-
urlObj.startsWith('ambiance') ||
|
|
76
|
-
urlObj.startsWith('panorama') ||
|
|
77
|
-
urlObj.startsWith('flow') ||
|
|
78
|
-
urlObj.startsWith('panorama') ||
|
|
79
|
-
urlObj.startsWith('avantio') ||
|
|
80
|
-
urlObj.startsWith('demo');
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
const query = isWeb ? `SELECT basedir as BROKER from ftpUsers where CONCAT(prefijo, '.', dominio) = '${urlObj}'` : `SELECT LOGIN_DS AS BROKER from CR_CANALVENTAS WHERE WEB_DS = '${urlObj}'`;
|
|
84
|
-
|
|
85
|
-
await this.init();
|
|
86
|
-
|
|
87
|
-
const result = await this.pool.request().query(query);
|
|
88
|
-
|
|
89
|
-
await this.close();
|
|
90
|
-
|
|
91
|
-
if (!result.recordset[0] || !result.recordset[0].BROKER) {
|
|
92
|
-
throw new Error(`No broker found for ${urlObj}`);
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
return result.recordset[0].BROKER as string;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
53
|
private async close(): Promise<void> {
|
|
99
54
|
if (this.connected && this.pool) {
|
|
100
55
|
await this.pool.close();
|