Skip to content

Commit

Permalink
commit to development with node modules
Browse files Browse the repository at this point in the history
  • Loading branch information
mohitp12 committed Jun 7, 2016
1 parent e4fcfd1 commit 6a450f0
Show file tree
Hide file tree
Showing 4,130 changed files with 461,030 additions and 0 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
19 changes: 19 additions & 0 deletions Dashboard/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>Dashboard</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.eclipsesource.jshint.ui.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.nodeclipse.ui.NodeNature</nature>
<nature>org.eclipse.wst.jsdt.core.jsNature</nature>
<nature>tern.eclipse.ide.core.ternnature</nature>
</natures>
</projectDescription>
7 changes: 7 additions & 0 deletions Dashboard/.settings/.jsdtscope
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<?xml version="1.0" encoding="UTF-8"?>
<classpath>
<classpathentry excluding="node_modules/**/*" kind="src" path=""/>
<classpathentry kind="con" path="org.eclipse.wst.jsdt.launching.JRE_CONTAINER"/>
<classpathentry kind="lib" path="node_modules"/>
<classpathentry kind="output" path=""/>
</classpath>
4 changes: 4 additions & 0 deletions Dashboard/.settings/com.eclipsesource.jshint.ui.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
eclipse.preferences.version=1
excluded=https://*.json\:bower_components//*\:node_lib//*\:node_modules//*
included=https://*.jjs\:https://*.js\:https://*.jshintrc\:https://*.mjs\:https://*.njs\:https://*.pjs\:https://*.vjs
projectSpecificOptions=true
2 changes: 2 additions & 0 deletions Dashboard/.settings/org.eclipse.wst.jsdt.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
eclipse.preferences.version=1
semanticValidation=disabled
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
org.eclipse.wst.jsdt.launching.JRE_CONTAINER
1 change: 1 addition & 0 deletions Dashboard/.settings/org.eclipse.wst.jsdt.ui.superType.name
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Global
1 change: 1 addition & 0 deletions Dashboard/.tern-project
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
{"libs":["ecma5"],"plugins":{"node":{}},"ide":{}}
122 changes: 122 additions & 0 deletions Dashboard/app.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
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 passport = require('passport');
require('./routes/passport')(passport);

var routes = require('./routes/index');
var users = require('./routes/users');
var home = require('./routes/home');
var mongoSessionURL = "mongodb:https://localhost:27017/login";
var expressSessions = require("express-session");
var mongoStore = require("connect-mongo/es5")(expressSessions);

var app = express();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'ejs');

// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__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')));
app.use(expressSessions({
secret: "litmus_passport",
resave: false,
saveUninitialized: false,
duration: 30 * 60 * 1000,
activeDuration: 5 * 6 * 1000,
store: new mongoStore({
url: mongoSessionURL
})
}));
app.use(passport.initialize());

app.use('/users', users);
app.get('/', home.signin);
app.use('/users', users);
app.get('/signIn',home.signin);
app.get('/dashboard',routes);
app.get('/getData',home.generateData);

app.get('/logout', function(req,res) {
req.session.destroy();
res.redirect('/');
});

app.post('/login', function(req, res, next) {

passport.authenticate('login', function(err, user, info) {
if(err) {
return next(err);
}

if(!user) {
return res.redirect('/');
}

req.logIn(user, {session:false}, function(err) {
if(err) {
return next(err);
}
req.session.user = req.body.username;
console.log("session initilized");
return res.render('index');
});
})(req, res, next);
});

app.post('/login', isAuthenticated, function(req, res) {
console.log("session: "+req.session.user);
res.render('index', {user:{username: req.session.user}});
});

function isAuthenticated(req, res, next) {
if(req.session.user) {
console.log(req.session.user);
return next();
}

res.redirect('/');
};

// catch 404 and forward to error handler
app.use(function(req, res, next) {
var err = new Error('Not Found');
err.status = 404;
next(err);
});

// error handlers

// 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;
90 changes: 90 additions & 0 deletions Dashboard/bin/www
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
#!/usr/bin/env node

/**
* Module dependencies.
*/

var app = require('../app');
var debug = require('debug')('Dashboard:server');
var http = require('http');

/**
* Get port from environment and store in Express.
*/

var port = normalizePort(process.env.PORT || '3000');
app.set('port', port);

/**
* Create HTTP server.
*/

var server = http.createServer(app);

/**
* Listen on provided port, on all network interfaces.
*/

server.listen(port);
server.on('error', onError);
server.on('listening', onListening);

/**
* Normalize a port into a number, string, or false.
*/

function normalizePort(val) {
var port = parseInt(val, 10);

if (isNaN(port)) {
// named pipe
return val;
}

if (port >= 0) {
// port number
return port;
}

return false;
}

/**
* Event listener for HTTP server "error" event.
*/

function onError(error) {
if (error.syscall !== 'listen') {
throw error;
}

var bind = typeof port === 'string'
? 'Pipe ' + port
: 'Port ' + port;

// handle specific listen errors with friendly messages
switch (error.code) {
case 'EACCES':
console.error(bind + ' requires elevated privileges');
process.exit(1);
break;
case 'EADDRINUSE':
console.error(bind + ' is already in use');
process.exit(1);
break;
default:
throw error;
}
}

/**
* Event listener for HTTP server "listening" event.
*/

function onListening() {
var addr = server.address();
var bind = typeof addr === 'string'
? 'pipe ' + addr
: 'port ' + addr.port;
debug('Listening on ' + bind);
}
1 change: 1 addition & 0 deletions Dashboard/node_modules/.bin/mime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Dashboard/node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 6a450f0

Please sign in to comment.