@autofleet/node-common 1.6.1 → 1.7.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.
package/logger/example.js CHANGED
@@ -1,5 +1,5 @@
1
1
  const logger = require('./index')();
2
2
 
3
3
  logger.info('it is working');
4
- logger.error('errors displayed in logs/error.log');
4
+ logger.error('errors displayed in logs/error.log', { e: new Error('test error') });
5
5
  logger.debug('debug with object', { a: 5 });
package/logger/index.js CHANGED
@@ -11,6 +11,11 @@ const infoEnvNmaes = [
11
11
  'test',
12
12
  ];
13
13
 
14
+ const serializeError = (error) => {
15
+ const fields = ['code', 'status', 'statusCode', 'message', 'messageData', 'name', 'stack', 'stackTrace'];
16
+ return fields.reduce((v, field) => ({ ...v, [field]: error[field] }), {});
17
+ };
18
+
14
19
  const getLevel = (logLevel) => {
15
20
  if (logLevel) return logLevel;
16
21
  if (env.LOG_LEVEL) return env.LOG_LEVEL;
@@ -21,7 +26,7 @@ const getLevel = (logLevel) => {
21
26
 
22
27
  const enumerateErrorFormat = winston.format((info) => {
23
28
  if (info.message instanceof Error) {
24
- info.message = Object.assign({ // eslint-disable-line
29
+ info.message = Object.assign({ // eslint-disable-line
25
30
  message: info.message.message,
26
31
  stack: info.message.stack,
27
32
  }, info.message);
@@ -32,6 +37,15 @@ const enumerateErrorFormat = winston.format((info) => {
32
37
  stack: info.stack,
33
38
  }, info);
34
39
  }
40
+
41
+ // eslint-disable-next-line array-callback-return
42
+ Object.keys(info).map((k) => {
43
+ if (info[k] instanceof Error) {
44
+ // eslint-disable-next-line no-param-reassign
45
+ info[k] = serializeError(info[k]);
46
+ }
47
+ });
48
+
35
49
  return info;
36
50
  });
37
51
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@autofleet/node-common",
3
- "version": "1.6.1",
3
+ "version": "1.7.1",
4
4
  "description": "",
5
5
  "scripts": {
6
6
  "coverage": "jest --coverage --forceExit --runInBand",
@@ -1,26 +0,0 @@
1
- version: 2
2
- jobs:
3
- test:
4
- docker:
5
- - image: circleci/node:11.14.0
6
- steps:
7
- - checkout
8
- - restore_cache:
9
- keys:
10
- - v1-dependencies-{{ checksum "package.json" }}
11
- # fallback to using the latest cache if no exact match is found
12
- - v1-dependencies-
13
- - run: npm i
14
- - save_cache:
15
- paths:
16
- - node_modules
17
- key: v1-dependencies-{{ checksum "package.json" }}
18
- - run: npm run coverage
19
- - run: rm -rf ./coverage
20
- - run: npm run linter
21
-
22
- workflows:
23
- version: 2
24
- build_and_test:
25
- jobs:
26
- - test
@@ -1,10 +0,0 @@
1
- version: 1
2
- update_configs:
3
- - package_manager: "javascript"
4
- directory: "/"
5
- update_schedule: "daily"
6
- allowed_updates:
7
- - match:
8
- dependency_name: "@autofleet/*"
9
- - match:
10
- update_type: "security"
package/.eslintrc.json DELETED
@@ -1,8 +0,0 @@
1
- {
2
- "extends": [
3
- "airbnb/base"
4
- ],
5
- "env": {
6
- "jest": true
7
- }
8
- }
@@ -1,37 +0,0 @@
1
- # This workflow will run tests using node and then publish a package to GitHub Packages when a release is created
2
- # For more information see: https://help.github.com/actions/language-and-framework-guides/publishing-nodejs-packages
3
-
4
- name: Node.js Package
5
-
6
- on:
7
- push:
8
- branches: [ master ]
9
-
10
- jobs:
11
- npm-test:
12
- runs-on: ubuntu-latest
13
- steps:
14
- - uses: actions/checkout@v2
15
- - uses: actions/setup-node@v1
16
- with:
17
- node-version: 12
18
- registry-url: https://registry.npmjs.org/
19
- - run: npm ci
20
- - run: npm run linter
21
- - run: npm run coverage
22
- - run: rm -rf ./coverage
23
- env:
24
- NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
25
-
26
- publish-npm:
27
- needs: npm-test
28
- runs-on: ubuntu-latest
29
- steps:
30
- - uses: actions/checkout@v2
31
- - uses: actions/setup-node@v1
32
- with:
33
- node-version: 12
34
- registry-url: https://registry.npmjs.org/
35
- - run: npm publish
36
- env:
37
- NODE_AUTH_TOKEN: ${{secrets.NPM_TOKEN}}
package/.gitlab-ci.yml DELETED
@@ -1,13 +0,0 @@
1
- image: node:11.14.0
2
-
3
- stages:
4
- - test
5
-
6
- before_script:
7
- - node -v
8
- - npm -v
9
- - npm install
10
- test:
11
- stage: test
12
- script:
13
- - npm run coverage
@@ -1,14 +0,0 @@
1
- {
2
- // Use IntelliSense to learn about possible attributes.
3
- // Hover to view descriptions of existing attributes.
4
- // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
5
- "version": "0.2.0",
6
- "configurations": [
7
- {
8
- "type": "node",
9
- "request": "launch",
10
- "name": "Launch Program",
11
- "program": "${workspaceFolder}/events/index.js"
12
- }
13
- ]
14
- }