@tinyhttp/logger
Advanced tools
@@ -1,1 +0,1 @@ | ||
| import o from"colors";export default(e=["GET","POST","PUT"])=>(s,t)=>{const{method:a,url:c}=s,{statusCode:l,statusMessage:r}=t;if(a&&e.includes(a)){const e=l.toString();let s=e,t=r;switch(e[0]){case"2":s=o.cyan.bold(e),t=o.cyan(t),console.log(`${s} ${t} ${c}`);break;case"4":s=o.red.bold(e),t=o.red(t),console.log(`${s} ${t} ${c}`);break;case"5":s=o.magenta.bold(e),t=o.magenta(t),console.error(`${s} ${t} ${c}`)}}}; | ||
| import o from"colors";export default(e=["GET","POST","PUT"])=>(s,t)=>{t.on("finish",()=>{const{method:a,url:c}=s,{statusCode:l,statusMessage:n}=t;if(a&&e.includes(a)){const e=l.toString();let s=e,t=n;switch(e[0]){case"2":s=o.cyan.bold(e),t=o.cyan(t),console.log(`${s} ${t} ${c}`);break;case"4":s=o.red.bold(e),t=o.red(t),console.log(`${s} ${t} ${c}`);break;case"5":s=o.magenta.bold(e),t=o.magenta(t),console.error(`${s} ${t} ${c}`)}}})}; |
+1
-1
@@ -1,1 +0,1 @@ | ||
| "use strict";var e,o=(e=require("colors"))&&"object"==typeof e&&"default"in e?e.default:e;module.exports=(e=["GET","POST","PUT"])=>(s,t)=>{const{method:a,url:c}=s,{statusCode:l,statusMessage:r}=t;if(a&&e.includes(a)){const e=l.toString();let s=e,t=r;switch(e[0]){case"2":s=o.cyan.bold(e),t=o.cyan(t),console.log(`${s} ${t} ${c}`);break;case"4":s=o.red.bold(e),t=o.red(t),console.log(`${s} ${t} ${c}`);break;case"5":s=o.magenta.bold(e),t=o.magenta(t),console.error(`${s} ${t} ${c}`)}}}; | ||
| "use strict";var e,o=(e=require("colors"))&&"object"==typeof e&&"default"in e?e.default:e;module.exports=(e=["GET","POST","PUT"])=>(s,t)=>{t.on("finish",()=>{const{method:a,url:c}=s,{statusCode:l,statusMessage:r}=t;if(a&&e.includes(a)){const e=l.toString();let s=e,t=r;switch(e[0]){case"2":s=o.cyan.bold(e),t=o.cyan(t),console.log(`${s} ${t} ${c}`);break;case"4":s=o.red.bold(e),t=o.red(t),console.log(`${s} ${t} ${c}`);break;case"5":s=o.magenta.bold(e),t=o.magenta(t),console.error(`${s} ${t} ${c}`)}}})}; |
+28
-26
| { | ||
| "name": "@tinyhttp/logger", | ||
| "version": "0.1.20", | ||
| "description": "tinyhttp logger module", | ||
| "homepage": "https://github.com/talentlessguy/tinyhttp", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/talentlessguy/tinyhttp.git", | ||
| "directory": "packages/logger" | ||
| }, | ||
| "main": "dist/index.js", | ||
| "types": "dist/index.d.ts", | ||
| "module": "dist/index.esm.js", | ||
| "keywords": [ | ||
| "tinyhttp", | ||
| "node.js", | ||
| "web framework", | ||
| "web", | ||
| "backend", | ||
| "logger" | ||
| ], | ||
| "author": "v1rtl", | ||
| "license": "MIT", | ||
| "dependencies": { | ||
| "colors": "^1.4.0" | ||
| }, | ||
| "gitHead": "584a7d9a98e23543ef5285af59532a583c578d11" | ||
| "name": "@tinyhttp/logger", | ||
| "version": "0.1.21", | ||
| "description": "tinyhttp logger module", | ||
| "homepage": "https://github.com/talentlessguy/tinyhttp", | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "https://github.com/talentlessguy/tinyhttp.git", | ||
| "directory": "packages/logger" | ||
| }, | ||
| "main": "dist/index.js", | ||
| "types": "dist/index.d.ts", | ||
| "module": "dist/index.esm.js", | ||
| "keywords": [ | ||
| "tinyhttp", | ||
| "node.js", | ||
| "web framework", | ||
| "web", | ||
| "backend", | ||
| "logger" | ||
| ], | ||
| "author": "v1rtl", | ||
| "license": "MIT", | ||
| "dependencies": { | ||
| "colors": "^1.4.0" | ||
| }, | ||
| "engines": { | ||
| "node": ">=12.4.0" | ||
| } | ||
| } |
+1
-1
@@ -15,3 +15,3 @@ # @tinyhttp/logger | ||
| ```sh | ||
| npm install @tinyhttp/logger --save | ||
| pnpm i @tinyhttp/logger --save | ||
| ``` | ||
@@ -18,0 +18,0 @@ |
+25
-23
@@ -6,29 +6,31 @@ import colors from 'colors' | ||
| const logger = (req: Request, res: Response) => { | ||
| const { method, url } = req | ||
| const { statusCode, statusMessage } = res | ||
| res.on('finish', () => { | ||
| const { method, url } = req | ||
| const { statusCode, statusMessage } = res | ||
| if (method && methods.includes(method)) { | ||
| const s = statusCode.toString() | ||
| if (method && methods.includes(method)) { | ||
| const s = statusCode.toString() | ||
| let status: string = s | ||
| let msg: string = statusMessage | ||
| let status: string = s | ||
| let msg: string = statusMessage | ||
| switch (s[0]) { | ||
| case '2': | ||
| status = colors.cyan.bold(s) | ||
| msg = colors.cyan(msg) | ||
| console.log(`${status} ${msg} ${url}`) | ||
| break | ||
| case '4': | ||
| status = colors.red.bold(s) | ||
| msg = colors.red(msg) | ||
| console.log(`${status} ${msg} ${url}`) | ||
| break | ||
| case '5': | ||
| status = colors.magenta.bold(s) | ||
| msg = colors.magenta(msg) | ||
| console.error(`${status} ${msg} ${url}`) | ||
| break | ||
| switch (s[0]) { | ||
| case '2': | ||
| status = colors.cyan.bold(s) | ||
| msg = colors.cyan(msg) | ||
| console.log(`${status} ${msg} ${url}`) | ||
| break | ||
| case '4': | ||
| status = colors.red.bold(s) | ||
| msg = colors.red(msg) | ||
| console.log(`${status} ${msg} ${url}`) | ||
| break | ||
| case '5': | ||
| status = colors.magenta.bold(s) | ||
| msg = colors.magenta(msg) | ||
| console.error(`${status} ${msg} ${url}`) | ||
| break | ||
| } | ||
| } | ||
| } | ||
| }) | ||
| } | ||
@@ -35,0 +37,0 @@ |
-21
| MIT License | ||
| Copyright (c) 2020 v 1 r t l | ||
| Permission is hereby granted, free of charge, to any person obtaining a copy | ||
| of this software and associated documentation files (the "Software"), to deal | ||
| in the Software without restriction, including without limitation the rights | ||
| to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
| copies of the Software, and to permit persons to whom the Software is | ||
| furnished to do so, subject to the following conditions: | ||
| The above copyright notice and this permission notice shall be included in all | ||
| copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
| OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
| SOFTWARE. |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
43
4.88%3340
-21.65%6
-14.29%