How to use the express.methodOverride 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 dundalek / warehouse / tests / browser-run.js View on Github external
var MemoryBackend = require('../backend/memory'),
    RestBackend = require('../backend/rest'),
    warehouse = require('..'),
    express = require('express'),
    _ = require('underscore'),
    app = express(),
    server = new MemoryBackend().objectStore('test', {keyPath: '_id'});

var port = 12345;


app.use(express.bodyParser());
app.use(express.methodOverride());

app.use(function(req, res, next) {
    if (req.url === '/' || req.url === '/index.html') {
        res.redirect('/tests/index.html');
        return;
    }

    // allow cross origin for testing
    res.header('Access-Control-Allow-Origin', '*');
    res.header('Access-Control-Allow-Methods', 'PUT, GET, POST, DELETE, OPTIONS');
      res.header('Access-Control-Allow-Headers', 'Content-Type, X-HTTP-Method-Override');

      // backbone emulateJSON support
      if (req.headers['content-type'] === 'application/x-www-form-urlencoded') {
          if (req.body.model) {
              req.body = JSON.parse(req.body.model);
github sebpiq / rhizome / bin / rhizome / main.js View on Github external
validateConfig(require(configFilePath), function(err, config, configErrors) {

  var wsServer = new websockets.WebSocketServer()
    , oscServer = new osc.OSCServer()

  if (_.keys(configErrors).length) {
    utils.printConfigErrors(configErrors)
    process.exit(1)
  }

  config.serverInstance = server

  app.set('port', config.webPort)
  app.use(express.logger('dev'))
  app.use(express.bodyParser())
  app.use(express.methodOverride())
  app.use(app.router)
  app.use('/rhizome', express.static(buildDir))

  // Serve the users pages
  config.pages.forEach(function(page) {
    if (page.rootUrl.search('/rhizome.*') !== -1)
      throw new Error(' the page with url \'/rhizome\' is reserved')
    app.use(page.rootUrl, express.static(page.dirName))
  })

  // Start servers
  async.parallel([

    websockets.renderClient.bind(websockets, buildDir),
    wsServer.start.bind(wsServer, config),
    oscServer.start.bind(oscServer, config),
github wshearn / openshift-origin-cartridge-nodejs / template / app.js View on Github external
, routes = require('./routes')
  , user = require('./routes/user')
  , http = require('http')
  , path = require('path');

var app = express();

// all environments
app.set('ip', process.env.OPENSHIFT_NODEJS_IP || "localhost");
app.set('port', process.env.OPENSHIFT_NODEJS_PORT || 3000);
app.set('views', __dirname + '/views');
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.bodyParser());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));

// development only
if ('development' == app.get('env')) {
  app.use(express.errorHandler());
}

app.get('/', routes.index);
app.get('/users', user.list);

http.createServer(app).listen(app.get('port'), app.get('ip'), function(){
  console.log('Express server listening on ip:' + app.get('ip') + ' port:' + app.get('port'));
});
github dwilhelm89 / Ethermap / lib / config / express.js View on Github external
app.configure(function(){
    app.engine('html', require('ejs').renderFile);
    app.set('view engine', 'html');
    app.use(express.logger('dev'));
    app.use(express.json());
    app.use(express.urlencoded());
    app.use(express.methodOverride());
    // Router needs to be last
    app.use(app.router);
  });
};
github G33kLabs / Node.VaSH / app.js View on Github external
///////////////////////////////////////////////////////////// APPLICATION /////////////
    // Create API server
    var app = express()
      , server = http.createServer(app) ;

    // Register VaSH as an express middleware plugin
    express.vash = require('./libs/server/express.vash') ;

    // Add session && router support
    // app.use(express.favicon());
    app.use(express.errorHandler({ dumpExceptions: true, showStack: true }));
    app.use(express.cookieParser());
    app.use(express.bodyParser());
    app.use(express.errorHandler());
    app.use(express.methodOverride());
   // app.use(express.csrf());

   // -- Create redis client
    // var clientRedis = redis.createClient(config.redis.port, config.redis.host);

    // -- Express sessions
    var sessionStore = new (require('express-sessions'))({
        storage: 'redis',
        host: config.redis.host, // optional
        port: config.redis.port, // optional
        collection: 'sessions', // optional
        expire: 86400 // optional
    });

    // -- Configure session
    app.use(express.session({
github bryanpaluch / jsep-to-sip-gw / example / requirejs_backbone / server.js View on Github external
app.configure(function(){
  app.set('port', process.env.PORT || 3000);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'jade');
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(express.static('./public'));
  app.use(app.router);
});
github redsquirrel / ipull / app.js View on Github external
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 kevinw / gitviz / app.js View on Github external
app.configure(function() {
  app.set('port', process.env.PORT || 3000);
  app.set('views', __dirname + '/views');
  app.set('view engine', 'hbs');
  app.use(express.favicon());
  app.use(express.logger('dev'));
  app.use(express.bodyParser());
  app.use(express.methodOverride());
  app.use(app.router);
  app.use(express.static(path.join(__dirname, 'public')));
});
github outsideris / node.js-programming / socket.io / connect / app.js View on Github external
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 spoletto / iOS-HTML5-Tethering / server / fs-server.js View on Github external
app.configure(function() {
    app.use(express.methodOverride());
    app.use(express.bodyParser());
    app.use(express.static(__dirname + '/public'));
    app.use(express.errorHandler({
        dumpExceptions: true,
        showStack: true
    }));
    app.use(app.router);
});