How to use the connect.query function in connect

To help you get started, we’ve selected a few connect 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 node-modules / weibo / examples / connect_with_oauth_middleware.js View on Github external
var weibo = require('../');

/**
 * init weibo api settings
 */ 

weibo.init('weibo', '1122960051', 'e678e06f627ffe0e60e2ba48abe3a1e3');
// weibo.init('github', '8e14edfda73a71f1f226', '1796ac639a8ada0dff6acfee2d63390440ca0f3b');
weibo.init('tqq', '801196838', '9f1a88caa8709de7dccbe3cae4bdc962');

/**
 * Create a web application.
 */

var app = connect(
  connect.query(),
  connect.cookieParser('oh year a cookie secret'),
  connect.session({ secret: "oh year a secret" }),
  // using weibo.oauth middleware for use login
  // will auto save user in req.session.oauthUser
  weibo.oauth({
    loginPath: '/login',
    logoutPath: '/logout',
    callbackPath: '/oauth/callback',
    blogtypeField: 'type',
    afterLogin: function (req, res, callback) {
      console.log(req.session.oauthUser.screen_name, 'login success');
      process.nextTick(callback);
    },
    beforeLogout: function (req, res, callback) {
      console.log(req.session.oauthUser.screen_name, 'loging out');
      process.nextTick(callback);
github cdapio / cdap / web-cloud-app / server / common / node_modules / express / lib / application.js View on Github external
app.defaultConfiguration = function(){
  // default settings
  this.enable('x-powered-by');
  this.set('env', process.env.NODE_ENV || 'development');
  this.set('subdomain offset', 2);
  debug('booting in %s mode', this.get('env'));

  // implicit middleware
  this.use(connect.query());
  this.use(middleware.init(this));

  // inherit protos
  this.on('mount', function(parent){
    this.request.__proto__ = parent.request;
    this.response.__proto__ = parent.response;
    this.engines.__proto__ = parent.engines;
    this.settings.__proto__ = parent.settings;
  });

  // router
  this._router = new Router(this);
  this.routes = this._router.map;
  this.__defineGetter__('router', function(){
    this._usedRouter = true;
    this._router.caseSensitive = this.enabled('case sensitive routing');
github chrisjenx / NodeSizer / node_modules / express / lib / application.js View on Github external
app.defaultConfiguration = function(){
  // default settings
  this.enable('x-powered-by');
  this.set('env', process.env.NODE_ENV || 'development');
  debug('booting in %s mode', this.get('env'));

  // implicit middleware
  this.use(connect.query());
  this.use(middleware.init(this));

  // inherit protos
  this.on('mount', function(parent){
    this.request.__proto__ = parent.request;
    this.response.__proto__ = parent.response;
    this.engines.__proto__ = parent.engines;
  });

  // router
  this._router = new Router(this);
  this.routes = this._router.map;
  this.__defineGetter__('router', function(){
    this._usedRouter = true;
    this._router.caseSensitive = this.enabled('case sensitive routing');
    this._router.strict = this.enabled('strict routing');
github expressjs / express / lib / application.js View on Github external
app.defaultConfiguration = function(){
  var self = this;

  // default settings
  this.set('home', '/');
  this.set('env', process.env.NODE_ENV || 'development');

  // always parse req.query
  this.use(connect.query());

  this.locals = function(obj){
    for (var key in obj) self.locals[key] = obj[key];
    return self;
  };

  this.locals.use = function(fn){
    self.viewCallbacks.push(fn);
    return this;
  };

  // expose objects to each other
  this.use(function(req, res, next){
    var charset;
    res.setHeader('X-Powered-By', 'Express');
    req.app = res.app = self;
github firebase / superstatic / lib / server / superstatic_server.js View on Github external
SuperstaticServer.prototype._createServer = function () {
  // The order of these middleware modules is DEATHLY important!!!
  return this._server = connect()
    .use(connect.logger())
    .use(connect.query())
    .use(middleware.router(this.settings, this.store, this.routes))
    .use(middleware.restful())
    .use(middleware.settingsCache)
    .use(middleware.static)
    .use(middleware.customRoute)
    .use(middleware.directoryIndex)
    .use(middleware.cleanUrls)
    .use(middleware.removeTrailingSlash)
    .use(connect.compress())
    .use(middleware.notFound)
    .use(middleware.cacheControl())
    .use(middleware.responder);
};
github ded / reqwest / make / tests.js View on Github external
'Expires': 0
      , 'Cache-Control': 'max-age=0, no-cache, no-store'
      , 'Content-Type': getMime(ext)
    })
    if (req.query.echo !== undefined) {
      ext == 'jsonp' && res.write((req.query.callback || req.query.testCallback || 'echoCallback') + '(')
      res.write(JSON.stringify({ method: req.method, query: req.query, headers: req.headers }))
      ext == 'jsonp' && res.write(');')
    } else {
      res.write(fs.readFileSync('./' + file + '.' + ext))
    }
    res.end()
  }
}

Connect.createServer(Connect.query(), dispatch(routes)).listen(1234)

var otherOriginRoutes = {
    '/get-value': function (req, res) {
      res.writeHead(200, {
        'Access-Control-Allow-Origin': req.headers.origin,
        'Content-Type': 'text/plain'
      })
      res.end('hello')
    },
    '/set-cookie': function (req, res) {
      res.writeHead(200, {
        'Access-Control-Allow-Origin': req.headers.origin,
        'Access-Control-Allow-Credentials': 'true',
        'Content-Type': 'text/plain',
        'Set-Cookie': 'cookie=hello'
      })
github eugeneware / firedup / test / wsocket.js View on Github external
beforeEach(function (done) {
    app = connect()
      .use(connect.query())
      .use(connect.static(path.join(__dirname, '..', 'public')));
    server = http.createServer(app).listen(port, function (err) {
      if (err) return done(err);
      socketServer = io.listen(server, { log: false });
      done();
    });
  });
github cdapio / cdap / server / cloud / node_modules / express / lib-cov / application.js View on Github external
app.defaultConfiguration = (function () {
  _$jscoverage['application.js'][72]++;
  var self = this;
  _$jscoverage['application.js'][75]++;
  this.set("env", process.env.NODE_ENV || "development");
  _$jscoverage['application.js'][76]++;
  debug("booting in %s mode", this.get("env"));
  _$jscoverage['application.js'][79]++;
  this.use(connect.query());
  _$jscoverage['application.js'][80]++;
  this.use(middleware.init(this));
  _$jscoverage['application.js'][83]++;
  this.locals = (function (obj) {
  _$jscoverage['application.js'][84]++;
  for (var key in obj) {
    _$jscoverage['application.js'][84]++;
    self.locals[key] = obj[key];
}
  _$jscoverage['application.js'][85]++;
  return self;
});
  _$jscoverage['application.js'][89]++;
  this.locals.use = (function (fn) {
  _$jscoverage['application.js'][90]++;
  if (3 == fn.length) {
github jaystack / jaydata / src / Types / StorageProviders / Storm / stormserver.js View on Github external
$data.EntityContext.extend('$test.Context', {
    Items: { type: $data.EntitySet, elementType: $test.Item },
    /*GetThat: (function(){
        return [1, 2, 3];
    }).returns($data.Array, $data.Integer).serviceName('GetThat').params([])
    Things: { type: $data.EntitySet, elementType: $test.Thing }*/
});

var connect = require('connect');
var app = require('connect')();

app.use(connect.multipart());
app.use(connect.urlencoded());
app.use(connect.json());
app.use(connect.bodyParser());
app.use(connect.query());

ISODate = function(date){
    return new Date(date);
};

app.use('/', function(req, res){
    if (req.method === 'GET'){
        $test.context = new $test.Context({ name: 'mongoDB', databaseName: 'storm' });
        $test.context.onReady(function(db){
            var callback = function(result){
                res.write(JSON.stringify(result));
                res.end();
            };
            
            var compiled = req.query.expression || {};