diff options
author | Timoney, Daniel (dt5972) <dtimoney@att.com> | 2017-02-15 10:37:53 -0500 |
---|---|---|
committer | Timoney, Daniel (dt5972) <dtimoney@att.com> | 2017-02-15 10:40:37 -0500 |
commit | 324ee36fe31763e507b422ab0a88e4230045e205 (patch) | |
tree | d0b04520f6657601c918ce63fd27575977624187 /admportal/server/app.js | |
parent | f0c97e8db427481e28c0a16b789bc73801b35e47 (diff) |
Initial commit for OpenECOMP SDN-C OA&M
Change-Id: I7ab579fd0d206bf356f36d52dcdf4f71f1fa2680
Signed-off-by: Timoney, Daniel (dt5972) <dtimoney@att.com>
Former-commit-id: 2a9f0edd09581f907e62ec4689b5ac94dd5382ba
Diffstat (limited to 'admportal/server/app.js')
-rw-r--r-- | admportal/server/app.js | 69 |
1 files changed, 69 insertions, 0 deletions
diff --git a/admportal/server/app.js b/admportal/server/app.js new file mode 100644 index 00000000..33cdb64f --- /dev/null +++ b/admportal/server/app.js @@ -0,0 +1,69 @@ +var express = require('express'); +var app = express(); +var path = require('path'); +var session = require('express-session'); +var cookieParser = require('cookie-parser'); +var bodyParser = require('body-parser'); +var PropertiesReader = require('properties-reader'); +var properties = PropertiesReader(process.argv[2]); //property file passed +var morgan = require('morgan'); +var _ = require('lodash'); +//var multer = require('multer'); +//var done=false; + +// Check to make sure SDNC_CONFIG_DIR is set +var sdnc_config_dir = process.env.SDNC_CONFIG_DIR; +if ( typeof sdnc_config_dir == 'undefined' ) +{ + console.log('ERROR the SDNC_CONFIG_DIR environmental variable is not set.'); + return; +} + + +var moptions = { "stream": +{ + write: function(str) + { + if ( str.indexOf("/javascript") == -1 && str.indexOf("/stylesheets") == -1) + { + console.log(str); + } + } +} +}; +var accesslog = morgan( "|:method|HTTP/:http-version|:status|:url - requestIP-:remote-addr", moptions); + +//var favicon = require('serve-favicon'); + +// initialize session objects +app.use(session({ + secret:'SDN7C', + resave: false, + saveUninitialized: false +})); + +app.use(cookieParser()); +app.use(bodyParser.urlencoded({ + extended: true +})); + +app.use(accesslog); // http access log +app.use(express.static(process.cwd() + '/public')); // static files + + +//app.use('trust proxy', true); +app.enable('trust proxy'); + +// view engine setup +app.set('views', path.join(__dirname, '../views')); +app.set('view engine', 'ejs'); + + +var router = require('./router')(app); + +// Error Handling +app.use(function(err,req,res,next) { + res.status(err.status || 500); +}); + +module.exports = app; |