Last active
April 14, 2020 09:21
-
-
Save Muzammil-Bilwani/9d56586ceaffffc7cd4035c333d42008 to your computer and use it in GitHub Desktop.
Morgan template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import morgan from "morgan"; | |
import e from "express"; | |
const loggerTemplate = ( | |
tokens: morgan.TokenIndexer, | |
req: e.Request, | |
res: e.Response | |
) => | |
[ | |
tokens.method(req, res), | |
tokens.url(req, res), | |
tokens.status(req, res), | |
tokens.res(req, res, "content-length"), | |
"-", | |
tokens["response-time"](req, res), | |
"ms" | |
].join(" "); | |
export default loggerTemplate; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Some awesome Code | |
// Here you can use morgan | |
app.use(morgan(loggerTemplate)) | |
// Some more awesome code |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment