lesgo 2.1.9 → 2.1.11
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/dist/services/RDSAuroraMySQLProxyService/disconnectMySQLProxyClient.d.ts +3 -0
- package/dist/services/RDSAuroraMySQLProxyService/disconnectMySQLProxyClient.js +21 -20
- package/dist/utils/db/mysql/proxy/disconnectDb.d.ts +3 -0
- package/dist/utils/db/mysql/proxy/disconnectDb.js +3 -0
- package/dist/utils/index.d.ts +1 -0
- package/dist/utils/index.js +1 -0
- package/dist/utils/safePromise.d.ts +1 -1
- package/dist/utils/safePromise.js +1 -1
- package/dist/utils/typeSafePromise.d.ts +29 -0
- package/dist/utils/typeSafePromise.js +49 -0
- package/package.json +1 -1
|
@@ -32,29 +32,30 @@ var __awaiter =
|
|
|
32
32
|
});
|
|
33
33
|
};
|
|
34
34
|
import { logger } from '../../utils';
|
|
35
|
-
import { singleton } from '../RDSAuroraMySQLProxyService/getMySQLProxyClient';
|
|
36
35
|
const FILE =
|
|
37
36
|
'lesgo.services.RDSAuroraMySQLProxyService.disconnectMySQLProxyClient';
|
|
37
|
+
/**
|
|
38
|
+
* @deprecated Disconnect db is no longer to be used due to the use of ConnectionPool
|
|
39
|
+
*/
|
|
38
40
|
const disconnectMySQLProxyClient = () =>
|
|
39
41
|
__awaiter(void 0, void 0, void 0, function* () {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
);
|
|
42
|
+
logger.warn(`${FILE}::DEPRECATED_FUNCTION_DO_NOT_END_POOL_CONNECTION`);
|
|
43
|
+
// const singletonConns = Object.keys(singleton);
|
|
44
|
+
// if (singletonConns.length === 0) {
|
|
45
|
+
// logger.debug(`${FILE}::NO_CONNECTIONS_TO_DISCONNECT`);
|
|
46
|
+
// return;
|
|
47
|
+
// }
|
|
48
|
+
// logger.debug(`${FILE}::PREPARING_TO_DISCONNECT`, {
|
|
49
|
+
// singletonConns,
|
|
50
|
+
// });
|
|
51
|
+
// singletonConns.forEach(async singletonConn => {
|
|
52
|
+
// try {
|
|
53
|
+
// await singleton[singletonConn].end();
|
|
54
|
+
// delete singleton[singletonConn];
|
|
55
|
+
// logger.debug(`${FILE}::COMPLETED`, { singletonConn });
|
|
56
|
+
// } catch (err) {
|
|
57
|
+
// logger.error(`${FILE}::ERROR`, { singletonConn, err });
|
|
58
|
+
// }
|
|
59
|
+
// });
|
|
59
60
|
});
|
|
60
61
|
export default disconnectMySQLProxyClient;
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -8,3 +8,4 @@ export { default as isEmpty } from './isEmpty';
|
|
|
8
8
|
export { default as logger } from './logger';
|
|
9
9
|
export { default as validateFields } from './validateFields';
|
|
10
10
|
export { default as safePromise } from './safePromise';
|
|
11
|
+
export { default as typeSafePromise } from './typeSafePromise';
|
package/dist/utils/index.js
CHANGED
|
@@ -8,3 +8,4 @@ export { default as isEmpty } from './isEmpty';
|
|
|
8
8
|
export { default as logger } from './logger';
|
|
9
9
|
export { default as validateFields } from './validateFields';
|
|
10
10
|
export { default as safePromise } from './safePromise';
|
|
11
|
+
export { default as typeSafePromise } from './typeSafePromise';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
*
|
|
3
|
+
* @param promise
|
|
4
|
+
* @returns {success: true, data: TData} | {success: false, error: TError}
|
|
5
|
+
* @reference https://github.com/arthurfiorette/proposal-safe-assignment-operator
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { typeSafePromise } from 'lesgo/utils';
|
|
10
|
+
*
|
|
11
|
+
* const res = await typeSafePromise(fetch('https://example.com/'));
|
|
12
|
+
* if (res.success) {
|
|
13
|
+
* console.log(res.data);
|
|
14
|
+
* } else {
|
|
15
|
+
* console.error(res.error);
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
type ReturnTypeSafePromise<TData, TError> = {
|
|
20
|
+
success: true;
|
|
21
|
+
data: TData;
|
|
22
|
+
error?: undefined;
|
|
23
|
+
} | {
|
|
24
|
+
success: false;
|
|
25
|
+
data?: undefined;
|
|
26
|
+
error: TError;
|
|
27
|
+
};
|
|
28
|
+
declare const typeSafePromise: <TData, TError = Error>(promise: Promise<TData>) => Promise<ReturnTypeSafePromise<TData, TError>>;
|
|
29
|
+
export default typeSafePromise;
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __awaiter =
|
|
2
|
+
(this && this.__awaiter) ||
|
|
3
|
+
function (thisArg, _arguments, P, generator) {
|
|
4
|
+
function adopt(value) {
|
|
5
|
+
return value instanceof P
|
|
6
|
+
? value
|
|
7
|
+
: new P(function (resolve) {
|
|
8
|
+
resolve(value);
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
12
|
+
function fulfilled(value) {
|
|
13
|
+
try {
|
|
14
|
+
step(generator.next(value));
|
|
15
|
+
} catch (e) {
|
|
16
|
+
reject(e);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
function rejected(value) {
|
|
20
|
+
try {
|
|
21
|
+
step(generator['throw'](value));
|
|
22
|
+
} catch (e) {
|
|
23
|
+
reject(e);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
function step(result) {
|
|
27
|
+
result.done
|
|
28
|
+
? resolve(result.value)
|
|
29
|
+
: adopt(result.value).then(fulfilled, rejected);
|
|
30
|
+
}
|
|
31
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
|
+
});
|
|
33
|
+
};
|
|
34
|
+
const typeSafePromise = promise =>
|
|
35
|
+
__awaiter(void 0, void 0, void 0, function* () {
|
|
36
|
+
try {
|
|
37
|
+
const res = yield promise;
|
|
38
|
+
return {
|
|
39
|
+
success: true,
|
|
40
|
+
data: res,
|
|
41
|
+
};
|
|
42
|
+
} catch (err) {
|
|
43
|
+
return {
|
|
44
|
+
success: false,
|
|
45
|
+
error: err,
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
});
|
|
49
|
+
export default typeSafePromise;
|