micronodelib 1.0.7 → 1.0.9

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.
Files changed (3) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +20 -5
  3. package/package.json +3 -2
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 ZENTHANG
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
package/README.md CHANGED
@@ -20,22 +20,26 @@ yarn add micronodelib
20
20
 
21
21
  ## Usage
22
22
 
23
- ```shell
23
+ ```javascript
24
24
  import express, {Application} from "express";
25
25
  import {Logger, httpContextMiddleware, requestLogMiddleware} from "micronodelib";
26
26
  const app: Application = express();
27
27
 
28
- # Enable request context
28
+ // Optional, if you want to override default console log
29
+ console.log = Logger.info
30
+ console.error = Logger.error
31
+
32
+ // Enable request context
29
33
  app.use(httpContextMiddleware());
30
34
 
31
- # Enable http request log
35
+ // Enable http request log
32
36
  app.use(requestLogMiddleware({
33
- # Ignore request log for specific routes
37
+ // Ignore request log for specific routes
34
38
  ignoreRoutes: ["/actuator/health"]
35
39
  }));
36
40
 
37
41
  app.listen(3000, () => {
38
- # Using standard log level: debug, info, warn, error
42
+ // Using standard log level: debug, info, warn, error
39
43
  Logger.info('App started');
40
44
  })
41
45
  ```
@@ -51,3 +55,14 @@ app.listen(3000, () => {
51
55
  ```json
52
56
  {"level":"INFO","msg":"finish router","request_meta":{"client_ip":null,"execution_time":4,"query":"","request_id":"a06dd50a-7127-4f87-bfe0-b7104fb453c9","request_method":"GET","request_path":"/example-path","request_pattern":"/example-path","status":200,"url":"/example-path","user_agent":"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.64 Safari/537.36"},"ts":1652842718}
53
57
  ```
58
+
59
+ ## Development
60
+
61
+ This package has been published at: https://www.npmjs.com/package/micronodelib
62
+
63
+ If you want to push new change to this, follow the following steps:
64
+
65
+ 1. Make change your code
66
+ 2. Update version in [package.json](./package.json)
67
+ 3. Push new update to `main` remote branch.
68
+ 4. Run `npm publish` to publish your changes.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "micronodelib",
3
- "version": "1.0.7",
3
+ "version": "1.0.9",
4
4
  "description": "Common core for NodeJs project",
5
5
  "author": "Thang Bui",
6
6
  "license": "MIT",
@@ -12,7 +12,8 @@
12
12
  "dependencies": {
13
13
  "express-http-context": "^1.2.4",
14
14
  "express-winston": "^4.2.0",
15
- "uuid": "^8.3.2"
15
+ "uuid": "^8.3.2",
16
+ "winston": "^3.8.2"
16
17
  },
17
18
  "devDependencies": {
18
19
  "@types/uuid": "^8.3.4",