X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server.ts;h=9af83cde9ffa9973a447efcd5885d48c3fbbd009;hb=e334d72ee09f77930db7efd611e5ecb1cd1c3d56;hp=582321a5b87b9f2ba89c5a8873764f446d1cb442;hpb=a24bd1ed41b43790bab6ba789580bb4e85f07d85;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server.ts b/server.ts index 582321a5b..9af83cde9 100644 --- a/server.ts +++ b/server.ts @@ -7,13 +7,13 @@ if (isTestInstance()) { } // ----------- Node modules ----------- -import * as express from 'express' -import * as morgan from 'morgan' -import * as cors from 'cors' -import * as cookieParser from 'cookie-parser' -import * as helmet from 'helmet' -import * as useragent from 'useragent' -import * as anonymize from 'ip-anonymize' +import express from 'express' +import morgan, { token } from 'morgan' +import cors from 'cors' +import cookieParser from 'cookie-parser' +import { frameguard } from 'helmet' +import { parse } from 'useragent' +import anonymize from 'ip-anonymize' import { program as cli } from 'commander' process.title = 'peertube' @@ -61,7 +61,7 @@ if (CONFIG.CSP.ENABLED) { } if (CONFIG.SECURITY.FRAMEGUARD.ENABLED) { - app.use(helmet.frameguard({ + app.use(frameguard({ action: 'deny' // we only allow it for /videos/embed, see server/controllers/client.ts })) } @@ -148,16 +148,16 @@ if (isTestInstance()) { } // For the logger -morgan.token('remote-addr', (req: express.Request) => { +token('remote-addr', (req: express.Request) => { if (CONFIG.LOG.ANONYMIZE_IP === true || req.get('DNT') === '1') { return anonymize(req.ip, 16, 16) } return req.ip }) -morgan.token('user-agent', (req: express.Request) => { +token('user-agent', (req: express.Request) => { if (req.get('DNT') === '1') { - return useragent.parse(req.get('user-agent')).family + return parse(req.get('user-agent')).family } return req.get('user-agent') @@ -305,13 +305,19 @@ async function startApplication () { updateStreamingPlaylistsInfohashesIfNeeded() .catch(err => logger.error('Cannot update streaming playlist infohashes.', { err })) - if (cliOptions.plugins) await PluginManager.Instance.registerPluginsAndThemes() - LiveManager.Instance.init() if (CONFIG.LIVE.ENABLED) LiveManager.Instance.run() // Make server listening - server.listen(port, hostname, () => { + server.listen(port, hostname, async () => { + if (cliOptions.plugins) { + try { + await PluginManager.Instance.registerPluginsAndThemes() + } catch (err) { + logger.error('Cannot register plugins and themes.', { err }) + } + } + logger.info('HTTP server listening on %s:%d', hostname, port) logger.info('Web server: %s', WEBSERVER.URL)