How to use the restify.queryParser 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 intuit / saloon / server / index.js View on Github external
/* eslint-env node */
/* eslint import/no-extraneous-dependencies: 0 */

import restify from 'restify'; // eslint-disable-line

import restApi from './restApi';
import graphqlApi from './graphqlApi';

/**
 * SERVER
 */
const port = process.env.PORT || 3000;
const server = restify.createServer();

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

restApi(server);
graphqlApi(server);

/**
 * START 'ER UP
 */
export default {
  ready: new Promise((resolve, reject) => {
    server.listen(port, (err) => {
      if (err) {
        console.error(err); // eslint-disable-line no-console
        reject();
      } else {
        resolve();
github alexbeletsky / react-restify-isomorphic / app.js View on Github external
// enable es6 features in node
require("babel/register");

var restify = require('restify');
var nunjucks = require('nunjucks');

var config = require('./config');
var middleware = require('./source/middleware');
var logger = require('./source/utils/logger');

var app = restify.createServer();
var env = process.env.NODE_ENV || 'development';
var port = process.env.PORT || 3012;

app.use(middleware.mongo(config));
app.use(restify.queryParser());

// applications api
require('./source/api')(app);

// master.html, assets
require('./source/static')(app, restify);

// configurations
nunjucks.configure('./views');

app.listen(port, function () {
	logger.info('router-switch listening on port ' + port + ' ' + env);
});
github Azure / meta-azure-service-broker / lib / broker / v2 / index.js View on Github external
BrokerV2.prototype.createRestServer = function() {
  var broker = this;
  var versionNS = '/v' + broker.opts.semver.major;

  var server = Restify.createServer({
    name: broker.opts.name,
    version: broker.opts.apiVersion
  });

  server.use(RestifyMiddleware.validateAPIVersion(broker.opts.semver));
  server.use(Restify.authorizationParser());
  server.use(Handlers.authenticate(broker.opts.serviceBroker.credentials));
  server.use(Restify.acceptParser(server.acceptable));
  server.use(Restify.queryParser());
  server.use(Restify.bodyParser());
  server.use(RestifyMiddleware.requestLogger({
    prefix: 'HTTP Request'
  }));

  // Catalog
  server.get(versionNS + '/catalog',
    function(req, res, next) {
      Handlers.handleCatalogRequest(broker, req, res, next);
    }
  );

  // Provision
  server.put(versionNS + '/service_instances/:instance_id',
    function(req, res, next) {
      Handlers.handleProvisionRequest(broker, req, res, next);
github covcom / 304CEM / Lab Demos / week08 / before / index.js View on Github external
'use strict'

const restify = require('restify')
const server = restify.createServer()

const googleapi = require('./modules/booksquery')
const favourites = require('./modules/favourites')
const authorization = require('./modules/authorisation')
const users = require('./modules/users')

server.use(restify.fullResponse())
server.use(restify.queryParser())
server.use(restify.bodyParser())
server.use(restify.authorizationParser())

server.get('/booksearch', googleapi.doBookSearch)

server.get('/favourites', authorization.authorize, favourites.list)  // get a list of all favs
server.post('/favourites', authorization.authorize, favourites.validate, favourites.add)  // add a new fav
server.get('/favourites/:id', authorization.authorize, favourites.get)  // get details of a particular fav using id
server.put('/favourites/:id', authorization.authorize, favourites.validate, favourites.update)  // update details of existing fav using id
server.del('/favourites/:id', authorization.authorize, favourites.delete)  // delete existing fav using id

server.post('/users', users.validateUser, users.add)  // add a new user to the DB (pending confirmation)
server.post('/users/confirm/:username', users.validateCode, users.confirm)  // confirm a pending user
server.del('/users/:username', authorization.authorize, users.delete)  // delete a user

const port = process.env.PORT || 8080
github AzureAD / passport-azure-ad / examples / server-oauth2 / server.js View on Github external
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
/*
/* Passport pattern provides the need to manage users and info tokens
github tes / seguir / server / index.js View on Github external
function bootstrapServer (api, config, next) {

  var server = restify.createServer({
    name: 'seguir',
    version: '0.1.0',
    log: config.logger || defaultLogger
  });

  // Default middleware
  server.use(restify.bodyParser({mapParams: true}));
  server.use(restify.queryParser({mapParams: false}));
  server.use(restify.gzipResponse());
  server.use(restify.CORS());
  server.use(function (req, res, cb) {
    debug(req.url, req.params, req.headers);
    cb();
  });

  // Logging
  server.on('after', function (request, response, route, error) {
    var fn = error ? 'error' : 'info';
    if (api.config.logging) {
      request.log[fn]({req: request, res: response, route: route, err: error}, 'request');
    }
  });

  server.get(/\/docs\/current\/?.*/, restify.serveStatic({
github joyent / sdc-docker / lib / endpoints / images.js View on Github external
// Match '/:apiversion/images/:name/push' where ':name' can include '/'.
    http.post(
        { path: /^(\/v[^\/]+)?\/images\/(.*?)\/push$/, name: 'ImagePush' },
        reqParamsName, before, imagePush);

    // Match '/:apiversion/images/:name/tag' where ':name' can include '/'.
    http.post(
        { path: /^(\/v[^\/]+)?\/images\/(.*?)\/tag$/, name: 'ImageTag' },
        reqParamsName, before, reqImage,
        restify.queryParser({mapParams: false}), imageTag);

    // Match '/:apiversion/images/:name' where ':name' can include '/'.
    http.del(
        { path: /^(\/v[^\/]+)?\/images\/(.*?)$/, name: 'ImageDelete' },
        reqParamsName, before,
        restify.queryParser({mapParams: false}), imageDelete);

    http.get({ path: /^(\/v[^\/]+)?\/images\/search$/, name: 'ImageSearch' },
        before, restify.queryParser({mapParams: false}),
        common.reqRegAuth, imageSearch);

    // Match '/:apiversion/images/:name/get' where ':name' can include '/'.
    http.get(
        { path: /^(\/v[^\/]+)?\/images\/(.*?)\/get$/, name: 'ImageGet' },
        reqParamsName, before, imageGet);

    // Match '/:apiversion/images/:name/load' where ':name' can include '/'.
    http.post(
        { path: /^(\/v[^\/]+)?\/images\/(.*?)\/load$/, name: 'ImageLoad' },
        reqParamsName, before, imageLoad);
}
github snyk / snyk / test / cli-server.js View on Github external
module.exports = function(root, apikey, notAuthorizedApiKey) {
  var server = restify.createServer({
    name: 'snyk-mock-server',
    version: '1.0.0',
  });

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

  [root + '/verify/callback', root + '/verify/token'].map(function(url) {
    server.post(url, function(req, res) {
      if (req.params.api) {
        if (
          req.params.api === apikey ||
          (notAuthorizedApiKey && req.params.api === notAuthorizedApiKey)
        ) {
          return res.send({
            ok: true,
            api: apikey,
          });
        }
      }
github bryanpaluch / jsep-to-sip-gw / server.js View on Github external
JSEPGateway = require('./lib/jsep-to-sip'),
    request = require('request'),
    logger = require('./lib/logwinston');

var env = process.env.NODE_ENV || 'development';
var config = require('./config/conftool').getConf();
var server = restify.createServer({
    name: 'jsep-to-sip-gateway',
      version: '0.0.1'
});

require('./lib/registrar_db').connect();


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

var jsepSession = require('./controllers/session');
var user = require('./controllers/user');

//inbound calls
server.post('/session', jsepSession.create);
server.put('/session/:uuid', jsepSession.add);
server.del('/session/:uuid', jsepSession.remove);


//registration
server.post('/registration', user.register);

server.listen(config.httpport, function () {
    logger.log('info', 'JSEP to Sip Gateway ' + server.name + 'listening at '+ server.url);