How to use method-override - 10 common examples

To help you get started, we’ve selected a few method-override 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 cncjs / cncjs / src / app / app.js View on Github external
// https://github.com/expressjs/body-parser
    app.use(bodyParser.json(settings.middleware['body-parser'].json));
    app.use(bodyParser.urlencoded(settings.middleware['body-parser'].urlencoded));

    // For multipart bodies, please use the following modules:
    // - [busboy](https://github.com/mscdex/busboy) and [connect-busboy](https://github.com/mscdex/connect-busboy)
    // - [multiparty](https://github.com/andrewrk/node-multiparty) and [connect-multiparty](https://github.com/andrewrk/connect-multiparty)
    app.use(multiparty(settings.middleware.multiparty));

    // https://github.com/dominictarr/connect-restreamer
    // connect's bodyParser has a problem when using it with a proxy.
    // It gobbles up all the body events, so that the proxy doesn't see anything!
    app.use(connectRestreamer());

    // https://github.com/expressjs/method-override
    app.use(methodOverride());
    if (settings.verbosity > 0) {
        // https://github.com/expressjs/morgan#use-custom-token-formats
        // Add an ID to all requests and displays it using the :id token
        morgan.token('id', (req, res) => {
            return req.session.id;
        });
        app.use(morgan(settings.middleware.morgan.format));
    }
    app.use(compress(settings.middleware.compression));

    Object.keys(settings.assets).forEach((name) => {
        const asset = settings.assets[name];

        log.debug('assets: name=%s, asset=%s', name, JSON.stringify(asset));
        if (!(asset.path)) {
            log.error('asset path is not defined');
github cheton / webappengine / src / app / app.standalone.js View on Github external
// https://github.com/expressjs/body-parser
    app.use(bodyParser.json(settings.middleware['body-parser'].json));
    app.use(bodyParser.urlencoded(settings.middleware['body-parser'].urlencoded));

    // For multipart bodies, please use the following modules:
    // - [busboy](https://github.com/mscdex/busboy) and [connect-busboy](https://github.com/mscdex/connect-busboy)
    // - [multiparty](https://github.com/andrewrk/node-multiparty) and [connect-multiparty](https://github.com/andrewrk/connect-multiparty)
    app.use(multiparty(settings.middleware.multiparty));

    // https://github.com/dominictarr/connect-restreamer
    // connect's bodyParser has a problem when using it with a proxy.
    // It gobbles up all the body events, so that the proxy doesn't see anything!
    app.use(connectRestreamer());

    // https://github.com/expressjs/method-override
    app.use(methodOverride());
    if (settings.verbosity > 0) {
        // https://github.com/expressjs/morgan#use-custom-token-formats
        // Add an ID to all requests and displays it using the :id token
        morgan.token('id', (req, res) => {
            return req.session.id;
        });
        app.use(morgan(settings.middleware.morgan.format));
    }
    app.use(compress(settings.middleware.compression));

    _.each(settings.assets, (asset, name) => {
        log.debug('assets: name=%s, asset=%s', name, JSON.stringify(asset));

        if (!(asset.path)) {
            log.error('asset path is not defined');
            return;
github kartikayg / StatusPage / notification-service / src / server / index.js View on Github external
const start = (conf, options) => {

  const app = express();

  // parse body params and attache them to req.body
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: true }));

  app.use(compress());
  app.use(methodOverride());

  // secure apps by setting various HTTP headers
  app.use(helmet());

  // enable CORS - Cross Origin Resource Sharing
  app.use(cors());

  // log the call
  if (conf.ENABLE_HTTP_REQUEST_LOGS === true) {
    app.use(logRequest(options.messagingQueue));
  }

  // setup routes
  app.use('/notification-service/api', routes(options));

  // if there is an error at this point, it means it is unexpected like db
github garage-it / SmartHouse-backend / src / config / express.js View on Github external
import ExtendableError from '../API/helpers/ExtendableError';
import passport from 'passport';

const app = express();

if (config.env === 'development') {
    app.use(logger('dev'));
}

// parse body params and attache them to req.body
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.use(cookieParser());
app.use(compress());
app.use(methodOverride());

app.use(passport.initialize());
app.use(passport.session());

// disable 'X-Powered-By' header in response
app.disable('x-powered-by');

// enable CORS - Cross Origin Resource Sharing
app.use(cors());

// enable detailed API logging in dev env
if (config.env === 'development') {
    expressWinston.requestWhitelist.push('body');
    expressWinston.responseWhitelist.push('body');
    app.use(expressWinston.logger({
        winstonInstance,
github rcos / observatory-server / server / config / express.js View on Github external
export default function(app) {
  var env = app.get('env');

  app.set('views', config.root + '/server/views');
  app.engine('html', require('ejs').renderFile);
  app.set('view engine', 'html');
  app.use(compression());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(bodyParser.json());
  app.use(methodOverride());
  app.use(cookieParser());
  app.use(passport.initialize());

  // Persist sessions with mongoStore / sequelizeStore
  // We need to enable sessions for passport-twitter because it's an
  // oauth 1.0 strategy, and Lusca depends on sessions
  app.use(session({
    secret: config.secrets.session,
    saveUninitialized: true,
    resave: false,
    store: new mongoStore({
      mongooseConnection: mongoose.connection,
      db: 'observatory3'
    })
  }));
github amida-tech / api-boilerplate / config / express.js View on Github external
import logger from './winston/get-default-logger';
import routes from '../server/routes/index.route';
import APIError from '../server/helpers/APIError';

// Define default HTTP logger instance (use default logger instance)
const winstonInstance = logger;

const app = express();

// parse body params and attache them to req.body
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: true }));

app.use(cookieParser());
app.use(compress());
app.use(methodOverride());

// secure apps by setting various HTTP headers
app.use(helmet());

// enable CORS - Cross Origin Resource Sharing
app.use(cors());

// This is really just a test output and should be the first thing you see
winstonInstance.info('The application is starting...');

// enable detailed API logging in dev env
if (config.env === 'development') {
    expressWinston.requestWhitelist.push('body');
    expressWinston.responseWhitelist.push('body');
    app.use(expressWinston.logger({
        winstonInstance,
github kartikayg / StatusPage / incidents-service / src / server / index.js View on Github external
return new Promise((resolve) => {

    const app = express();

    // parse body params and attache them to req.body
    app.use(bodyParser.json());
    app.use(bodyParser.urlencoded({ extended: true }));

    app.use(compress());
    app.use(methodOverride());

    // secure apps by setting various HTTP headers
    app.use(helmet());

    // enable CORS - Cross Origin Resource Sharing
    app.use(cors());

    // log the call
    if (conf.ENABLE_HTTP_REQUEST_LOGS === true) {
      app.use(logRequest(options.messagingQueue));
    }

    // setup routes
    app.use('/incidents-service/api', routes(options));

    // if there is an error at this point, it means it is unexpected like db
github adeperio / base / src / server / server.js View on Github external
//setting CSP
var scriptSources = ["'self'", "'unsafe-inline'", "'unsafe-eval'", "ajax.googleapis.com", "www.google-analytics.com"];
var styleSources = ["'self'", "'unsafe-inline'", "ajax.googleapis.com"];
var connectSources = ["'self'"];

server.use(helmet.contentSecurityPolicy({
    defaultSrc: ["'self'"],
    scriptSrc: scriptSources,
    styleSrc: styleSources,
    connectSrc: connectSources,
    reportOnly: false,
    setAllHeaders: false,
    safari5: false
}));

server.use(methodOverride());
server.use(bodyParser());

//setup express sessions
server.use(cookieParser());
server.use(session({
  store: new pgSession({
    pg : pg,
    conString : Config.connectionString,
    tableName : 'session',
    schemaName: 'public'
  }),
  secret: Config.session.secret,
  resave: false,
  saveUninitialized: true,
  expires : new Date(Date.now() + 3600000), //1 Hour
  cookie: { httpOnly:true, secure: true }
github mapcontrib / mapcontrib / server.js View on Github external
app.use(compression());
app.use(
  helmet({
    frameguard: false
  })
);
app.engine('ejs', ejs.renderFile);
app.set('view engine', 'ejs');
app.set('views', path.resolve(__dirname, 'views'));
app.use(cookieParser());
app.use(bodyParser.json({ limit: '50mb' }));
app.use(bodyParser.urlencoded({ limit: '50mb', extended: true }));

app.set('port', config.get('server.port'));
app.use(morgan('dev'));
app.use(methodOverride());

if (app.get('env') !== 'production') {
  app.use(errorHandler());
}

app.get('/theme-s8c2d4', (req, res) => {
  res.redirect('/t/s8c2d4-MapContrib');
});

const database = new Database();
const passport = new Passport();
const api = new Api();

database.connect((err, db) => {
  if (err) {
    throw err;
github TossShinHwa / node-odata / src / express.js View on Github external
export default function (options) {
  const app = express();
  const opts = (options && options.expressRequestLimit) ?
                { limit: options.expressRequestLimit } : {};
  app.use(bodyParser.json(opts));
  opts.extended = true;
  app.use(bodyParser.urlencoded(opts));
  app.use(methodOverride());
  app.use(express.query());
  app.use(cors());
  app.disable('x-powered-by');
  return app;
}

method-override

Override HTTP verbs

MIT
Latest version published 6 years ago

Package Health Score

68 / 100
Full package analysis

Popular method-override functions

Similar packages