How to use the restify.dateParser function in restify

To help you get started, we’ve selected a few restify 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 cmawhorter / hmmac / test / api / server.js View on Github external
// timeout requests
server.use(function(req, res, next) {
  next();

  res.timeoutFn = setTimeout(function() {
    if (!res.finished) res.end();
  }, 30000);
});

// we're done. clear timeout.
server.on('after', function(req, res, route, err) {
  if (res.timeoutFn) clearTimeout(res.timeoutFn);
});

server.use(restify.acceptParser(server.acceptable));
server.use(restify.dateParser());
server.use(restify.jsonp());
server.use(restify.gzipResponse());
server.use(restify.bodyParser({ mapParams: false }));

module.exports = server;
github amd / rest3d / server / rest3d-server.js View on Github external
rmdirSync('cache');
rmdirSync('upload');

fs.mkdirSync('tmp');
fs.mkdirSync('upload');
fs.mkdirSync('cache');

fs.chmodSync('tmp', '777');
fs.chmodSync('upload', '777');
fs.chmodSync('cache', '777');

//fs.mkdirSync('upload/thumbnail');

server.use(restify.acceptParser(server.acceptable));
//server.use(restify.authorizationParser());
server.use(restify.dateParser());
server.use(restify.queryParser());
//server.use(restify.bodyParser()); -> use formidable instead
server.use(restify.gzipResponse());
restify.defaultResponseHeaders = false;

var session = require('./src/session')();

server.sessionManager = session;
server.use(session.sessionManager);

// call passport init after we have set the session manager
var passport = require('./src/passport');
passport.init(server);

// include routes
require('./src/jobs_routes')(server);
github yldio / training-node-angular-source-code / api.js View on Github external
var restify = require('restify');
var server = restify.createServer();


/// Middleware
server.use(restify.CORS());
server.use(restify.requestLogger());
server.use(restify.acceptParser(server.acceptable));
server.use(restify.dateParser());
server.use(restify.authorizationParser());
server.use(restify.queryParser());
server.use(restify.gzipResponse());
server.use(restify.bodyParser());

/// Routes
require('./routes')(server);


/// Listen
var port = parseInt(process.argv[2]) || 3001;

server.listen(port);

server.once('listening', function() {
  console.log('API Server is listening on port %d', port);
github AzureADQuickStarts / AppModelv2-WebAPI-nodejs / node-server / app.js View on Github external
// Handles annoying user agents (curl)
server.pre(restify.pre.userAgentConnection());

// Set a per request bunyan logger (with requestid filled in)
server.use(restify.requestLogger());

// Allow 5 requests/second by IP, and burst to 10
server.use(restify.throttle({
    burst: 10,
    rate: 5,
    ip: true,
}));

// Use the common stuff you probably want
server.use(restify.acceptParser(server.acceptable));
server.use(restify.dateParser());
server.use(restify.queryParser());
server.use(restify.gzipResponse());
server.use(restify.bodyParser({
    mapParams: true
})); // Allows for JSON mapping to REST
server.use(restify.authorizationParser()); // Looks for authorization headers

// Let's start using Passport.js

server.use(passport.initialize()); // Starts passport
server.use(passport.session()); // Provides session support

var bearerStrategy = new OIDCBearerStrategy(options,
    function(token, done) {
        log.info(token, 'was the token retreived');
        if (!token.oid)
github intuition-io / intuition / server / rest_server.js View on Github external
host     : program.server,
    user     : config.mysql.user,
    password : config.mysql.password,
    database : config.mysql.database
});

connection.connect(function(err) {
    if (err) throw err; 
    log('Connected to database');
});

var server = restify.createServer({name: 'R&D test'});

server.use(restify.acceptParser(server.acceptable));
server.use(restify.authorizationParser());
server.use(restify.dateParser());
server.use(restify.queryParser());
server.use(restify.bodyParser());
server.use(restify.throttle({
    burst: 100,
    rate: 50,
    ip: true, // throttle based on source ip address
    overrides: {
        '127.0.0.1': {
        //'192.168.0.12': {
            rate: 0, // unlimited
    burst: 0
        }
    }
}));
github AzureAD / passport-azure-ad / examples / server-oauth2-b2c / server.js View on Github external
// Handles annoying user agents (curl)
server.pre(restify.pre.userAgentConnection());

// Set a per request bunyan logger (with requestid filled in)
server.use(restify.requestLogger());

// Allow 5 requests/second by IP, and burst to 10
server.use(restify.throttle({
    burst: 10,
    rate: 5,
    ip: true,
}));

// Use the common stuff you probably want
server.use(restify.acceptParser(server.acceptable));
server.use(restify.dateParser());
server.use(restify.queryParser());
server.use(restify.gzipResponse());
server.use(restify.bodyParser({
    mapParams: true
})); // Allows for JSON mapping to REST
server.use(restify.authorizationParser()); // Looks for authorization headers

// Let's start using Passport.js

server.use(passport.initialize()); // Starts passport
server.use(passport.session()); // Provides session support

/**
/*
/* Calling the OIDCBearerStrategy and managing users
/*
github ngnjs / NGN / lib / web / API.js View on Github external
// Add a makeshift "all" method to the server
			this._server.all = function(route,method){
				me._server.get(route,method);
				me._server.put(route,method);
				me._server.post(route,method);
				me._server.del(route,method);
				me._server.head(route,method);
			};
			
			this._server.use(restify.acceptParser(this._server.acceptable));
			this.applyProcessor('preauthentication');
			this.applyProcessor('postauthentication');
			this.applyProcessor('preauthorization');
			this._server.use(restify.authorizationParser());
			this.applyProcessor('postauthorization');
			this._server.use(restify.dateParser());
			this._server.use(restify.queryParser());
			this._server.use(restify.bodyParser());
			
			this._server.use(function(req,res,next){
				if (req.body)
					req.body = typeof req.body == "string" ? JSON.parse(req.body) : req.body;
				next();
			});
			
			this.applyProcessor('prerequest');
			
			var _evt = [
				'NotFound',
				'MethodNotAllowed',
				'VersionNotAllowed',
				'after',
github Azure-Samples / active-directory-node-webapi / node-server / app.js View on Github external
// Handles annoying user agents (curl)
server.pre(restify.pre.userAgentConnection());

// Set a per request bunyan logger (with requestid filled in)
server.use(restify.requestLogger());

// Allow 5 requests/second by IP, and burst to 10
server.use(restify.throttle({
    burst: 10,
    rate: 5,
    ip: true,
}));

// Use the common stuff you probably want
server.use(restify.acceptParser(server.acceptable));
server.use(restify.dateParser());
server.use(restify.queryParser());
server.use(restify.gzipResponse());
server.use(restify.bodyParser({
    mapParams: true
})); // Allows for JSON mapping to REST
server.use(restify.authorizationParser()); // Looks for authorization headers

// Let's start using Passport.js

server.use(passport.initialize()); // Starts passport
server.use(passport.session()); // Provides session support

/**
/*
/* Calling the OIDCBearerStrategy and managing users
/*
github ng-nice / code-front-jet / seeds / default / mock / server.js View on Github external
'use strict';

var restify = require('restify');

var server = restify.createServer({
  name: 'mock-server',
  version: '1.0.0'
});

server.use(restify.acceptParser(server.acceptable));
server.use(restify.queryParser());
server.use(restify.bodyParser());

server.use(restify.authorizationParser());
server.use(restify.dateParser());
server.use(restify.CORS());
server.pre(restify.pre.sanitizePath());
server.pre(function (req, res, next) {
  res.charSet('utf-8');
  res.cache({maxAge: 0});
  next();
});

require('./routes')(server);

server.listen(5050, function () {
  console.log('Mock server listening at %s', server.url);
});
github MerlinDMC / smartos-public-dsapi / lib / server.js View on Github external
}

          var data = JSON.stringify(body, null, 2);

          if (res.getHeader('Content-Length') === undefined && res.contentLength === undefined) {
            res.setHeader('Content-Length', Buffer.byteLength(data));
          }

          return data;
        }
      }
  });

  server.use(restify.acceptParser(server.acceptable));
  server.use(restify.authorizationParser());
  server.use(restify.dateParser());
  server.use(restify.bodyParser({ mapParams: false }));
  server.use(restify.queryParser());

  server.get('/ping', function(req, res, next) {
    var data = {
      "ping": "pong"
    };

    res.send(data);

    next();
  });

  server.get('/stats', function(req, res, next) {
    var data = {
      "started_at": -1,