@naturalcycles/backend-lib 4.20.2 → 4.21.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.
@@ -186,7 +186,7 @@ class BaseAdminService {
186
186
  res
187
187
  .cookie(this.cfg.adminTokenKey, token, {
188
188
  maxAge,
189
- sameSite: 'lax',
189
+ sameSite: 'lax', // can be: none, lax, strict
190
190
  // comment these 2 lines to debug on localhost
191
191
  httpOnly: true,
192
192
  secure: true,
@@ -7,7 +7,7 @@ const js_lib_1 = require("@naturalcycles/js-lib");
7
7
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
8
8
  const js_yaml_1 = tslib_1.__importDefault(require("js-yaml"));
9
9
  const APP_YAML_DEFAULT = () => ({
10
- runtime: 'nodejs18',
10
+ runtime: 'nodejs20',
11
11
  service: 'default',
12
12
  inbound_services: ['warmup'],
13
13
  instance_class: 'F1',
@@ -9,10 +9,8 @@ const deployPrepare_1 = require("./deployPrepare");
9
9
  async function deployGae(opt = {}) {
10
10
  const { logOnFailure, logOnSuccess } = opt;
11
11
  // 1. build-prod
12
- // await execCommand(`yarn`, [`build-prod`])
13
12
  (0, dev_lib_1.buildProdCommand)();
14
13
  // 2. deploy-prepare
15
- // await execCommand(`yarn`, ['deploy-prepare'])
16
14
  const deployInfo = await (0, deployPrepare_1.deployPrepare)();
17
15
  const targetDir = './tmp/deploy';
18
16
  const appYamlPath = `${targetDir}/app.yaml`;
@@ -22,6 +20,7 @@ async function deployGae(opt = {}) {
22
20
  gaeService,
23
21
  gaeVersion,
24
22
  });
23
+ (0, nodejs_lib_1.appendToGithubSummary)(`[versionUrl](${versionUrl})`);
25
24
  await (0, js_lib_1.pRetry)(async () => {
26
25
  try {
27
26
  (0, nodejs_lib_1.execVoidCommandSync)(`gcloud app deploy ${appYamlPath} --project ${gaeProject} --version ${gaeVersion} --quiet --no-promote`, [], { shell: true });
@@ -36,6 +35,8 @@ async function deployGae(opt = {}) {
36
35
  name: 'deploy',
37
36
  maxAttempts: 2,
38
37
  delay: 30000,
38
+ // todo: this doesn't work, as the error is different from what is logged.
39
+ // We shoud somehow capture the logged text
39
40
  predicate: err => (0, js_lib_1._anyToError)(err).message.includes('operation is already in progress'),
40
41
  });
41
42
  // Health check (versionUrl)
@@ -30,7 +30,7 @@ const DEFAULT_FILES = [
30
30
  // '!dist/**/*.test.*',
31
31
  // '!dist/**/*.mock.*',
32
32
  '!dist/**/*.script.*',
33
- 'src',
33
+ 'src', // For Sentry
34
34
  '!src/test',
35
35
  '!src/**/*.test.*',
36
36
  '!src/**/*.mock.*',
@@ -38,15 +38,15 @@ const DEFAULT_FILES = [
38
38
  '!**/__snapshots__',
39
39
  '!**/__exclude',
40
40
  'static',
41
- 'secret/**/*.enc',
41
+ 'secret/**/*.enc', // encrypted secrets
42
42
  'package.json',
43
43
  'yarn.lock',
44
44
  '.yarnrc',
45
- 'tsconfig.json',
45
+ 'tsconfig.json', // for path-mapping to work!
46
46
  'tsconfig.dist.json',
47
47
  '.gcloudignore',
48
48
  'app.yaml',
49
- 'patches',
49
+ 'patches', // to allow patch-package
50
50
  'resources',
51
51
  ];
52
52
  const defaultFilesDir = `${paths_cnst_1.srcDir}/deploy/files-default`;
@@ -35,7 +35,7 @@ class SentrySharedService {
35
35
  console.log('SentryService init...');
36
36
  }
37
37
  sentry.init({
38
- maxValueLength: 2000,
38
+ maxValueLength: 2000, // default is 250 characters
39
39
  ...this.sentryServiceCfg,
40
40
  });
41
41
  return sentry;
@@ -113,8 +113,8 @@ class SentrySharedService {
113
113
  */
114
114
  getCommonLogger() {
115
115
  return {
116
- log: () => { },
117
- warn: () => { },
116
+ log: () => { }, // noop
117
+ warn: () => { }, // noop
118
118
  error: (...args) => {
119
119
  const message = args.map(arg => (0, nodejs_lib_1._inspect)(arg, INSPECT_OPT)).join(' ');
120
120
  this.sentry().addBreadcrumb({
@@ -31,8 +31,8 @@ class ExpressTestService {
31
31
  retry: { count: 0 },
32
32
  logRequest: true,
33
33
  logResponse: true,
34
- logWithBaseUrl: false,
35
- fetchFn: nativeFetchFn,
34
+ logWithBaseUrl: false, // for stable error snapshots
35
+ fetchFn: nativeFetchFn, // this is to make it NOT mockable
36
36
  ...opt,
37
37
  }).onAfterResponse(async () => {
38
38
  // This "empty" hook exists to act like `await pDelay`,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/backend-lib",
3
- "version": "4.20.2",
3
+ "version": "4.21.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "serve": "APP_ENV=dev nodemon",
@@ -29,7 +29,7 @@
29
29
  "ejs": "^3.0.1",
30
30
  "express": "^4.16.4",
31
31
  "express-promise-router": "^4.0.0",
32
- "firebase-admin": "^11.0.0",
32
+ "firebase-admin": "^12.0.0",
33
33
  "helmet": "^7.0.0",
34
34
  "js-yaml": "^4.0.0",
35
35
  "on-finished": "^2.3.0",
@@ -6,7 +6,7 @@ import { BackendCfg } from './backend.cfg.util'
6
6
  import { AppYaml, DeployInfo } from './deploy.model'
7
7
 
8
8
  const APP_YAML_DEFAULT = (): AppYaml => ({
9
- runtime: 'nodejs18',
9
+ runtime: 'nodejs20',
10
10
  service: 'default',
11
11
  inbound_services: ['warmup'],
12
12
  instance_class: 'F1',
@@ -1,6 +1,6 @@
1
1
  import { buildProdCommand } from '@naturalcycles/dev-lib'
2
2
  import { _anyToError, _objectAssign, pRetry } from '@naturalcycles/js-lib'
3
- import { execVoidCommandSync } from '@naturalcycles/nodejs-lib'
3
+ import { appendToGithubSummary, execVoidCommandSync } from '@naturalcycles/nodejs-lib'
4
4
  import { deployHealthCheck, DeployHealthCheckOptions } from './deployHealthCheck'
5
5
  import { deployPrepare, DeployPrepareOptions } from './deployPrepare'
6
6
 
@@ -11,12 +11,10 @@ export async function deployGae(opt: DeployGaeOptions = {}): Promise<void> {
11
11
 
12
12
  // 1. build-prod
13
13
 
14
- // await execCommand(`yarn`, [`build-prod`])
15
14
  buildProdCommand()
16
15
 
17
16
  // 2. deploy-prepare
18
17
 
19
- // await execCommand(`yarn`, ['deploy-prepare'])
20
18
  const deployInfo = await deployPrepare()
21
19
 
22
20
  const targetDir = './tmp/deploy'
@@ -29,6 +27,8 @@ export async function deployGae(opt: DeployGaeOptions = {}): Promise<void> {
29
27
  gaeVersion,
30
28
  })
31
29
 
30
+ appendToGithubSummary(`[versionUrl](${versionUrl})`)
31
+
32
32
  await pRetry(
33
33
  async () => {
34
34
  try {
@@ -48,6 +48,8 @@ export async function deployGae(opt: DeployGaeOptions = {}): Promise<void> {
48
48
  name: 'deploy',
49
49
  maxAttempts: 2,
50
50
  delay: 30_000,
51
+ // todo: this doesn't work, as the error is different from what is logged.
52
+ // We shoud somehow capture the logged text
51
53
  predicate: err => _anyToError(err).message.includes('operation is already in progress'),
52
54
  },
53
55
  )