How to use the express.createServer function in express

To help you get started, we’ve selected a few express examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github PaulKinlan / ioreader / server / server.js View on Github external
http://www.apache.org/licenses/LICENSE-2.0

   Unless required by applicable law or agreed to in writing, software
   distributed under the License is distributed on an "AS IS" BASIS,
   WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   See the License for the specific language governing permissions and
   limitations under the License.
*/

var express = require('express');
var proxies = require('./proxies');
var exception = require('./exceptions');
var logic = require('./controller');
var config = require('../config');

var app = express.createServer();

var conf; // A handle to the configuration;

function bustCache(req, res, next) {
  res.setHeader("Expires","Mon, 26 Jul 1997 05:00:00 GMT");
  res.setHeader("Last-Modified", +new Date);
  res.setHeader("Cache-Control","no-store, no-cache, must-revalidate, max-age=0");
  res.setHeader("Cache-Control", "post-check=0, pre-check=0");
  res.setHeader("Pragma","no-cache");
  next();
}

var Cache = function(timeout) {
  var cache = {};
  var clearCacheItem = function(url) {
    console.log("Removing " + url + "_from cache. ");
github kennir / drawstory_server / app.js View on Github external
/**
 * Module dependencies.
 */

var express = require('express')
  , routes = require('./routes')
  , models = require('./models/models')
  , auth = require('./controllers/auth')
  , lexicon = require('./controllers/lexicon');

var app = module.exports = express.createServer();

auth.init(models.UserModel);
lexicon.init(models);


// Configuration

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});
github theodi / OpenRefine-WS / app.js View on Github external
authorizationURL: 'https://accounts.google.com/o/oauth2/auth',
    tokenURL: 'https://accounts.google.com/o/oauth2/token',
    clientID: config.googleAuth.clientID,
    clientSecret: config.googleAuth.clientSecret,
    callbackURL: "/auth/google/return"
  },
  function(accessToken, refreshToken, profile, done) {
//    User.findOrCreate({ exampleId: profile.id }, function (err, user) {
      process.nextTick(function() {
	      profile.identifier = accessToken;
	      return done(null, profile);
    });
  }
));

var app = express.createServer();

// configure Express
app.configure(function() {
  app.set('views', __dirname + '/views');
  app.set('view engine', 'ejs');
  app.use(express.logger());
  app.use(express.cookieParser());
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.session({ secret: 'keyboard cat' }));
  // Initialize Passport!  Also use passport.session() middleware, to support
  // persistent login sessions (recommended).
  app.use(passport.initialize());
  app.use(passport.session());
  app.use(app.router);
  app.use(express.static(__dirname + '/../../public'));
github ivolo / express-rate / examples / simple-redis.js View on Github external
var rate            = require('../lib/rate'),
	redis			= require('redis'),
	client			= redis.createClient();

var app = require('express').createServer();

// create the rate redis handler
var redisHandler = new rate.Redis.RedisRateHandler({client: client});



// 
// Monitor rate of a route
//

// options: handler is the mechanism where rate information is kept
// interval is the interval on which we are listening for the rate. Here we're counting requests per 1 second.
// If we switch interval to 10, then we are counting how many requests this route is handling per 10 seconds.
var simpleMiddleware = rate.middleware({handler: redisHandler, interval: 1});

app.get('/', simpleMiddleware, function(req, res, next){
github martinhansdk / Continuous-Meter-Reader / server / meter / app.js View on Github external
/**
 * Module dependencies.
 */

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

var app = module.exports = express.createServer();

io = require('socket.io').listen(app);
io.set('log level', 1); // disables debugging. this is optional. you may remove it if desired.

// Configuration

app.configure(function(){
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
  app.use(express.static(__dirname + '/public'));
});

app.configure('development', function(){
github substack / testling / _old / server.js View on Github external
.default('port', 8082)
    .argv
;
var fs = require('fs');
var util = require('util');
var path = require('path');
var url = require('url');

var testDir = path.resolve(process.cwd(), argv.tests);

var version = JSON.parse(fs.readFileSync(__dirname + '/package.json')).version;
var browserify = require('browserify');

var express = require('express');

var app = express.createServer();
app.use(argv.mount, express.static(__dirname + '/static'));
app.use(argv.mount, require('progressify'));

var jadeify = require('jadeify');
var fileify = require('fileify');

util.print('Generating bundle... ');
var bundle = browserify({
        mount : argv.mount + '/browserify.js',
        watch : true,
    })
    .require({ jquery : 'jquery-browserify' })
    .use(jadeify(__dirname + '/views', { watch : true }))
    .use(fileify('test_files', testDir, {
        extension : '.js',
        watch : true,
github bmander / vtp / example.js View on Github external
var express = require('express');
var fs = require('fs');
var mongodb = require('mongodb');

var server = new mongodb.Db('test', new mongodb.Server("127.0.0.1", 27017, {}));
var app = express.createServer();

app.get('/foobar', function(req,res){
  res.contentType("text");
  res.send( "Hi Elsbeth!" );
});

app.get('/static/js/jquery.js', function(req,res){
  res.contentType("javascript");
  fs.readFile( "templates/jquery.js", function(err,data){
    res.send( data );
  });
});

server.open(function(err, client) {
  var collection = new mongodb.Collection(client,"tiled_ways");
  var compcoll = new mongodb.Collection(client,"simple_tiles");
github swagger-api / swagger-node / src / main / js / petstore.js View on Github external
var express = require("express");
var url = require("url");

//	swagger core
var swagger = require("./swagger.js");

//	resources for the demo
var petResources = require("./petResources.js");

var app = express.createServer();

function callback(req, res) {
	res.send(JSON.stringify({
		"message" : "thanks for playing"
	}));
}

swagger.addGet(app, petResources.findByStatus, petResources.findByStatusSpec);
swagger.addGet(app, petResources.findByTags, petResources.findByTagsSpec);
swagger.addGet(app, petResources.findById, petResources.findByIdSpec);

swagger.addPost(app, callback, petResources.addPetSpec);
swagger.addDelete(app, callback, petResources.deletePetSpec);
swagger.addPut(app, callback, petResources.updatePetSpec);

swagger.addValidator(
github iLanguage / iLanguage / httpredirectapp.js View on Github external
var express = require('express');

//Everyauth and express keep routing to http rather than https
//http://stackoverflow.com/questions/7450940/automatic-https-connection-redirect-with-node-js-express
var http = express.createServer();
http.get('*',function(req,res){  
    res.redirect('https://auth.fieldlinguist.com'+req.url);
});
http.listen(8080);
github LockerProject / Locker / Apps / BackMeUp / bmu.js View on Github external
/*
*
* Copyright (C) 2011, The Locker Project
* All rights reserved.
*
* Please see the LICENSE file for more information.
*
*/


var fs = require('fs'),http = require('http');
var express = require('express'),connect = require('connect');
var app = express.createServer(connect.bodyParser());
var locker = require('../../Common/node/locker.js');
var lfs = require('../../Common/node/lfs.js');
var lconfig = require('../../Common/node/lconfig.js');
lconfig.load('../../Config/config.json');
var exec = require('child_process').exec;
var util = require('util');
var request = require('request');

app.set('views', __dirname);

var dbox=false;
var lockerBase=false;
app.get('/',
function(req, res) {
    res.writeHead(200, {
        'Content-Type': 'text/html'