Created
October 14, 2014 04:48
-
-
Save calvintwr/21f13462147509d068f6 to your computer and use it in GitHub Desktop.
iOS Safari problem: package JSON
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "name": "hashionable", | |
| "version": "0.0.1", | |
| "private": true, | |
| "scripts": { | |
| "start": "node ./bin/www" | |
| }, | |
| "dependencies": { | |
| "async": "0.9.0", | |
| "bcrypt-nodejs": "0.0.3", | |
| "biguint-format": "0.2.1", | |
| "bluebird": "2.3.4", | |
| "body-parser": "~1.0.0", | |
| "connect-flash": "0.1.1", | |
| "consolidate": "0.10.0", | |
| "cookie-parser": "~1.0.1", | |
| "debug": "~0.7.4", | |
| "dustjs-linkedin": "2.4.0", | |
| "dustjs-helpers" : "1.3.0", | |
| "express": "~4.9.7", | |
| "express-session": "1.2.1", | |
| "flake-idgen": "0.1.3", | |
| "formidable": "1.0.15", | |
| "gm": "1.16.0", | |
| "less-middleware": "1.0.x", | |
| "moment": "2.8.1", | |
| "morgan": "~1.0.0", | |
| "passport": "0.2.0", | |
| "passport-local": "1.0.0", | |
| "pg": "^3.4.0", | |
| "static-favicon": "~1.0.0", | |
| "socket.io": "1.1.0" | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| var express = require('express'); | |
| /* routes */ | |
| var routes = require('./routes/index'); | |
| var users = require('./routes/users'); | |
| var path = require('path'); | |
| var favicon = require('static-favicon'); | |
| var logger = require('morgan'); | |
| var cookieParser = require('cookie-parser'); | |
| var bodyParser = require('body-parser'); | |
| //dev utilities | |
| //var sys = require('sys'); | |
| //var util = require('util'); | |
| var cons = require('consolidate'); | |
| /* sequelize */ | |
| var db = require('./models'); | |
| global.db = db; | |
| var Promise = require('bluebird'); | |
| global.Promise = Promise; | |
| /* passport and its friends */ | |
| var passport = require('passport'); | |
| //flash messages is deprecated. | |
| //var flash = require('connect-flash'); | |
| var session = require('express-session'); | |
| var jumanji = require('jumanji'); | |
| var app = express(); | |
| // view engine setup | |
| app.set('views', path.join(__dirname, 'views')); | |
| app.engine('dust', cons.dust); | |
| app.set('view engine', 'dust'); | |
| app.use(favicon()); | |
| app.use(logger('dev')); | |
| //using jumanji to sniff safari and get rid of blank page issue. monitoring... | |
| app.use(jumanji); | |
| app.use(bodyParser.json()); | |
| app.use(bodyParser.urlencoded()); | |
| app.use(cookieParser('hashionhashion')); | |
| app.use(require('less-middleware')(path.join(__dirname, 'public'))); | |
| app.use(express.static(path.join(__dirname, 'public'))); | |
| app.use(session({ secret: 'hashionhashion' })); // session secret | |
| app.use(passport.initialize()); | |
| app.use(passport.session()); // persistent login sessions | |
| //app.use(flash()); // use connect-flash for flash messages stored in session | |
| //routing | |
| app.use('/', routes); | |
| app.use('/users', users); | |
| //safari caching bug. | |
| //disabling etag takes away some performance gains. | |
| //more on this issue: https://github.com/jshttp/fresh/issues/8 | |
| app.disable('etag'); | |
| /// 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: {} | |
| }); | |
| }); | |
| //start the server | |
| var server = require('http').Server(app); | |
| var io = require('socket.io')(server); | |
| var ioSockets = {}; | |
| io.on('connection', function(socket) { | |
| ioSockets[socket.id] = socket; | |
| socket.emit('welcome', {message: socket.id}); | |
| socket.on('disconnect', function(socket) { | |
| delete ioSockets[socket.id]; | |
| }); | |
| }); | |
| //uncomment if we need to export io instance | |
| //exports.io = io; | |
| exports.ioSockets = ioSockets; | |
| module.exports = app; | |
| server.listen(3000, function() { | |
| console.log('Congrats, nothing broke!! Listening on port %d', server.address().port); | |
| }); | |
| var moment = require('moment'); | |
| //console.log time very 5 minutes | |
| setInterval(function() { | |
| console.log(moment().format()); | |
| }, 300000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment