@naturalcycles/backend-lib
Advanced tools
Comparing version 1.14.1 to 1.15.0
@@ -0,1 +1,13 @@ | ||
# [1.15.0](https://github.com/NaturalCycles/backend-lib/compare/v1.14.1...v1.15.0) (2019-07-18) | ||
### Bug Fixes | ||
* update js-lib ([62f8716](https://github.com/NaturalCycles/backend-lib/commit/62f8716)) | ||
### Features | ||
* getDeployInfo, extend rootHandler ([3aa4b24](https://github.com/NaturalCycles/backend-lib/commit/3aa4b24)) | ||
## [1.14.1](https://github.com/NaturalCycles/backend-lib/compare/v1.14.0...v1.14.1) (2019-07-18) | ||
@@ -2,0 +14,0 @@ |
@@ -12,2 +12,6 @@ import { StringMap } from '@naturalcycles/js-lib'; | ||
prod: boolean; | ||
/** | ||
* Unix timestamp of deployInfo.json being generated. | ||
*/ | ||
ts: number; | ||
} | ||
@@ -14,0 +18,0 @@ export interface AppYaml extends StringMap<any> { |
@@ -133,2 +133,3 @@ "use strict"; | ||
prod, | ||
ts: now.unix(), | ||
}; | ||
@@ -135,0 +136,0 @@ } |
@@ -10,2 +10,3 @@ import { BaseEnv } from './env/env.model'; | ||
import { createDefaultApp } from './server/createDefaultApp'; | ||
import { getDeployInfo } from './server/deployInfo.util'; | ||
import { getDefaultRouter } from './server/getDefaultRouter'; | ||
@@ -20,2 +21,2 @@ import { genericErrorHandler } from './server/handlers/generic.error.handler'; | ||
import { SlackMessage, SlackSharedServiceCfg } from './slack/slack.shared.service.model'; | ||
export { reqValidationMiddleware, notFoundHandler, genericErrorHandler, sentryErrorMiddleware, SentrySharedService, SentrySharedServiceCfg, createDefaultApp, BootstrapSharedService, BootstrapSharedServiceCfg, serverSharedService, SlackSharedService, SlackSharedServiceCfg, SlackMessage, catchWrapper, getDefaultRouter, EnvSharedService, EnvSharedServiceCfg, BaseEnv, isGAE, createRootHandler, }; | ||
export { reqValidationMiddleware, notFoundHandler, genericErrorHandler, sentryErrorMiddleware, SentrySharedService, SentrySharedServiceCfg, createDefaultApp, BootstrapSharedService, BootstrapSharedServiceCfg, serverSharedService, SlackSharedService, SlackSharedServiceCfg, SlackMessage, catchWrapper, getDefaultRouter, EnvSharedService, EnvSharedServiceCfg, BaseEnv, isGAE, createRootHandler, getDeployInfo, }; |
@@ -15,2 +15,4 @@ "use strict"; | ||
exports.createDefaultApp = createDefaultApp_1.createDefaultApp; | ||
const deployInfo_util_1 = require("./server/deployInfo.util"); | ||
exports.getDeployInfo = deployInfo_util_1.getDeployInfo; | ||
const getDefaultRouter_1 = require("./server/getDefaultRouter"); | ||
@@ -17,0 +19,0 @@ exports.getDefaultRouter = getDefaultRouter_1.getDefaultRouter; |
@@ -6,3 +6,3 @@ import { RequestHandler } from 'express'; | ||
declare type ServerStartedCallback = () => number | undefined; | ||
export declare function createRootHandler(serverStartedCallback: ServerStartedCallback, extra?: any): RequestHandler; | ||
export declare function createRootHandler(serverStartedCallback: ServerStartedCallback, projectDir: string, extra?: any): RequestHandler; | ||
export {}; |
@@ -6,8 +6,15 @@ "use strict"; | ||
const time_lib_1 = require("@naturalcycles/time-lib"); | ||
function createRootHandler(serverStartedCallback, extra) { | ||
const deployInfo_util_1 = require("../deployInfo.util"); | ||
function createRootHandler(serverStartedCallback, projectDir, extra) { | ||
const { APP_ENV } = process.env; | ||
const { gitRev, gitBranch, prod, ts } = deployInfo_util_1.getDeployInfo(projectDir); | ||
const deployBuildTimeUTC = time_lib_1.dayjs.unix(ts).toPretty(); | ||
const buildInfo = [time_lib_1.dayjs.unix(ts).toCompactTime(), gitBranch, gitRev].join('_'); | ||
return async (req, res) => { | ||
res.json(js_lib_1.filterFalsyValues({ | ||
started: getStartedStr(serverStartedCallback()), | ||
deployBuildTimeUTC, | ||
APP_ENV, | ||
prod, | ||
buildInfo, | ||
mem: nodejs_lib_1.processSharedUtil.memoryUsage(), | ||
@@ -14,0 +21,0 @@ cpuAvg: nodejs_lib_1.processSharedUtil.cpuAvg(), |
{ | ||
"name": "@naturalcycles/backend-lib", | ||
"version": "1.14.1", | ||
"version": "1.15.0", | ||
"scripts": { | ||
@@ -5,0 +5,0 @@ "deploy-gae": "yarn tsn ./src/bin/deploy-gae.ts", |
@@ -21,2 +21,7 @@ import { kpy } from '@naturalcycles/fs-lib' | ||
prod: boolean | ||
/** | ||
* Unix timestamp of deployInfo.json being generated. | ||
*/ | ||
ts: number | ||
} | ||
@@ -200,2 +205,3 @@ | ||
prod, | ||
ts: now.unix(), | ||
} | ||
@@ -202,0 +208,0 @@ } |
@@ -10,2 +10,3 @@ import { BaseEnv } from './env/env.model' | ||
import { createDefaultApp } from './server/createDefaultApp' | ||
import { getDeployInfo } from './server/deployInfo.util' | ||
import { getDefaultRouter } from './server/getDefaultRouter' | ||
@@ -43,2 +44,3 @@ import { genericErrorHandler } from './server/handlers/generic.error.handler' | ||
createRootHandler, | ||
getDeployInfo, | ||
} |
@@ -5,2 +5,3 @@ import { filterFalsyValues } from '@naturalcycles/js-lib' | ||
import { RequestHandler } from 'express' | ||
import { getDeployInfo } from '../deployInfo.util' | ||
@@ -14,5 +15,9 @@ /** | ||
serverStartedCallback: ServerStartedCallback, | ||
projectDir: string, | ||
extra?: any, | ||
): RequestHandler { | ||
const { APP_ENV } = process.env | ||
const { gitRev, gitBranch, prod, ts } = getDeployInfo(projectDir) | ||
const deployBuildTimeUTC = dayjs.unix(ts).toPretty() | ||
const buildInfo = [dayjs.unix(ts).toCompactTime(), gitBranch, gitRev].join('_') | ||
@@ -23,3 +28,6 @@ return async (req, res) => { | ||
started: getStartedStr(serverStartedCallback()), | ||
deployBuildTimeUTC, | ||
APP_ENV, | ||
prod, | ||
buildInfo, | ||
mem: processSharedUtil.memoryUsage(), | ||
@@ -30,2 +38,3 @@ cpuAvg: processSharedUtil.cpuAvg(), | ||
GAE_VERSION: process.env.GAE_VERSION, | ||
...extra, | ||
@@ -32,0 +41,0 @@ }), |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
109461
122
2147
13