@naturalcycles/backend-lib 4.4.1 → 4.4.2
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/db/httpDB.d.ts
CHANGED
|
@@ -19,7 +19,7 @@ export declare class HttpDB extends BaseCommonDB implements CommonDB {
|
|
|
19
19
|
getByIds<ROW extends ObjectWithId>(table: string, ids: string[], opt?: CommonDBOptions): Promise<ROW[]>;
|
|
20
20
|
runQuery<ROW extends ObjectWithId>(query: DBQuery<ROW>, opt?: CommonDBOptions): Promise<RunQueryResult<ROW>>;
|
|
21
21
|
runQueryCount<ROW extends ObjectWithId>(query: DBQuery<ROW>, opt?: CommonDBOptions): Promise<number>;
|
|
22
|
-
saveBatch<ROW extends ObjectWithId
|
|
22
|
+
saveBatch<ROW extends Partial<ObjectWithId>>(table: string, rows: ROW[], opt?: CommonDBSaveOptions<ROW>): Promise<void>;
|
|
23
23
|
deleteByIds(table: string, ids: string[], opt?: CommonDBOptions): Promise<number>;
|
|
24
24
|
deleteByQuery<ROW extends ObjectWithId>(query: DBQuery<ROW>, opt?: CommonDBOptions): Promise<number>;
|
|
25
25
|
streamQuery<ROW extends ObjectWithId>(_q: DBQuery<ROW>, _opt?: CommonDBStreamOptions): ReadableTyped<ROW>;
|
|
@@ -34,7 +34,7 @@ exports.createAndSaveDeployInfo = createAndSaveDeployInfo;
|
|
|
34
34
|
async function createDeployInfo(backendCfg) {
|
|
35
35
|
const simpleGit = require('simple-git/promise'); // lazy load
|
|
36
36
|
const git = simpleGit('.');
|
|
37
|
-
const now = (0, js_lib_1.localTime)()
|
|
37
|
+
const now = (0, js_lib_1.localTime)();
|
|
38
38
|
const gitBranch = (await git.status()).current;
|
|
39
39
|
const gitRev = (await git.revparse(['HEAD'])).slice(0, 7);
|
|
40
40
|
let { gaeProject, gaeProjectByBranch = {}, gaeService, gaeServiceByBranch = {}, serviceWithBranchName, prodBranch, branchesWithTimestampVersions = [], } = backendCfg;
|
|
@@ -14,12 +14,12 @@ function serverStatusMiddleware(projectDir, extra) {
|
|
|
14
14
|
exports.serverStatusMiddleware = serverStatusMiddleware;
|
|
15
15
|
function getServerStatusData(projectDir = process.cwd(), extra) {
|
|
16
16
|
const { gitRev, gitBranch, prod, ts } = (0, deployInfo_util_1.getDeployInfo)(projectDir);
|
|
17
|
-
const t = (0, js_lib_1.localTime)(ts)
|
|
18
|
-
const
|
|
17
|
+
const t = (0, js_lib_1.localTime)(ts);
|
|
18
|
+
const deployBuildTime = t.toPretty();
|
|
19
19
|
const buildInfo = [t.toStringCompact(), gitBranch, gitRev].filter(Boolean).join('_');
|
|
20
20
|
return (0, js_lib_1._filterFalsyValues)({
|
|
21
21
|
started: getStartedStr(),
|
|
22
|
-
|
|
22
|
+
deployBuildTime,
|
|
23
23
|
APP_ENV,
|
|
24
24
|
prod,
|
|
25
25
|
buildInfo,
|
|
@@ -35,6 +35,6 @@ function getServerStatusData(projectDir = process.cwd(), extra) {
|
|
|
35
35
|
}
|
|
36
36
|
exports.getServerStatusData = getServerStatusData;
|
|
37
37
|
function getStartedStr() {
|
|
38
|
-
const started = (0, js_lib_1.localTime)().
|
|
39
|
-
return `${started.toPretty()}
|
|
38
|
+
const started = (0, js_lib_1.localTime)().subtract(process.uptime(), 'second');
|
|
39
|
+
return `${started.toPretty()} (${started.fromNow()})`;
|
|
40
40
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/backend-lib",
|
|
3
|
-
"version": "4.4.
|
|
3
|
+
"version": "4.4.2",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install && patch-package",
|
|
6
6
|
"serve": "APP_ENV=dev nodemon",
|
|
@@ -44,9 +44,8 @@
|
|
|
44
44
|
"@types/ejs": "^3.0.0",
|
|
45
45
|
"@types/js-yaml": "^4.0.0",
|
|
46
46
|
"@types/node": "^17.0.0",
|
|
47
|
-
"esbuild-register": "^3.1.2",
|
|
48
47
|
"fastify": "^3.20.1",
|
|
49
|
-
"jest": "^
|
|
48
|
+
"jest": "^28.0.3",
|
|
50
49
|
"nodemon": "^2.0.14",
|
|
51
50
|
"patch-package": "^6.2.1",
|
|
52
51
|
"prettier": "^2.0.0",
|
package/src/db/httpDB.ts
CHANGED
|
@@ -92,10 +92,10 @@ export class HttpDB extends BaseCommonDB implements CommonDB {
|
|
|
92
92
|
.json()
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
override async saveBatch<ROW extends ObjectWithId
|
|
95
|
+
override async saveBatch<ROW extends Partial<ObjectWithId>>(
|
|
96
96
|
table: string,
|
|
97
97
|
rows: ROW[],
|
|
98
|
-
opt?: CommonDBSaveOptions
|
|
98
|
+
opt?: CommonDBSaveOptions<ROW>,
|
|
99
99
|
): Promise<void> {
|
|
100
100
|
await this.got.put(`saveBatch`, {
|
|
101
101
|
json: {
|
|
@@ -43,7 +43,7 @@ export async function createDeployInfo(backendCfg: BackendCfg): Promise<DeployIn
|
|
|
43
43
|
const simpleGit = require('simple-git/promise') as typeof simpleGitLib // lazy load
|
|
44
44
|
const git = simpleGit('.')
|
|
45
45
|
|
|
46
|
-
const now = localTime()
|
|
46
|
+
const now = localTime()
|
|
47
47
|
const gitBranch = (await git.status()).current!
|
|
48
48
|
const gitRev = (await git.revparse(['HEAD'])).slice(0, 7)
|
|
49
49
|
|
|
@@ -17,13 +17,13 @@ export function getServerStatusData(
|
|
|
17
17
|
extra?: any,
|
|
18
18
|
): Record<string, any> {
|
|
19
19
|
const { gitRev, gitBranch, prod, ts } = getDeployInfo(projectDir)
|
|
20
|
-
const t = localTime(ts)
|
|
21
|
-
const
|
|
20
|
+
const t = localTime(ts)
|
|
21
|
+
const deployBuildTime = t.toPretty()
|
|
22
22
|
const buildInfo = [t.toStringCompact(), gitBranch, gitRev].filter(Boolean).join('_')
|
|
23
23
|
|
|
24
24
|
return _filterFalsyValues({
|
|
25
25
|
started: getStartedStr(),
|
|
26
|
-
|
|
26
|
+
deployBuildTime,
|
|
27
27
|
APP_ENV,
|
|
28
28
|
prod,
|
|
29
29
|
buildInfo,
|
|
@@ -39,6 +39,6 @@ export function getServerStatusData(
|
|
|
39
39
|
}
|
|
40
40
|
|
|
41
41
|
function getStartedStr(): string {
|
|
42
|
-
const started = localTime().
|
|
43
|
-
return `${started.toPretty()}
|
|
42
|
+
const started = localTime().subtract(process.uptime(), 'second')
|
|
43
|
+
return `${started.toPretty()} (${started.fromNow()})`
|
|
44
44
|
}
|