Add max age to static requests in production.
'use strict';

var express = require('express');
var passport = require('passport');
var path = require('path');

var routes = require('./routes');

var rootDir = path.dirname(require.main.filename);

module.exports = function (app) {
  var appDir = path.join(rootDir, 'app');
  var maxAge = 0;
  if (app.get('env') === 'production') {
    appDir = path.join(rootDir, 'build');
    maxAge = 86400000;
  }

  app.get('/auth/github', passport.authenticate('github', {scope: ['gist']}));
  app.get('/auth/github/callback', passport.authenticate('github', {
    successRedirect: '/'
  }));

  app.get('/api/gists/:id', routes.gists.show);

  app.use(express.static(appDir, {maxAge: maxAge}));

  // Catch-all route for HTML5 URLs
  app.get('*', function (req, res) {
    res.sendfile(path.join(appDir, 'index.html'));
  });
};

'use strict';

var express = require('express');
var passport = require('passport');
var path = require('path');

var routes = require('./routes');

var rootDir = path.dirname(require.main.filename);

module.exports = function (app) {
  var appDir = path.join(rootDir, 'app');
  if (app.get('env') === 'production') {
    appDir = path.join(rootDir, 'build');
  }

  app.get('/auth/github', passport.authenticate('github', {scope: ['gist']}));
  app.get('/auth/github/callback', passport.authenticate('github', {
    successRedirect: '/'
  }));

  app.get('/api/gists/:id', routes.gists.show);

  app.use(express.static(appDir));

  // Catch-all route for HTML5 URLs
  app.get('*', function (req, res) {
    res.sendfile(path.join(appDir, 'index.html'));
  });
};
