forked from huridocs/uwazi
-
Notifications
You must be signed in to change notification settings - Fork 1
/
server.js
46 lines (39 loc) · 1.62 KB
/
server.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
require('es6-promise').polyfill(); // Required in some browsers
//babel polyfill ES6
require('babel-core/register')();
require.extensions['.scss'] = function () { return; };
require.extensions['.css'] = function () { return; };
var express = require('express');
var path = require('path');
var compression = require('compression');
const app = express();
var http = require('http').Server(app);
app.use(compression());
app.use(express.static(path.resolve(__dirname, 'dist')));
app.use('/uploaded_documents', express.static(path.resolve(__dirname, 'uploaded_documents')));
app.use('/public', express.static(path.resolve(__dirname, 'public')));
app.use('/flag-images', express.static(path.resolve(__dirname, 'node_modules/react-flags/vendor/flags')));
require('./app/api/api.js')(app, http);
require('./app/react/server.js')(app);
var dbConfig = require('./app/api/config/database');
var translations = require('./app/api/i18n/translations.js');
var systemKeys = require('./app/api/i18n/systemKeys.js');
var ports = require('./app/api/config/ports.js');
const port = ports[app.get('env')];
var mongoose = require('mongoose');
mongoose.Promise = Promise;
mongoose.connect(dbConfig[app.get('env')]);
var db = mongoose.connection;
db.on('error', console.error.bind(console, 'connection error:'));
db.once('open', function () {
translations.processSystemKeys(systemKeys)
.then(function() {
http.listen(port, '0.0.0.0', function onStart(err) {
if (err) {
console.log(err);
}
console.info('==> 🌎 Listening on port %s. Open up http://localhost:%s/ in your browser.', port, port);
});
})
.catch(console.log);
});