@naturalcycles/backend-lib 4.4.0 → 4.4.1

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.
@@ -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)().utc();
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 deployBuildTime = t.toPretty();
17
+ const t = (0, js_lib_1.localTime)(ts).utc();
18
+ const deployBuildTimeUTC = 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
- deployBuildTime,
22
+ deployBuildTimeUTC,
23
23
  APP_ENV,
24
24
  prod,
25
25
  buildInfo,
@@ -35,8 +35,6 @@ function getServerStatusData(projectDir = process.cwd(), extra) {
35
35
  }
36
36
  exports.getServerStatusData = getServerStatusData;
37
37
  function getStartedStr() {
38
- const serverStarted = (0, js_lib_1.localTime)().subtract(process.uptime(), 'second');
39
- const s1 = serverStarted.toPretty();
40
- const s2 = (0, js_lib_1._ms)(Date.now() - serverStarted.unix() * 1000);
41
- return `${s1} (${s2} ago)`;
38
+ const started = (0, js_lib_1.localTime)().utc().subtract(process.uptime(), 'second');
39
+ return `${started.toPretty()} UTC (${started.fromNow()})`;
42
40
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/backend-lib",
3
- "version": "4.4.0",
3
+ "version": "4.4.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install && patch-package",
6
6
  "serve": "APP_ENV=dev nodemon",
@@ -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().utc()
47
47
  const gitBranch = (await git.status()).current!
48
48
  const gitRev = (await git.revparse(['HEAD'])).slice(0, 7)
49
49
 
@@ -1,4 +1,4 @@
1
- import { _filterFalsyValues, _ms, localTime } from '@naturalcycles/js-lib'
1
+ import { _filterFalsyValues, localTime } from '@naturalcycles/js-lib'
2
2
  import { memoryUsageFull, processSharedUtil } from '@naturalcycles/nodejs-lib'
3
3
  import { getDeployInfo } from './deployInfo.util'
4
4
  import { BackendRequestHandler } from './server.model'
@@ -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 deployBuildTime = t.toPretty()
20
+ const t = localTime(ts).utc()
21
+ const deployBuildTimeUTC = t.toPretty()
22
22
  const buildInfo = [t.toStringCompact(), gitBranch, gitRev].filter(Boolean).join('_')
23
23
 
24
24
  return _filterFalsyValues({
25
25
  started: getStartedStr(),
26
- deployBuildTime,
26
+ deployBuildTimeUTC,
27
27
  APP_ENV,
28
28
  prod,
29
29
  buildInfo,
@@ -39,9 +39,6 @@ export function getServerStatusData(
39
39
  }
40
40
 
41
41
  function getStartedStr(): string {
42
- const serverStarted = localTime().subtract(process.uptime(), 'second')
43
-
44
- const s1 = serverStarted.toPretty()
45
- const s2 = _ms(Date.now() - serverStarted.unix() * 1000)
46
- return `${s1} (${s2} ago)`
42
+ const started = localTime().utc().subtract(process.uptime(), 'second')
43
+ return `${started.toPretty()} UTC (${started.fromNow()})`
47
44
  }