diff --git a/server/package.json b/server/package.json index 51f5e1b34b..99c6b264bf 100644 --- a/server/package.json +++ b/server/package.json @@ -55,12 +55,7 @@ "start:debug": "nodemon --config nodemon-debug.json", "prestart:prod": "rimraf dist && npm run build", "start:prod": "node dist/main.js", - "lint": "tslint -p tsconfig.json -c tslint.json", - "test": "jest", - "test:watch": "jest --watch", - "test:cov": "jest --coverage", - "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand", - "test:e2e": "jest --config ./test/jest-e2e.json" + "lint": "tslint -p tsconfig.json -c tslint.json" }, "dependencies": { "@nestjs/common": "^6.0.0", @@ -115,38 +110,22 @@ "sqlstring": "^2.3.3", "tangy-log": "^1.0.0", "underscore": "^1.8.3", - "uuid": "^8.3.0" + "uuid": "^8.3.0", + "winston": "^3.8.2", + "express-winston": "^4.2.0", + "winston-daily-rotate-file": "^4.7.1" }, "devDependencies": { "@nestjs/testing": "^6.0.0", "@types/express": "^4.16.0", - "@types/jest": "^23.3.13", "@types/node": "^10.12.18", "@types/supertest": "^2.0.7", - "jest": "^24.9.0", - "jest-circus": "^24.9.0", "nodemon": "^1.18.9", "prettier": "^1.15.3", "supertest": "^3.4.1", - "ts-jest": "^23.10.5", "ts-node": "^7.0.1", "tsconfig-paths": "^3.7.0", "tslint": "5.12.1", "typescript": "^3.2.4" - }, - "jest": { - "testRunner": "jest-circus/runner", - "moduleFileExtensions": [ - "js", - "json", - "ts" - ], - "rootDir": "src", - "testRegex": ".spec.ts$", - "transform": { - "^.+\\.(t|j)s$": "ts-jest" - }, - "coverageDirectory": "../coverage", - "testEnvironment": "node" } } diff --git a/server/src/express-app.js b/server/src/express-app.js index 6726252283..5b0af351f7 100644 --- a/server/src/express-app.js +++ b/server/src/express-app.js @@ -60,6 +60,8 @@ const {archiveToDiskConfig, passwordPolicyConfig} = require('./config-utils.js') const { generateCSV, generateCSVDataSet, generateCSVDataSetsRoute, listCSVDataSets, getDatasetDetail } = require('./routes/group-csv.js'); const allowIfUser1 = require('./middleware/allow-if-user1.js'); const hasUploadToken = require("./middleware/has-upload-token"); +const winston = require('winston'), expressWinston = require('express-winston'); +require('winston-daily-rotate-file'); if (process.env.T_AUTO_COMMIT === 'true') { setInterval(commitFilesToVersionControl,parseInt(process.env.T_AUTO_COMMIT_FREQUENCY)) @@ -119,6 +121,28 @@ app.use(bodyParser.urlencoded({ extended: false })); app.use(bodyParser.json({ limit: '1gb' })) app.use(bodyParser.text({ limit: '1gb' })) app.use(compression()) + +const transport = new winston.transports.DailyRotateFile({ + level: 'debug', + filename: 'application-%DATE%.log', + dirname: '../client/releases/', + datePattern: 'YYYY-MM-DD-HH', + zippedArchive: true, + maxSize: '20m', + maxFiles: '14d' +}); + +// Request logging +app.use(expressWinston.logger({ + transports: [ + transport + ], + meta: false, // optional: control whether you want to log the meta data about the request (default to true) + msg: "{{res.statusCode}} {{req.method}} {{res.responseTime}}ms {{req.url}}", // optional: customize the default logging message. E.g. "{{res.statusCode}} {{req.method}} {{res.responseTime}}ms {{req.url}}" + expressFormat: true, // Use the default Express/morgan request formatting. Enabling this will override any msg if true. Will only output colors with colorize set to true + colorize: false, // Color the text and status code, using the Express/morgan color palette (text: gray, status: default green, 3XX cyan, 4XX yellow, 5XX red). +})); + // Middleware to protect routes. var isAuthenticated = require('./middleware/is-authenticated.js') var {permit, permitOnGroupIfAll} = require('./middleware/permitted.js')