@naturalcycles/backend-lib 9.57.0 → 9.58.0

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.
@@ -26,4 +26,5 @@ export interface BackendCfg {
26
26
  */
27
27
  appYamlPassEnv?: string;
28
28
  }
29
+ export declare const backendCfgSchema: any;
29
30
  export declare function getBackendCfg(projectDir?: string): BackendCfg;
@@ -1,11 +1,17 @@
1
- import { _lazyValue } from '@naturalcycles/js-lib';
2
- import { JSchema } from '@naturalcycles/nodejs-lib/ajv';
1
+ import { j } from '@naturalcycles/nodejs-lib/ajv';
3
2
  import { fs2 } from '@naturalcycles/nodejs-lib/fs2';
4
3
  import { yaml2 } from '@naturalcycles/nodejs-lib/yaml2';
5
- import { resourcesDir } from '../paths.cnst.js';
6
- const getBackendCfgSchema = _lazyValue(() => {
7
- const schemaJson = fs2.readJson(`${resourcesDir}/backendCfg.schema.json`);
8
- return new JSchema(schemaJson, { inputName: 'backend.cfg.yaml' });
4
+ export const backendCfgSchema = j.object({
5
+ gaeProject: j.string(),
6
+ gaeProjectByBranch: j.object.stringMap(j.string()).optional(),
7
+ gaeService: j.string(),
8
+ gaeServiceByBranch: j.object.stringMap(j.string()).optional(),
9
+ files: j.array(j.string()).optional(),
10
+ appEnvDefault: j.string(),
11
+ appEnvByBranch: j.object.stringMap(j.string()).optional(),
12
+ branchesWithTimestampVersions: j.array(j.string()).optional(),
13
+ hashedBranches: j.boolean().optional(),
14
+ appYamlPassEnv: j.string().optional(),
9
15
  });
10
16
  export function getBackendCfg(projectDir = '.') {
11
17
  const backendCfgYamlPath = `${projectDir}/backend.cfg.yaml`;
@@ -13,6 +19,5 @@ export function getBackendCfg(projectDir = '.') {
13
19
  const backendCfg = {
14
20
  ...yaml2.readYaml(backendCfgYamlPath),
15
21
  };
16
- getBackendCfgSchema().validate(backendCfg);
17
- return backendCfg;
22
+ return backendCfgSchema.validate(backendCfg);
18
23
  }
@@ -3,7 +3,7 @@ import { _filterNullishValues } from '@naturalcycles/js-lib/object/object.util.j
3
3
  import { memoryUsageFull, processSharedUtil } from '@naturalcycles/nodejs-lib';
4
4
  import { getDeployInfo } from '../deploy/deployInfo.util.js';
5
5
  const { versions, arch, platform } = process;
6
- const { GAE_APPLICATION, GAE_SERVICE, GAE_VERSION, GOOGLE_CLOUD_PROJECT, K_SERVICE, K_REVISION, APP_ENV, NODE_OPTIONS, DEPLOY_BUILD_TIME, BUILD_VERSION, } = process.env;
6
+ const { GAE_APPLICATION, GAE_SERVICE, GAE_VERSION, GOOGLE_CLOUD_PROJECT, K_SERVICE, K_REVISION, APP_ENV, NODE_ENV, NODE_OPTIONS, UV_THREADPOOL_SIZE, DEPLOY_BUILD_TIME, BUILD_VERSION, } = process.env;
7
7
  export function serverStatusMiddleware(projectDir, extra) {
8
8
  return async (_req, res) => {
9
9
  res.json(getServerStatusData(projectDir, extra));
@@ -35,6 +35,8 @@ export function getServerStatusData(projectDir = process.cwd(), extra) {
35
35
  cpuInfo: processSharedUtil.cpuInfo(),
36
36
  versions,
37
37
  NODE_OPTIONS,
38
+ NODE_ENV,
39
+ UV_THREADPOOL_SIZE,
38
40
  ...extra,
39
41
  });
40
42
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/backend-lib",
3
3
  "type": "module",
4
- "version": "9.57.0",
4
+ "version": "9.58.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/db-lib": "^10",
7
7
  "@naturalcycles/js-lib": "^15",
@@ -1,10 +1,7 @@
1
- import { _lazyValue } from '@naturalcycles/js-lib'
2
1
  import type { StringMap } from '@naturalcycles/js-lib/types'
3
- import { JSchema } from '@naturalcycles/nodejs-lib/ajv'
4
- import type { JsonSchema } from '@naturalcycles/nodejs-lib/ajv'
2
+ import { j } from '@naturalcycles/nodejs-lib/ajv'
5
3
  import { fs2 } from '@naturalcycles/nodejs-lib/fs2'
6
4
  import { yaml2 } from '@naturalcycles/nodejs-lib/yaml2'
7
- import { resourcesDir } from '../paths.cnst.js'
8
5
 
9
6
  export interface BackendCfg {
10
7
  gaeProject: string
@@ -40,9 +37,17 @@ export interface BackendCfg {
40
37
  appYamlPassEnv?: string
41
38
  }
42
39
 
43
- const getBackendCfgSchema = _lazyValue(() => {
44
- const schemaJson = fs2.readJson<JsonSchema<BackendCfg>>(`${resourcesDir}/backendCfg.schema.json`)
45
- return new JSchema<BackendCfg, false>(schemaJson, { inputName: 'backend.cfg.yaml' })
40
+ export const backendCfgSchema = j.object<BackendCfg>({
41
+ gaeProject: j.string(),
42
+ gaeProjectByBranch: j.object.stringMap(j.string()).optional(),
43
+ gaeService: j.string(),
44
+ gaeServiceByBranch: j.object.stringMap(j.string()).optional(),
45
+ files: j.array(j.string()).optional(),
46
+ appEnvDefault: j.string(),
47
+ appEnvByBranch: j.object.stringMap(j.string()).optional(),
48
+ branchesWithTimestampVersions: j.array(j.string()).optional(),
49
+ hashedBranches: j.boolean().optional(),
50
+ appYamlPassEnv: j.string().optional(),
46
51
  })
47
52
 
48
53
  export function getBackendCfg(projectDir = '.'): BackendCfg {
@@ -54,6 +59,5 @@ export function getBackendCfg(projectDir = '.'): BackendCfg {
54
59
  ...yaml2.readYaml(backendCfgYamlPath),
55
60
  }
56
61
 
57
- getBackendCfgSchema().validate(backendCfg)
58
- return backendCfg
62
+ return backendCfgSchema.validate(backendCfg)
59
63
  }
@@ -13,7 +13,9 @@ const {
13
13
  K_SERVICE,
14
14
  K_REVISION,
15
15
  APP_ENV,
16
+ NODE_ENV,
16
17
  NODE_OPTIONS,
18
+ UV_THREADPOOL_SIZE,
17
19
  DEPLOY_BUILD_TIME,
18
20
  BUILD_VERSION,
19
21
  } = process.env
@@ -54,6 +56,8 @@ export function getServerStatusData(
54
56
  cpuInfo: processSharedUtil.cpuInfo(),
55
57
  versions,
56
58
  NODE_OPTIONS,
59
+ NODE_ENV,
60
+ UV_THREADPOOL_SIZE,
57
61
  ...extra,
58
62
  })
59
63
  }
@@ -1,41 +0,0 @@
1
- {
2
- "$schema": "http://json-schema.org/draft-07/schema#",
3
- "$id": "https://unpkg.com/@naturalcycles/backend-lib/resources/backendCfg.schema.json",
4
- "type": "object",
5
- "properties": {
6
- "gaeProject": { "type": "string" },
7
- "gaeProjectByBranch": {
8
- "type": "object",
9
- "patternProperties": {
10
- ".*": { "type": "string" }
11
- }
12
- },
13
- "gaeService": { "type": "string" },
14
- "gaeServiceByBranch": {
15
- "type": "object",
16
- "patternProperties": {
17
- ".*": { "type": "string" }
18
- }
19
- },
20
- "files": {
21
- "type": "array",
22
- "items": { "type": "string" }
23
- },
24
- "appEnvDefault": { "type": "string" },
25
- "appEnvByBranch": {
26
- "type": "object",
27
- "patternProperties": {
28
- ".*": { "type": "string" }
29
- }
30
- },
31
- "branchesWithTimestampVersions": {
32
- "type": "array",
33
- "items": { "type": "string" }
34
- },
35
- "hashedBranches": {
36
- "type": "boolean"
37
- },
38
- "appYamlPassEnv": { "type": "string" }
39
- },
40
- "required": ["gaeProject", "gaeService", "appEnvDefault"]
41
- }