X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;ds=sidebyside;f=server.ts;h=6963bbf235a5b5958d442bbcbff57a7b186f4d80;hb=8f3ad70874f8769f5340632754dc2ca7f4c82733;hp=b49d10344bb5a38b83739afe30fe7b350a85322d;hpb=464687bb96cf98d00714279750fd5f19a42b6a02;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server.ts b/server.ts index b49d10344..6963bbf23 100644 --- a/server.ts +++ b/server.ts @@ -1,16 +1,5 @@ -import { resolve } from 'path' - -const tsConfig = require('./tsconfig.json') -const tsConfigPaths = require('tsconfig-paths') - -// Thanks: https://github.com/dividab/tsconfig-paths/issues/75#issuecomment-458936883 -tsConfigPaths.register({ - baseUrl: resolve(tsConfig.compilerOptions.baseUrl || '', tsConfig.compilerOptions.outDir || ''), - paths: tsConfig.compilerOptions.paths -}) - -// FIXME: https://github.com/nodejs/node/pull/16853 -require('tls').DEFAULT_ECDH_CURVE = 'auto' +import { registerTSPaths } from './server/helpers/register-ts-paths' +registerTSPaths() import { isTestInstance } from './server/helpers/core-utils' if (isTestInstance()) { @@ -81,7 +70,9 @@ if (CONFIG.CSP.ENABLED) { // ----------- Database ----------- // Initialize database and models -import { initDatabaseModels } from './server/initializers/database' +import { initDatabaseModels, checkDatabaseConnectionOrDie } from './server/initializers/database' +checkDatabaseConnectionOrDie() + import { migrate } from './server/initializers/migrator' migrate() .then(() => initDatabaseModels(false)) @@ -95,7 +86,7 @@ migrate() loadLanguages() // ----------- PeerTube modules ----------- -import { installApplication } from './server/initializers' +import { installApplication } from './server/initializers/installer' import { Emailer } from './server/lib/emailer' import { JobQueue } from './server/lib/job-queue' import { VideosPreviewCache, VideosCaptionCache } from './server/lib/files-cache' @@ -107,10 +98,12 @@ import { staticRouter, lazyStaticRouter, servicesRouter, + liveRouter, pluginsRouter, webfingerRouter, trackerRouter, - createWebsocketTrackerServer, botsRouter + createWebsocketTrackerServer, + botsRouter } from './server/controllers' import { advertiseDoNotTrack } from './server/middlewares/dnt' import { Redis } from './server/lib/redis' @@ -128,6 +121,7 @@ import { updateStreamingPlaylistsInfohashesIfNeeded } from './server/lib/hls' import { PluginsCheckScheduler } from './server/lib/schedulers/plugins-check-scheduler' import { Hooks } from './server/lib/plugins/hooks' import { PluginManager } from './server/lib/plugins/plugin-manager' +import { LiveManager } from '@server/lib/live-manager' // ----------- Command line ----------- @@ -148,14 +142,14 @@ if (isTestInstance()) { } // For the logger -morgan.token('remote-addr', req => { - if (req.get('DNT') === '1') { +morgan.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 => { +morgan.token('user-agent', (req: express.Request) => { if (req.get('DNT') === '1') { return useragent.parse(req.get('user-agent')).family } @@ -192,6 +186,9 @@ app.use(apiRoute, apiRouter) // Services (oembed...) app.use('/services', servicesRouter) +// Live streaming +app.use('/live', liveRouter) + // Plugins & themes app.use('/', pluginsRouter) @@ -280,6 +277,9 @@ async function startApplication () { if (cli.plugins) await PluginManager.Instance.registerPluginsAndThemes() + LiveManager.Instance.init() + if (CONFIG.LIVE.ENABLED) LiveManager.Instance.run() + // Make server listening server.listen(port, hostname, () => { logger.info('Server listening on %s:%d', hostname, port)