Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 5 additions & 26 deletions server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"
}
}
24 changes: 24 additions & 0 deletions server/src/express-app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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')
Expand Down