-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.js
76 lines (71 loc) · 2.85 KB
/
app.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var express = require('express');
var path = require('path');
var favicon = require('serve-favicon');
var morgan = require('morgan');
var cookieParser = require('cookie-parser');
var bodyParser = require('body-parser');
var appconf = require('./appconf');
// var jsonServer = require('json-server');
var mongoose = require('mongoose');
mongoose.connect(appconf.MONGO_HOST + ":" + appconf.MONGO_PORT + "/" + appconf.MONGO_DB);
var datamodeldefination = require('./datamillserver/datamodel/datamodel_router');
//APP logger
// var logger = require("./applogger");
var nav_router = require('./datamillserver/nav_router');
var datasource = require('./datamillserver/datasource/datasourceRouter');
var domainlib_router = require('./datamillserver/domainlib/domainlib_router');
var oauth_router = require('./datamillserver/oauth/authlogin');
var isAuthenticated = require('./datamillserver/authorization/authorize').isAuthenticated;
var profile_router = require('./datamillserver/users/profile_router');
var validate = require('./datamillserver/datasource/validate');
var dataSourceCache = require('./generatorloops/dataSourceCache');
var scheduledatasrc = require('./generatorloops/schedulestart');
//Express App created
var app = express();
dataSourceCache.startBufferring();
//scheduledatasrc.scheduledatasource();
app.onAppStart = function(addr) {
// logger.info("DataMill web app is now Running on port:",addr.port);
}
app.use(morgan('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(cookieParser());
app.use('/profile', isAuthenticated, profile_router);
// app.use('/api', jsonServer.router('db.json'));
app.use('/navbarItems', nav_router);
// app.use('/createdatasource', createdatasource);
app.use('/datasources', isAuthenticated, datasource);
app.use('/validatename', isAuthenticated, validate);
app.use('/domain', isAuthenticated, domainlib_router);
app.use(express.static(path.join(__dirname, 'webapp')));
app.use(express.static(path.join(__dirname, 'bower_modules')));
// app.use(express.static(path.join(__dirname, 'public')));
app.post('/login', function(req, res) {
});
app.use('/', oauth_router);
app.use('/datamodel', isAuthenticated, datamodeldefination);
app.use(function(req, res, next) {
var err = new Error('Resource not found');
err.status = 404;
return res.status(err.status).json({
"error": err.message
});
});
if (app.get('env') === 'development') {
app.use(function(err, req, res, next) {
// logger.error("Internal error in watch processor: ", err);
return res.status(err.status || 500).json({
"error": err.message
});
});
}
app.use(function(err, req, res, next) {
// logger.error("Internal error in watch processor: ", err);
return res.status(err.status || 500).json({
"error": err.message
});
});
module.exports = app;