@canmingir/link-express 1.6.9 → 1.6.11

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.
@@ -46,7 +46,6 @@ jobs:
46
46
  id: version_bump
47
47
  run: |
48
48
  npm version ${{ github.event.inputs.version_type }} -m "Bump version to %s [skip ci]"
49
- echo "new_version=$(node -p "require('./package.json').version")" >> $GITHUB_OUTPUT
50
49
  git push --follow-tags
51
50
 
52
51
  - name: Publish to NPM
@@ -54,11 +53,4 @@ jobs:
54
53
  run: npm publish --access public
55
54
  env:
56
55
  NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
57
-
58
- - name: Revert version bump on failure
59
- if: failure() && steps.version_bump.outcome == 'success'
60
- run: |
61
- git reset --hard HEAD~1
62
- git tag -d v${{ steps.version_bump.outputs.new_version }}
63
- git push --force
64
- git push --delete origin v${{ steps.version_bump.outputs.new_version }}
56
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@canmingir/link-express",
3
- "version": "1.6.9",
3
+ "version": "1.6.11",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "author": "NucTeam",
@@ -21,6 +21,7 @@
21
21
  "dependencies": {
22
22
  "@aws-sdk/client-dynamodb": "^3.614.0",
23
23
  "@aws-sdk/lib-dynamodb": "^3.614.0",
24
+ "@elastic/ecs-pino-format": "^1.5.0",
24
25
  "axios": "^1.7.2",
25
26
  "cors": "^2.8.5",
26
27
  "dotenv": "^16.4.5",
@@ -33,6 +34,8 @@
33
34
  "lodash": "^4.17.21",
34
35
  "morgan": "^1.10.0",
35
36
  "pg": "^8.12.0",
37
+ "pino": "^10.1.0",
38
+ "pino-elasticsearch": "^8.1.0",
36
39
  "prom-client": "^15.1.3",
37
40
  "sequelize": "^6.37.3",
38
41
  "swagger-jsdoc": "^6.2.8",
package/src/logger.js ADDED
@@ -0,0 +1,34 @@
1
+ const { ecsFormat } = require("@elastic/ecs-pino-format");
2
+ const pino = require("pino");
3
+ const pinoElastic = require("pino-elasticsearch");
4
+
5
+ const config = require("./config");
6
+
7
+ const { logger: loggerConfig, project } = config();
8
+
9
+ const streams = [{ stream: process.stdout }];
10
+
11
+ const streamToElastic = pinoElastic({
12
+ index: loggerConfig.elasticsearch.index,
13
+ consistency: loggerConfig.elasticsearch.consistency || "one",
14
+ node: loggerConfig.elasticsearch.node,
15
+ esVersion: loggerConfig.elasticsearch.esVersion || 8,
16
+ flushBytes: loggerConfig.elasticsearch.flushBytes || 1000,
17
+ });
18
+
19
+ streams.push({ stream: streamToElastic });
20
+
21
+ const logger = pino(
22
+ {
23
+ ...ecsFormat(),
24
+ base: {
25
+ service: {
26
+ name: project.name,
27
+ version: project.version,
28
+ },
29
+ },
30
+ },
31
+ pino.multistream(streams)
32
+ );
33
+
34
+ module.exports = logger;
@@ -48,7 +48,7 @@ class DBMetrics {
48
48
  url: metrics.url || "http://localhost:9091",
49
49
  jobName: metrics.pushGateway.jobName || "api",
50
50
  instance: metrics.pushGateway.instance || "database",
51
- interval: config.interval || 15000,
51
+ interval: metrics.interval || 15000,
52
52
  };
53
53
 
54
54
  this.stopPushgateway();
package/src/platform.js CHANGED
@@ -5,6 +5,7 @@ const error = require("./error");
5
5
  let _express;
6
6
  let _postgres;
7
7
  let _dynamodb;
8
+ let _logger;
8
9
 
9
10
  function init(config = {}) {
10
11
  return new Promise((resolve, reject) => {
@@ -13,10 +14,16 @@ function init(config = {}) {
13
14
  module.exports = fs.readFileSync(filename, "utf8").trim();
14
15
  };
15
16
 
16
- const { postgres, dynamodb } = require("./config").init(config);
17
+ const { postgres, dynamodb, logger } = require("./config").init(config);
17
18
 
18
19
  _express = require("./express");
19
20
 
21
+ if (logger) {
22
+ _logger = require("./logger");
23
+ } else {
24
+ _logger = console;
25
+ }
26
+
20
27
  if (postgres) {
21
28
  _postgres = require("./postgres");
22
29
  }
@@ -43,4 +50,7 @@ module.exports = {
43
50
  require: (pkg) => require(pkg),
44
51
  authorization,
45
52
  error,
53
+ get logger() {
54
+ return _logger;
55
+ },
46
56
  };