@bigid/apps-infrastructure-node-js 1.191.0 → 1.194.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.
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.fetchLogs = void 0;
4
4
  const fs_1 = require("fs");
5
5
  const constants_1 = require("../utils/constants");
6
+ const READONLY_MODE_ENABLED = process.env.READONLY_MODE_ENABLED === "true";
7
+ const logFolder = READONLY_MODE_ENABLED ? constants_1.TMP_LOGS_PATH : constants_1.LOGS_PATH;
6
8
  const fetchLogs = (req, res) => {
7
9
  const tenantId = req.headers.tenantid;
8
- const data = (0, fs_1.readFileSync)(constants_1.LOGS_PATH, { encoding: 'utf8' });
10
+ const data = (0, fs_1.readFileSync)(logFolder, { encoding: 'utf8' });
9
11
  const lines = data.split('\n');
10
12
  const tenantLogLines = lines
11
13
  .filter(line => line.includes(`[tenantId: ${tenantId}`) || !line.includes('[tenantId: '))
package/lib/server.js CHANGED
@@ -45,7 +45,6 @@ const http_errors_1 = __importDefault(require("http-errors"));
45
45
  const configureProvider_1 = require("./abstractProviders/configureProvider");
46
46
  const app = (0, express_1.default)();
47
47
  const deployServer = ({ manifestController, iconsController, executionController, serverPort, configureController, additionalEndpoints, expressBodyLimit, }) => {
48
- app.use(express_1.default.json());
49
48
  app.use(express_1.default.urlencoded({ extended: false }));
50
49
  app.use(bodyParser.json({ limit: expressBodyLimit || '5mb' }));
51
50
  app.get('/assets/icon', (req, res) => res.sendFile(iconsController.getIconPath()));
@@ -4,6 +4,7 @@ exports.logDebug = exports.logWarn = exports.logError = exports.logInfo = void 0
4
4
  const log4js_1 = require("log4js");
5
5
  const constants_1 = require("./constants");
6
6
  const USER_LOG_BACKUPS = parseInt(process.env.LOG_BACKUPS + "") || 3;
7
+ const READONLY_MODE_ENABLED = process.env.READONLY_MODE_ENABLED === "true";
7
8
  const MAX_BACKUPS = 10;
8
9
  (0, log4js_1.configure)({
9
10
  appenders: {
@@ -11,7 +12,7 @@ const MAX_BACKUPS = 10;
11
12
  dateFile: {
12
13
  type: 'dateFile',
13
14
  layout: { type: 'basic' },
14
- filename: constants_1.LOGS_PATH,
15
+ filename: READONLY_MODE_ENABLED ? constants_1.TMP_LOGS_PATH : constants_1.LOGS_PATH,
15
16
  compress: true,
16
17
  numBackups: USER_LOG_BACKUPS > MAX_BACKUPS ? MAX_BACKUPS : USER_LOG_BACKUPS,
17
18
  keepFileExt: true,
@@ -1 +1,2 @@
1
1
  export declare const LOGS_PATH = "log/app.log";
2
+ export declare const TMP_LOGS_PATH = "/tmp/log/app.log";
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.LOGS_PATH = void 0;
3
+ exports.TMP_LOGS_PATH = exports.LOGS_PATH = void 0;
4
4
  exports.LOGS_PATH = 'log/app.log';
5
+ exports.TMP_LOGS_PATH = '/tmp/log/app.log';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bigid/apps-infrastructure-node-js",
3
- "version": "1.191.0",
3
+ "version": "1.194.0",
4
4
  "description": "",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {
@@ -1,10 +1,14 @@
1
1
  import { readFileSync } from 'fs';
2
2
  import { Request, Response } from 'express';
3
- import { LOGS_PATH } from '../utils/constants';
3
+ import {LOGS_PATH, TMP_LOGS_PATH} from '../utils/constants';
4
+
5
+ const READONLY_MODE_ENABLED = process.env.READONLY_MODE_ENABLED === "true";
6
+
7
+ const logFolder = READONLY_MODE_ENABLED ? TMP_LOGS_PATH : LOGS_PATH
4
8
 
5
9
  export const fetchLogs = (req: Request, res: Response) => {
6
10
  const tenantId = req.headers.tenantid;
7
- const data = readFileSync(LOGS_PATH, { encoding: 'utf8' });
11
+ const data = readFileSync(logFolder, { encoding: 'utf8' });
8
12
  const lines = data.split('\n');
9
13
  const tenantLogLines = lines
10
14
  .filter(line => line.includes(`[tenantId: ${tenantId}`) || !line.includes('[tenantId: '))
package/src/server.ts CHANGED
@@ -29,7 +29,6 @@ export const deployServer = ({
29
29
  additionalEndpoints,
30
30
  expressBodyLimit,
31
31
  }: ServerInit): void => {
32
- app.use(express.json());
33
32
  app.use(express.urlencoded({ extended: false }));
34
33
  app.use(bodyParser.json({ limit: expressBodyLimit || '5mb' }));
35
34
 
@@ -1,5 +1,5 @@
1
1
  import { configure, getLogger } from 'log4js';
2
- import { LOGS_PATH } from './constants';
2
+ import { LOGS_PATH, TMP_LOGS_PATH } from './constants';
3
3
 
4
4
  type LogMetadata = {
5
5
  tenantId: string;
@@ -7,6 +7,8 @@ type LogMetadata = {
7
7
  scriptName: string;
8
8
  };
9
9
  const USER_LOG_BACKUPS = parseInt(process.env.LOG_BACKUPS + "") || 3;
10
+
11
+ const READONLY_MODE_ENABLED = process.env.READONLY_MODE_ENABLED === "true";
10
12
  const MAX_BACKUPS = 10;
11
13
 
12
14
  configure({
@@ -15,7 +17,7 @@ configure({
15
17
  dateFile: {
16
18
  type: 'dateFile',
17
19
  layout: { type: 'basic' },
18
- filename: LOGS_PATH,
20
+ filename: READONLY_MODE_ENABLED ? TMP_LOGS_PATH : LOGS_PATH,
19
21
  compress: true,
20
22
  numBackups: USER_LOG_BACKUPS > MAX_BACKUPS ? MAX_BACKUPS : USER_LOG_BACKUPS,
21
23
  keepFileExt: true,
@@ -32,9 +34,9 @@ const formatLog = (message: string, logMetadata?: LogMetadata): string => {
32
34
  if (!logMetadata) return message;
33
35
 
34
36
  const params = Object.entries(logMetadata)
35
- .filter(([value]) => value)
36
- .map(([key, value]) => `[${key}: ${value}]`)
37
- .join(' ');
37
+ .filter(([value]) => value)
38
+ .map(([key, value]) => `[${key}: ${value}]`)
39
+ .join(' ');
38
40
  return `${params} ${message}`;
39
41
  };
40
42
 
@@ -1 +1,2 @@
1
- export const LOGS_PATH = 'log/app.log';
1
+ export const LOGS_PATH = 'log/app.log';
2
+ export const TMP_LOGS_PATH = '/tmp/log/app.log';