summaryrefslogtreecommitdiffstats
path: root/ecomp-portal-FE-os/server
diff options
context:
space:
mode:
authorst782s <statta@research.att.com>2017-05-04 07:48:42 -0400
committerst782s <statta@research.att.com>2017-05-04 12:28:17 -0400
commitb54df0ddd0c6a0372327c5aa3668e5a6458fcd64 (patch)
treee69cfa9b314a801bd187cf0145d1d4306436229c /ecomp-portal-FE-os/server
parent39d1e62c84041831bfc52cca73b5ed5efaf57d27 (diff)
[PORTAL-7] Rebase
This rebasing includes common libraries and common overlays projects abstraction of components Change-Id: I9a24a338665c7cd058978e8636bc412d9e2fdce8 Signed-off-by: st782s <statta@research.att.com>
Diffstat (limited to 'ecomp-portal-FE-os/server')
-rw-r--r--ecomp-portal-FE-os/server/.jshintrc14
-rw-r--r--ecomp-portal-FE-os/server/.jshintrc-spec11
-rw-r--r--ecomp-portal-FE-os/server/app.js19
-rw-r--r--ecomp-portal-FE-os/server/components/errors/index.js20
-rw-r--r--ecomp-portal-FE-os/server/config/environment/index.js25
-rw-r--r--ecomp-portal-FE-os/server/config/express.js40
-rw-r--r--ecomp-portal-FE-os/server/routes.js17
-rw-r--r--ecomp-portal-FE-os/server/views/404.html157
8 files changed, 303 insertions, 0 deletions
diff --git a/ecomp-portal-FE-os/server/.jshintrc b/ecomp-portal-FE-os/server/.jshintrc
new file mode 100644
index 00000000..66d1af7c
--- /dev/null
+++ b/ecomp-portal-FE-os/server/.jshintrc
@@ -0,0 +1,14 @@
+{
+ "node": true,
+ "esnext": true,
+ "bitwise": true,
+ "eqeqeq": true,
+ "immed": true,
+ "latedef": "nofunc",
+ "newcap": true,
+ "noarg": true,
+ "undef": true,
+ "smarttabs": true,
+ "asi": true,
+ "debug": true
+}
diff --git a/ecomp-portal-FE-os/server/.jshintrc-spec b/ecomp-portal-FE-os/server/.jshintrc-spec
new file mode 100644
index 00000000..b6b55cbf
--- /dev/null
+++ b/ecomp-portal-FE-os/server/.jshintrc-spec
@@ -0,0 +1,11 @@
+{
+ "extends": ".jshintrc",
+ "globals": {
+ "describe": true,
+ "it": true,
+ "before": true,
+ "beforeEach": true,
+ "after": true,
+ "afterEach": true
+ }
+}
diff --git a/ecomp-portal-FE-os/server/app.js b/ecomp-portal-FE-os/server/app.js
new file mode 100644
index 00000000..e6e3383f
--- /dev/null
+++ b/ecomp-portal-FE-os/server/app.js
@@ -0,0 +1,19 @@
+'use strict';
+//let serverCommon = require('ssp_server_common');
+let express = require('express');
+let config = require('./config/environment');
+
+//let logger = serverCommon.getLogger(config);
+// Setup server
+let app = express();
+let server = require('http').createServer(app);
+require('./config/express')(app);
+require('./routes')(app);
+
+// Start server
+server.listen(config.port, config.ip, ()=> {
+ console.log('Express server listening on %d port, in %s mode', config.port, config.ip);
+});
+
+// Expose app
+module.exports = app;
diff --git a/ecomp-portal-FE-os/server/components/errors/index.js b/ecomp-portal-FE-os/server/components/errors/index.js
new file mode 100644
index 00000000..4c5a57c9
--- /dev/null
+++ b/ecomp-portal-FE-os/server/components/errors/index.js
@@ -0,0 +1,20 @@
+/**
+ * Error responses
+ */
+
+'use strict';
+
+module.exports[404] = function pageNotFound(req, res) {
+ var viewFilePath = '404';
+ var statusCode = 404;
+ var result = {
+ status: statusCode
+ };
+
+ res.status(result.status);
+ res.render(viewFilePath, function (err) {
+ if (err) { return res.json(result, result.status); }
+
+ res.render(viewFilePath);
+ });
+};
diff --git a/ecomp-portal-FE-os/server/config/environment/index.js b/ecomp-portal-FE-os/server/config/environment/index.js
new file mode 100644
index 00000000..6bf620cb
--- /dev/null
+++ b/ecomp-portal-FE-os/server/config/environment/index.js
@@ -0,0 +1,25 @@
+'use strict';
+
+var path = require('path');
+
+// All configurations will extend these options
+// ============================================
+var all = {
+ env: process.env.NODE_ENV,
+
+ // Root path of server
+ root: path.normalize(__dirname + '/../../..'),
+
+ // Server port
+ port: process.env.PORT || 9000,
+
+ // Server IP
+ ip: process.env.IP || '0.0.0.0',
+
+ //Base tag url
+ baseUrl: '/ecompportal'
+};
+
+// Export the config object based on the NODE_ENV
+// ==============================================
+module.exports = all;
diff --git a/ecomp-portal-FE-os/server/config/express.js b/ecomp-portal-FE-os/server/config/express.js
new file mode 100644
index 00000000..15600503
--- /dev/null
+++ b/ecomp-portal-FE-os/server/config/express.js
@@ -0,0 +1,40 @@
+'use strict';
+
+let express = require('express');
+let favicon = require('serve-favicon');
+let morgan = require('morgan');
+let compression = require('compression');
+let bodyParser = require('body-parser');
+let methodOverride = require('method-override');
+let cookieParser = require('cookie-parser');
+let errorHandler = require('errorhandler');
+let path = require('path');
+let config = require('./environment');
+
+
+module.exports = (app) => {
+ var env = app.get('env');
+
+ app.set('views', config.root + '/server/views');
+ app.engine('html', require('ejs').renderFile);
+ app.set('view engine', 'html');
+ app.use(compression());
+ app.use(bodyParser.urlencoded({extended: false}));
+ app.use(bodyParser.json());
+ app.use(methodOverride());
+ app.use(cookieParser());
+
+ //if (process.env.NODE_TREE_STRUCTURE === 'unminified') {
+ app.use(require('connect-livereload')());
+ app.use(config.baseUrl, express.static(path.join(config.root, '.tmp')));
+ app.use(config.baseUrl, express.static(path.join(config.root, 'client')));
+ app.set('appPath', path.join(config.root, 'client'));
+ app.use(morgan('dev'));
+ app.use(errorHandler()); // Error handler - has to be last
+ //} else {
+ // app.use(favicon(path.join(config.root, 'public', 'favicon.ico')));
+ // app.use(express.static(path.join(config.root, 'public')));
+ // app.set('appPath', path.join(config.root, 'public'));
+ // app.use(morgan('dev'));
+ //}
+};
diff --git a/ecomp-portal-FE-os/server/routes.js b/ecomp-portal-FE-os/server/routes.js
new file mode 100644
index 00000000..b74027e8
--- /dev/null
+++ b/ecomp-portal-FE-os/server/routes.js
@@ -0,0 +1,17 @@
+'use strict';
+let path = require('path');
+let config = require('./config/environment');
+
+module.exports = app => {
+ // All undefined asset or api routes should return a 404
+ app.route('/:url(api|auth|components|app|bower_components|assets)/*')
+ .get(function(req, res){
+ res.status(404).send();
+ });
+
+ // All other routes should redirect to the index.html
+ app.route(config.baseUrl + '/*')
+ .get(function (req, res) {
+ res.sendFile(path.resolve('client/index.html'));
+ });
+};
diff --git a/ecomp-portal-FE-os/server/views/404.html b/ecomp-portal-FE-os/server/views/404.html
new file mode 100644
index 00000000..ec98e3c2
--- /dev/null
+++ b/ecomp-portal-FE-os/server/views/404.html
@@ -0,0 +1,157 @@
+<!DOCTYPE html>
+<html lang="en">
+ <head>
+ <meta charset="utf-8">
+ <title>Page Not Found :(</title>
+ <style>
+ ::-moz-selection {
+ background: #b3d4fc;
+ text-shadow: none;
+ }
+
+ ::selection {
+ background: #b3d4fc;
+ text-shadow: none;
+ }
+
+ html {
+ padding: 30px 10px;
+ font-size: 20px;
+ line-height: 1.4;
+ color: #737373;
+ background: #f0f0f0;
+ -webkit-text-size-adjust: 100%;
+ -ms-text-size-adjust: 100%;
+ }
+
+ html,
+ input {
+ font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
+ }
+
+ body {
+ max-width: 500px;
+ _width: 500px;
+ padding: 30px 20px 50px;
+ border: 1px solid #b3b3b3;
+ border-radius: 4px;
+ margin: 0 auto;
+ box-shadow: 0 1px 10px #a7a7a7, inset 0 1px 0 #fff;
+ background: #fcfcfc;
+ }
+
+ h1 {
+ margin: 0 10px;
+ font-size: 50px;
+ text-align: center;
+ }
+
+ h1 span {
+ color: #bbb;
+ }
+
+ h3 {
+ margin: 1.5em 0 0.5em;
+ }
+
+ p {
+ margin: 1em 0;
+ }
+
+ ul {
+ padding: 0 0 0 40px;
+ margin: 1em 0;
+ }
+
+ .container {
+ max-width: 380px;
+ _width: 380px;
+ margin: 0 auto;
+ }
+
+ /* google search */
+
+ #goog-fixurl ul {
+ list-style: none;
+ padding: 0;
+ margin: 0;
+ }
+
+ #goog-fixurl form {
+ margin: 0;
+ }
+
+ #goog-wm-qt,
+ #goog-wm-sb {
+ border: 1px solid #bbb;
+ font-size: 16px;
+ line-height: normal;
+ vertical-align: top;
+ color: #444;
+ border-radius: 2px;
+ }
+
+ #goog-wm-qt {
+ width: 220px;
+ height: 20px;
+ padding: 5px;
+ margin: 5px 10px 0 0;
+ box-shadow: inset 0 1px 1px #ccc;
+ }
+
+ #goog-wm-sb {
+ display: inline-block;
+ height: 32px;
+ padding: 0 10px;
+ margin: 5px 0 0;
+ white-space: nowrap;
+ cursor: pointer;
+ background-color: #f5f5f5;
+ background-image: -webkit-linear-gradient(rgba(255,255,255,0), #f1f1f1);
+ background-image: -moz-linear-gradient(rgba(255,255,255,0), #f1f1f1);
+ background-image: -ms-linear-gradient(rgba(255,255,255,0), #f1f1f1);
+ background-image: -o-linear-gradient(rgba(255,255,255,0), #f1f1f1);
+ -webkit-appearance: none;
+ -moz-appearance: none;
+ appearance: none;
+ *overflow: visible;
+ *display: inline;
+ *zoom: 1;
+ }
+
+ #goog-wm-sb:hover,
+ #goog-wm-sb:focus {
+ border-color: #aaa;
+ box-shadow: 0 1px 1px rgba(0, 0, 0, 0.1);
+ background-color: #f8f8f8;
+ }
+
+ #goog-wm-qt:hover,
+ #goog-wm-qt:focus {
+ border-color: #105cb6;
+ outline: 0;
+ color: #222;
+ }
+
+ input::-moz-focus-inner {
+ padding: 0;
+ border: 0;
+ }
+ </style>
+ </head>
+ <body>
+ <div class="container">
+ <h1>Not found <span>:(</span></h1>
+ <p>Sorry, but the page you were trying to view does not exist.</p>
+ <p>It looks like this was the result of either:</p>
+ <ul>
+ <li>a mistyped address</li>
+ <li>an out-of-date link</li>
+ </ul>
+ <script>
+ var GOOG_FIXURL_LANG = (navigator.language || '').slice(0,2),GOOG_FIXURL_SITE = location.host;
+ </script>
+ <script src="//linkhelp.clients.google.com/tbproxy/lh/wm/fixurl.js"></script>
+ </div>
+ </body>
+</html>