Add HTTP request logging
This commit is contained in:
parent
dc2950d60f
commit
9cdcf90c8a
|
@ -827,6 +827,14 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"basic-auth": {
|
||||
"version": "2.0.1",
|
||||
"resolved": "https://registry.npmjs.org/basic-auth/-/basic-auth-2.0.1.tgz",
|
||||
"integrity": "sha512-NF+epuEdnUYVlGuhaxbbq+dvJttwLnGY+YixlXlME5KpQ5W3CnXA5cVTneY3SPbPDRkcjMbifrwmFYcClgOZeg==",
|
||||
"requires": {
|
||||
"safe-buffer": "5.1.2"
|
||||
}
|
||||
},
|
||||
"bcrypt-pbkdf": {
|
||||
"version": "1.0.2",
|
||||
"resolved": "https://registry.npmjs.org/bcrypt-pbkdf/-/bcrypt-pbkdf-1.0.2.tgz",
|
||||
|
@ -3348,6 +3356,18 @@
|
|||
"integrity": "sha512-9DITV2YEMcw7XojdfvGl3gDD8J9QjZTJ7ZOUuSAkP+F3T6rDbzMJuPktxptsdHYEvZcmXrCD3LMOhdSAEq6zKA==",
|
||||
"optional": true
|
||||
},
|
||||
"morgan": {
|
||||
"version": "1.9.1",
|
||||
"resolved": "https://registry.npmjs.org/morgan/-/morgan-1.9.1.tgz",
|
||||
"integrity": "sha512-HQStPIV4y3afTiCYVxirakhlCfGkI161c76kKFca7Fk1JusM//Qeo1ej2XaMniiNeaZklMVrh3vTtIzpzwbpmA==",
|
||||
"requires": {
|
||||
"basic-auth": "~2.0.0",
|
||||
"debug": "2.6.9",
|
||||
"depd": "~1.1.2",
|
||||
"on-finished": "~2.3.0",
|
||||
"on-headers": "~1.0.1"
|
||||
}
|
||||
},
|
||||
"ms": {
|
||||
"version": "2.0.0",
|
||||
"resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz",
|
||||
|
@ -3487,6 +3507,11 @@
|
|||
"ee-first": "1.1.1"
|
||||
}
|
||||
},
|
||||
"on-headers": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/on-headers/-/on-headers-1.0.1.tgz",
|
||||
"integrity": "sha1-ko9dD0cNSTQmUepnlLCFfBAGk/c="
|
||||
},
|
||||
"once": {
|
||||
"version": "1.4.0",
|
||||
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
"jsonwebtoken": "^8.4.0",
|
||||
"lru-cache": "^5.1.1",
|
||||
"mime": "^2.4.0",
|
||||
"morgan": "^1.9.1",
|
||||
"ndjson": "^1.5.0",
|
||||
"pretty-bytes": "^5.1.0",
|
||||
"prop-types": "^15.6.2",
|
||||
|
|
|
@ -1,11 +1,13 @@
|
|||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
import express from 'express';
|
||||
|
||||
import logging from '../middleware/logging';
|
||||
import userToken from '../middleware/userToken';
|
||||
import showAuth from '../actions/showAuth';
|
||||
|
||||
const app = express.Router();
|
||||
|
||||
app.use(logging);
|
||||
app.use(cors());
|
||||
app.use(userToken);
|
||||
app.use(showAuth);
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
import express from 'express';
|
||||
|
||||
import logging from '../middleware/logging';
|
||||
import serveMainPage from '../actions/serveMainPage';
|
||||
|
||||
const app = express.Router();
|
||||
|
||||
app.use(logging);
|
||||
app.use(serveMainPage);
|
||||
|
||||
export default app;
|
||||
|
|
|
@ -1,8 +1,9 @@
|
|||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
import express from 'express';
|
||||
|
||||
import fetchPackage from '../middleware/fetchPackage';
|
||||
import findFile from '../middleware/findFile';
|
||||
import logging from '../middleware/logging';
|
||||
import redirectLegacyURLs from '../middleware/redirectLegacyURLs';
|
||||
import validatePackageURL from '../middleware/validatePackageURL';
|
||||
import validatePackageName from '../middleware/validatePackageName';
|
||||
|
@ -11,6 +12,7 @@ import serveFile from '../actions/serveFile';
|
|||
|
||||
const app = express.Router();
|
||||
|
||||
app.use(logging);
|
||||
app.use(cors());
|
||||
app.use(redirectLegacyURLs);
|
||||
app.use(validatePackageURL);
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
import express from 'express';
|
||||
|
||||
import logging from '../middleware/logging';
|
||||
import showPublicKey from '../actions/showPublicKey';
|
||||
|
||||
const app = express.Router();
|
||||
|
||||
app.use(logging);
|
||||
app.use(cors());
|
||||
app.use(showPublicKey);
|
||||
|
||||
|
|
|
@ -1,10 +1,12 @@
|
|||
import express from 'express';
|
||||
import cors from 'cors';
|
||||
import express from 'express';
|
||||
|
||||
import logging from '../middleware/logging';
|
||||
import showStats from '../actions/showStats';
|
||||
|
||||
const app = express.Router();
|
||||
|
||||
app.use(logging);
|
||||
app.use(cors());
|
||||
app.use(showStats);
|
||||
|
||||
|
|
|
@ -0,0 +1,15 @@
|
|||
import morgan from 'morgan';
|
||||
|
||||
const logging = morgan(
|
||||
process.env.NODE_ENV === 'development'
|
||||
? 'dev'
|
||||
: ':date[clf] - :method :url :status :res[content-length] - :response-time ms',
|
||||
{
|
||||
skip:
|
||||
process.env.NODE_ENV === 'production'
|
||||
? (req, res) => res.statusCode < 400 // Log only errors in production
|
||||
: () => process.env.NODE_ENV === 'test' // Skip logging in test env
|
||||
}
|
||||
);
|
||||
|
||||
export default logging;
|
Loading…
Reference in New Issue