aboutsummaryrefslogtreecommitdiffhomepage
path: root/server.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-08-27 14:32:44 +0200
committerChocobozzz <me@florianbigard.com>2021-08-27 15:12:22 +0200
commit41fb13c330de629df2d23379209e79c7af0f2e9a (patch)
tree73bc5a90566406b3910f142beae2a879c1e4265d /server.ts
parent40e7ed0714f96c01e16de3ac971a4b28116294e1 (diff)
downloadPeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.tar.gz
PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.tar.zst
PeerTube-41fb13c330de629df2d23379209e79c7af0f2e9a.zip
esModuleInterop to true
Diffstat (limited to 'server.ts')
-rw-r--r--server.ts22
1 files changed, 11 insertions, 11 deletions
diff --git a/server.ts b/server.ts
index bfc7ee145..9af83cde9 100644
--- a/server.ts
+++ b/server.ts
@@ -7,13 +7,13 @@ if (isTestInstance()) {
7} 7}
8 8
9// ----------- Node modules ----------- 9// ----------- Node modules -----------
10import * as express from 'express' 10import express from 'express'
11import * as morgan from 'morgan' 11import morgan, { token } from 'morgan'
12import * as cors from 'cors' 12import cors from 'cors'
13import * as cookieParser from 'cookie-parser' 13import cookieParser from 'cookie-parser'
14import * as helmet from 'helmet' 14import { frameguard } from 'helmet'
15import * as useragent from 'useragent' 15import { parse } from 'useragent'
16import * as anonymize from 'ip-anonymize' 16import anonymize from 'ip-anonymize'
17import { program as cli } from 'commander' 17import { program as cli } from 'commander'
18 18
19process.title = 'peertube' 19process.title = 'peertube'
@@ -61,7 +61,7 @@ if (CONFIG.CSP.ENABLED) {
61} 61}
62 62
63if (CONFIG.SECURITY.FRAMEGUARD.ENABLED) { 63if (CONFIG.SECURITY.FRAMEGUARD.ENABLED) {
64 app.use(helmet.frameguard({ 64 app.use(frameguard({
65 action: 'deny' // we only allow it for /videos/embed, see server/controllers/client.ts 65 action: 'deny' // we only allow it for /videos/embed, see server/controllers/client.ts
66 })) 66 }))
67} 67}
@@ -148,16 +148,16 @@ if (isTestInstance()) {
148} 148}
149 149
150// For the logger 150// For the logger
151morgan.token('remote-addr', (req: express.Request) => { 151token('remote-addr', (req: express.Request) => {
152 if (CONFIG.LOG.ANONYMIZE_IP === true || req.get('DNT') === '1') { 152 if (CONFIG.LOG.ANONYMIZE_IP === true || req.get('DNT') === '1') {
153 return anonymize(req.ip, 16, 16) 153 return anonymize(req.ip, 16, 16)
154 } 154 }
155 155
156 return req.ip 156 return req.ip
157}) 157})
158morgan.token('user-agent', (req: express.Request) => { 158token('user-agent', (req: express.Request) => {
159 if (req.get('DNT') === '1') { 159 if (req.get('DNT') === '1') {
160 return useragent.parse(req.get('user-agent')).family 160 return parse(req.get('user-agent')).family
161 } 161 }
162 162
163 return req.get('user-agent') 163 return req.get('user-agent')