summaryrefslogtreecommitdiffstats
path: root/utils/test/vnfcatalogue/VNF_Catalogue/app.js
diff options
context:
space:
mode:
authorKumar Rishabh <shailrishabh@gmail.com>2017-02-10 10:31:59 +0530
committerKumar Rishabh <shailrishabh@gmail.com>2017-02-10 10:38:38 +0530
commit76e8a833fb517d711a38fc4e122246e56cfd1f6b (patch)
treee79bd4e8d0504fbebb71f602f2fa1649553a1828 /utils/test/vnfcatalogue/VNF_Catalogue/app.js
parentf46d6de5ff79393df52edc8f31c6480445bc7259 (diff)
Added VNF_Catalogue Server
Change-Id: I45cedac46f06e6e1f080dd3bc38d6f79eec37fa6 Signed-off-by: Kumar Rishabh <shailrishabh@gmail.com>
Diffstat (limited to 'utils/test/vnfcatalogue/VNF_Catalogue/app.js')
-rw-r--r--utils/test/vnfcatalogue/VNF_Catalogue/app.js79
1 files changed, 79 insertions, 0 deletions
diff --git a/utils/test/vnfcatalogue/VNF_Catalogue/app.js b/utils/test/vnfcatalogue/VNF_Catalogue/app.js
new file mode 100644
index 000000000..0f842b62d
--- /dev/null
+++ b/utils/test/vnfcatalogue/VNF_Catalogue/app.js
@@ -0,0 +1,79 @@
+/*******************************************************************************
+ * Copyright (c) 2017 Kumar Rishabh and others.
+ *
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Apache License, Version 2.0
+ * which accompanies this distribution, and is available at
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *******************************************************************************/
+
+var express = require('express');
+var path = require('path');
+var favicon = require('serve-favicon');
+var logger = require('morgan');
+var cookieParser = require('cookie-parser');
+var bodyParser = require('body-parser');
+
+var routes = require('./routes/index');
+var search_projects = require('./routes/search_projects');
+
+var app = express();
+
+// view engine setup
+app.set('views', path.join(__dirname, 'views'));
+app.set('view engine', 'jade');
+
+// Database
+var db = require('mysql2');
+
+// uncomment after placing your favicon in /public
+//app.use(favicon(__dirname + '/public/favicon.ico'));
+app.use(logger('dev'));
+app.use(bodyParser.json());
+app.use(bodyParser.urlencoded({ extended: false }));
+app.use(cookieParser());
+app.use(express.static(path.join(__dirname, 'public')));
+
+// Make our db accessible to our router
+app.use(function(req,res,next){
+ req.db = db;
+ next();
+});
+
+app.use('/', routes);
+app.use('/search_projects', search_projects);
+
+
+// Some Error handling for now #TODO Remove
+
+/// catch 404 and forwarding to error handler
+app.use(function(req, res, next) {
+ var err = new Error('Not Found');
+ err.status = 404;
+ next(err);
+});
+
+
+// development error handler
+// will print stacktrace
+if (app.get('env') === 'development') {
+ app.use(function(err, req, res, next) {
+ res.status(err.status || 500);
+ res.render('error', {
+ message: err.message,
+ error: err
+ });
+ });
+}
+
+// production error handler
+// no stacktraces leaked to user
+app.use(function(err, req, res, next) {
+ res.status(err.status || 500);
+ res.render('error', {
+ message: err.message,
+ error: {}
+ });
+});
+
+module.exports = app;