@naturalcycles/backend-lib 4.8.2 → 4.8.3

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.
@@ -18,7 +18,7 @@ export interface RequireAdminCfg {
18
18
  */
19
19
  autoLogin?: boolean;
20
20
  }
21
- export declare type AdminMiddleware = (reqPermissions?: string[], cfg?: RequireAdminCfg) => BackendRequestHandler;
21
+ export type AdminMiddleware = (reqPermissions?: string[], cfg?: RequireAdminCfg) => BackendRequestHandler;
22
22
  export declare function createAdminMiddleware(adminService: BaseAdminService, cfgDefaults?: RequireAdminCfg): AdminMiddleware;
23
23
  /**
24
24
  * Require Admin permission.
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getLoginHtmlRedirect = exports.loginHtml = exports.requireAdminPermissions = exports.createAdminMiddleware = void 0;
4
- const fs = require("fs");
4
+ const fs = require("node:fs");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  const ejs = require("ejs");
7
7
  function createAdminMiddleware(adminService, cfgDefaults = {}) {
package/dist/db/httpDB.js CHANGED
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.HttpDB = void 0;
4
- const stream_1 = require("stream");
4
+ const node_stream_1 = require("node:stream");
5
5
  const db_lib_1 = require("@naturalcycles/db-lib");
6
6
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
7
7
  /**
@@ -91,7 +91,7 @@ class HttpDB extends db_lib_1.BaseCommonDB {
91
91
  }
92
92
  streamQuery(_q, _opt) {
93
93
  console.warn(`streamQuery not implemented`);
94
- return stream_1.Readable.from([]);
94
+ return node_stream_1.Readable.from([]);
95
95
  }
96
96
  }
97
97
  exports.HttpDB = HttpDB;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.validateGAEServiceName = exports.createAppYaml = exports.createAndSaveAppYaml = exports.createDeployInfo = exports.createAndSaveDeployInfo = void 0;
4
- const fs = require("fs");
4
+ const fs = require("node:fs");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
7
7
  const yaml = require("js-yaml");
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.deployHealthCheck = exports.deployHealthCheckYargsOptions = void 0;
4
- const util_1 = require("util");
4
+ const node_util_1 = require("node:util");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
7
7
  const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
@@ -83,7 +83,7 @@ async function deployHealthCheck(url, opt = {}) {
83
83
  }
84
84
  async function makeAttempt() {
85
85
  attempt++;
86
- console.log([`>>`, (0, colors_1.dimGrey)(url), (0, util_1.inspect)({ attempt }, inspectOpt)].join(' '));
86
+ console.log([`>>`, (0, colors_1.dimGrey)(url), (0, node_util_1.inspect)({ attempt }, inspectOpt)].join(' '));
87
87
  const started = Date.now();
88
88
  const { statusCode } = await got(url, {
89
89
  responseType: 'json',
@@ -120,7 +120,7 @@ async function deployHealthCheck(url, opt = {}) {
120
120
  `<< HTTP`,
121
121
  (0, request_log_util_1.coloredHttpCode)(statusCode),
122
122
  (0, colors_1.dimGrey)((0, js_lib_1._since)(started)),
123
- (0, util_1.inspect)((0, js_lib_1._filterFalsyValues)({ countHealthy, countUnhealthy }), inspectOpt),
123
+ (0, node_util_1.inspect)((0, js_lib_1._filterFalsyValues)({ countHealthy, countUnhealthy }), inspectOpt),
124
124
  ].join(' '));
125
125
  if (attempt >= maxTries) {
126
126
  doneReason = `reached maxTries of ${maxTries}`;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.testDir = exports.srcDir = exports.resourcesDir = exports.projectDir = void 0;
4
- const path = require("path");
4
+ const path = require("node:path");
5
5
  exports.projectDir = path.join(__dirname, '/..');
6
6
  exports.resourcesDir = `${exports.projectDir}/resources`;
7
7
  exports.srcDir = `${exports.projectDir}/src`;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.appEngineLogMiddleware = exports.ciLogger = exports.devLogger = exports.gaeLogger = void 0;
4
- const util_1 = require("util");
4
+ const node_util_1 = require("node:util");
5
5
  const colors_1 = require("@naturalcycles/nodejs-lib/dist/colors");
6
6
  const nodejs_lib_1 = require("@naturalcycles/nodejs-lib");
7
7
  const { GOOGLE_CLOUD_PROJECT, GAE_INSTANCE } = process.env;
@@ -37,7 +37,7 @@ exports.ciLogger = {
37
37
  // Documented here: https://cloud.google.com/logging/docs/structured-logging
38
38
  function logToAppEngine(meta, args) {
39
39
  console.log(JSON.stringify({
40
- message: args.map(a => (typeof a === 'string' ? a : (0, util_1.inspect)(a))).join(' '),
40
+ message: args.map(a => (typeof a === 'string' ? a : (0, node_util_1.inspect)(a))).join(' '),
41
41
  ...meta,
42
42
  }));
43
43
  }
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.requestLogger = exports.getRequestLogger = exports.getRequest = exports.asyncLocalStorageMiddleware = void 0;
4
- const async_hooks_1 = require("async_hooks");
4
+ const node_async_hooks_1 = require("node:async_hooks");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  const appEngineLogMiddleware_1 = require("./appEngineLogMiddleware");
7
7
  const { GAE_INSTANCE, CI } = process.env;
@@ -9,7 +9,7 @@ const isGAE = !!GAE_INSTANCE;
9
9
  const isCI = !!CI;
10
10
  // Singleton, for simplicity
11
11
  // Create it lazily (on demand)
12
- const storage = (0, js_lib_1._lazyValue)(() => new async_hooks_1.AsyncLocalStorage());
12
+ const storage = (0, js_lib_1._lazyValue)(() => new node_async_hooks_1.AsyncLocalStorage());
13
13
  function asyncLocalStorageMiddleware() {
14
14
  return (req, res, next) => {
15
15
  const store = {
@@ -7,7 +7,7 @@ import { GenericErrorMiddlewareCfg } from './genericErrorMiddleware';
7
7
  * Plain RequestHandler can be provided - then it's mounted to /
8
8
  * Otherwise `path` can be provided to specify mounting point.
9
9
  */
10
- export declare type BackendRequestHandlerCfg = BackendRequestHandler | BackendRequestHandlerWithPath;
10
+ export type BackendRequestHandlerCfg = BackendRequestHandler | BackendRequestHandlerWithPath;
11
11
  export interface BackendRequestHandlerWithPath {
12
12
  path: string;
13
13
  handler: BackendRequestHandler;
@@ -1,7 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getDeployInfo = void 0;
4
- const fs = require("fs");
4
+ const fs = require("node:fs");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  exports.getDeployInfo = (0, js_lib_1._memoFn)((projectDir) => {
7
7
  const deployInfoPath = `${projectDir}/deployInfo.json`;
@@ -20,11 +20,11 @@ export interface BackendRequest extends Request {
20
20
  requestTimeout?: NodeJS.Timeout;
21
21
  bodyParserTimeout?: NodeJS.Timeout;
22
22
  }
23
- export declare type BackendResponse = Response;
24
- export declare type BackendRequestHandler = (req: BackendRequest, res: BackendResponse, next: NextFunction) => void;
25
- export declare type BackendErrorRequestHandler = (err: any, req: BackendRequest, res: BackendResponse, next: NextFunction) => void;
26
- export declare type BackendRouter = IRouter;
27
- export declare type BackendApplication = Application;
23
+ export type BackendResponse = Response;
24
+ export type BackendRequestHandler = (req: BackendRequest, res: BackendResponse, next: NextFunction) => void;
25
+ export type BackendErrorRequestHandler = (err: any, req: BackendRequest, res: BackendResponse, next: NextFunction) => void;
26
+ export type BackendRouter = IRouter;
27
+ export type BackendApplication = Application;
28
28
  declare module 'http' {
29
29
  interface IncomingMessage {
30
30
  log: CommonLogFunction;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Server } from 'http';
2
+ import { Server } from 'node:http';
3
3
  export interface DestroyableServer extends Server {
4
4
  destroy(): Promise<void>;
5
5
  }
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Server } from 'http';
2
+ import { Server } from 'node:http';
3
3
  import { StartServerCfg, StartServerData } from './startServer.model';
4
4
  export declare class BackendServer {
5
5
  private cfg;
@@ -1,5 +1,5 @@
1
1
  /// <reference types="node" />
2
- import { Server } from 'http';
2
+ import { Server } from 'node:http';
3
3
  import { SentrySharedService } from '../sentry/sentry.shared.service';
4
4
  import { DefaultAppCfg } from './createDefaultApp.model';
5
5
  import { BackendApplication } from './server.model';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/backend-lib",
3
- "version": "4.8.2",
3
+ "version": "4.8.3",
4
4
  "scripts": {
5
5
  "prepare": "husky install && patch-package",
6
6
  "serve": "APP_ENV=dev nodemon",
@@ -30,7 +30,7 @@
30
30
  "express": "^4.16.4",
31
31
  "express-promise-router": "^4.0.0",
32
32
  "firebase-admin": "^11.0.0",
33
- "fs-extra": "^10.0.0",
33
+ "fs-extra": "^11.0.0",
34
34
  "helmet": "^6.0.0",
35
35
  "js-yaml": "^4.0.0",
36
36
  "on-finished": "^2.3.0",
@@ -49,14 +49,10 @@
49
49
  "jest": "^29.0.1",
50
50
  "nodemon": "^2.0.14",
51
51
  "patch-package": "^6.2.1",
52
- "prettier": "^2.0.0",
53
52
  "vue-class-component": "^7.2.6",
54
53
  "vuepress": "^1.7.1",
55
54
  "vuepress-plugin-typescript": "^0.3.1"
56
55
  },
57
- "resolutions": {
58
- "prettier": "^2.0.0"
59
- },
60
56
  "files": [
61
57
  "dist",
62
58
  "cfg",
@@ -82,7 +78,7 @@
82
78
  "url": "https://github.com/NaturalCycles/backend-lib"
83
79
  },
84
80
  "engines": {
85
- "node": ">=14.15.0"
81
+ "node": ">=16.10.0"
86
82
  },
87
83
  "type": "commonjs",
88
84
  "description": "Standard library for making Express.js / AppEngine based backend services",
@@ -1,4 +1,4 @@
1
- import * as fs from 'fs'
1
+ import * as fs from 'node:fs'
2
2
  import { Admin401ErrorData, HttpError, _memoFn } from '@naturalcycles/js-lib'
3
3
  import * as ejs from 'ejs'
4
4
  import { BackendRequestHandler } from '../server/server.model'
package/src/db/httpDB.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { Readable } from 'stream'
1
+ import { Readable } from 'node:stream'
2
2
  import { JsonSchemaRootObject, ObjectWithId } from '@naturalcycles/js-lib'
3
3
  import {
4
4
  BaseCommonDB,
@@ -1,4 +1,4 @@
1
- import * as fs from 'fs'
1
+ import * as fs from 'node:fs'
2
2
  import { _mapValues, _merge, _truncate, localTime } from '@naturalcycles/js-lib'
3
3
  import { dimGrey, white } from '@naturalcycles/nodejs-lib/dist/colors'
4
4
  import * as yaml from 'js-yaml'
@@ -1,4 +1,4 @@
1
- import { inspect, InspectOptions } from 'util'
1
+ import { inspect, InspectOptions } from 'node:util'
2
2
  import { pDelay, _filterFalsyValues, _ms, _since } from '@naturalcycles/js-lib'
3
3
  import { getGot } from '@naturalcycles/nodejs-lib'
4
4
  import { dimGrey, red } from '@naturalcycles/nodejs-lib/dist/colors'
package/src/paths.cnst.ts CHANGED
@@ -1,4 +1,4 @@
1
- import * as path from 'path'
1
+ import * as path from 'node:path'
2
2
 
3
3
  export const projectDir = path.join(__dirname, '/..')
4
4
  export const resourcesDir = `${projectDir}/resources`
@@ -1,4 +1,4 @@
1
- import { inspect } from 'util'
1
+ import { inspect } from 'node:util'
2
2
  import { dimGrey } from '@naturalcycles/nodejs-lib/dist/colors'
3
3
  import { inspectAny } from '@naturalcycles/nodejs-lib'
4
4
  import { AnyObject, CommonLogger } from '@naturalcycles/js-lib'
@@ -1,4 +1,4 @@
1
- import { AsyncLocalStorage } from 'async_hooks'
1
+ import { AsyncLocalStorage } from 'node:async_hooks'
2
2
  import { _lazyValue, CommonLogger } from '@naturalcycles/js-lib'
3
3
  import { BackendRequest, BackendRequestHandler } from './server.model'
4
4
  import { gaeLogger, devLogger, ciLogger } from './appEngineLogMiddleware'
@@ -1,4 +1,4 @@
1
- import * as fs from 'fs'
1
+ import * as fs from 'node:fs'
2
2
  import { _memoFn } from '@naturalcycles/js-lib'
3
3
  import type { DeployInfo } from '../deploy'
4
4
 
@@ -1,5 +1,5 @@
1
- import { Server } from 'http'
2
- import { Socket } from 'net'
1
+ import { Server } from 'node:http'
2
+ import { Socket } from 'node:net'
3
3
  import { StringMap } from '@naturalcycles/js-lib'
4
4
 
5
5
  export interface DestroyableServer extends Server {
@@ -1,4 +1,4 @@
1
- import { Server } from 'http'
1
+ import { Server } from 'node:http'
2
2
  import { SentrySharedService } from '../sentry/sentry.shared.service'
3
3
  import { DefaultAppCfg } from './createDefaultApp.model'
4
4
  import { BackendApplication } from './server.model'
@@ -1,4 +1,4 @@
1
- import { Server } from 'http'
1
+ import { Server } from 'node:http'
2
2
  import { _Memo, _ms } from '@naturalcycles/js-lib'
3
3
  import { boldGrey, dimGrey, white } from '@naturalcycles/nodejs-lib/dist/colors'
4
4
  import { createDefaultApp } from '../index'
@@ -1,5 +1,5 @@
1
- import { Server } from 'http'
2
- import { AddressInfo } from 'net'
1
+ import { Server } from 'node:http'
2
+ import { AddressInfo } from 'node:net'
3
3
  import { getGot, GetGotOptions, Got } from '@naturalcycles/nodejs-lib'
4
4
  import { BackendApplication, createDefaultApp, DefaultAppCfg } from '../index'
5
5
  import { BackendRequestHandlerCfg } from '../server/createDefaultApp.model'