How to use the morgan.remote-addr function in morgan

To help you get started, we’ve selected a few morgan examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github interfaced / zombiebox / lib / server.js View on Github external
this._app.use((req, res, next) => {
			const {pathname} = new URL(req.url, 'request-target://');

			switch (pathname) {
				case '/':
				case '/index.html':
					const remoteAddress = morgan['remote-addr'](req);
					const userAgent = morgan['user-agent'](req);

					console.log(
						chalk.cyan((new Date()).toLocaleTimeString()),
						`${remoteAddress} GET ${pathname} "${userAgent}"`
					);

					let styles = [];
					if (config.postcss.importEntryPoints) {
						styles = config.postcss.importEntryPoints;
					} else {
						styles = this._application.getSortedStyles();
					}

					styles = styles.map((fsPath) => this.getStyleWebPath(fsPath));

morgan

HTTP request logger middleware for node.js

MIT
Latest version published 4 years ago

Package Health Score

73 / 100
Full package analysis