diff options
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1,3 +1,7 @@ | |||
1 | if ([ 'dev', 'test'].indexOf(process.env.NODE_ENV) !== -1) { | ||
2 | require('source-map-support').install() | ||
3 | } | ||
4 | |||
1 | // ----------- Node modules ----------- | 5 | // ----------- Node modules ----------- |
2 | import bodyParser = require('body-parser') | 6 | import bodyParser = require('body-parser') |
3 | import express = require('express') | 7 | import express = require('express') |
@@ -20,8 +24,8 @@ const app = express() | |||
20 | import { logger } from './server/helpers/logger' | 24 | import { logger } from './server/helpers/logger' |
21 | import { API_VERSION, CONFIG } from './server/initializers/constants' | 25 | import { API_VERSION, CONFIG } from './server/initializers/constants' |
22 | // Initialize database and models | 26 | // Initialize database and models |
23 | const db = require('./server/initializers/database') | 27 | import { database as db } from './server/initializers/database' |
24 | db.init(onDatabaseInitDone) | 28 | db.init(false, onDatabaseInitDone) |
25 | 29 | ||
26 | // ----------- Checker ----------- | 30 | // ----------- Checker ----------- |
27 | import { checkMissedConfig, checkFFmpeg, checkConfig } from './server/initializers/checker' | 31 | import { checkMissedConfig, checkFFmpeg, checkConfig } from './server/initializers/checker' |
@@ -52,7 +56,9 @@ import { apiRouter, clientsRouter, staticRouter } from './server/controllers' | |||
52 | // ----------- App ----------- | 56 | // ----------- App ----------- |
53 | 57 | ||
54 | // For the logger | 58 | // For the logger |
55 | // app.use(morgan('combined', { stream: logger.stream })) | 59 | app.use(morgan('combined', { |
60 | stream: { write: logger.info } | ||
61 | })) | ||
56 | // For body requests | 62 | // For body requests |
57 | app.use(bodyParser.json({ limit: '500kb' })) | 63 | app.use(bodyParser.json({ limit: '500kb' })) |
58 | app.use(bodyParser.urlencoded({ extended: false })) | 64 | app.use(bodyParser.urlencoded({ extended: false })) |
@@ -75,7 +81,7 @@ app.use('/', staticRouter) | |||
75 | 81 | ||
76 | // Always serve index client page (the client is a single page application, let it handle routing) | 82 | // Always serve index client page (the client is a single page application, let it handle routing) |
77 | app.use('/*', function (req, res, next) { | 83 | app.use('/*', function (req, res, next) { |
78 | res.sendFile(path.join(__dirname, './client/dist/index.html')) | 84 | res.sendFile(path.join(__dirname, '../client/dist/index.html')) |
79 | }) | 85 | }) |
80 | 86 | ||
81 | // ----------- Tracker ----------- | 87 | // ----------- Tracker ----------- |