How to use the connect.cookieParser 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-webot / wechat / test / list.test2.js View on Github external
require('should');
var List = require('../').List;

var request = require('supertest');
var template = require('./support').template;
var tail = require('./support').tail;

var connect = require('connect');
var wechat = require('../');

var app = connect();
app.use(connect.query());
app.use(connect.cookieParser());
app.use(connect.session({secret: 'keyboard cat', cookie: {maxAge: 60000}}));
app.use('/wechat', wechat('some token', function (req, res, next) {
  // 微信输入信息都在req.weixin上
  var info = req.weixin;
  if (info.Content === 'list') {
    res.wait('view');
  }
}));

describe('list', function() {
  it('should ok with list', function (done) {
    List.add('view', [
      ['回复{c}查看我的性取向', '这样的事情怎么好意思告诉你啦- -']
    ]);
    var info = {
      sp: 'test',
github treygriffith / connect-mongodb / example / index.js View on Github external
(msgs[type] = msgs[type] || []).push(msg);
  } else if (type) {
    var arr = msgs[type];
    delete msgs[type];
    return arr || [];
  } else {
    this.session.flash = {};
    return msgs;
  }
};

connect.createServer(

    connect.favicon(),
    connect.bodyParser(),
    connect.cookieParser(),
    // reap every 6 seconds, 6 seconds maxAge
    connect.session({cookie: {maxAge: 6000}, store: mongo_store, secret: 'foo'}),

    // Increment views
    function (req, res) {
      req.session.count = req.session.count || 0
      ++req.session.count;

      // Display online count
      req.sessionStore.length(function(err, len){
        if (req.session.count < 10) {
          var msgs = req.flash('info').join('\n');
          res.writeHead(200, { 'Content-Type': 'text/html' });
          res.write(msgs);
          res.write('<form method="post"><input value="bar" name="foo" type="hidden"><input value="POST request!" type="submit"></form>');
          res.write('<p>online : ' + len + '</p>');
github fengmk2 / nodejs-web-dev / todo / connect / app.js View on Github external
"use strict";

/**
 * Module dependencies.
 */

var connect = require('connect');
var path = require('path');
var urlrouter = require('urlrouter');
var render = require('connect-render');
var routes = require('./routes');
var config = require('./config');

var app = connect(
  connect.bodyParser(),
  connect.cookieParser(),
  connect.session({ secret: 'todo secret', key: 'sid' }),
  connect.csrf()
);

/**
 * Static files
 */
app.use('/public', connect.static(path.join(__dirname, 'public')));

/**
 * Template Engine helper
 */
app.use(render({
  root: __dirname + '/views',
  layout: 'layout.html',
  cache: false, // must set `true` for prodution
github accesolibre / proxy / app.js View on Github external
function initApp() {
    // the redis client differs depending on if you're using redistogo (heroku) or not
    if (config.redistogo_url) {
        redis = require('redis-url').connect(config.redistogo_url);
    } else {
        redis = require('redis').createClient(config.redis_port, config.redis_host, config.redis_options);
    }
    redis.unref();

    return connect()
        .use(connect.cookieParser(config.secret))
        .use(connect.session({
            store: new RedisStore({
                client: redis
            }),
            cookie: {
                path: '/',
                httpOnly: false,
                maxAge: null
            }
        }))
        .use(handleRequest);
}
github jpallen / connect-cookie-session / example.js View on Github external
var connect       = require("connect"),
    cookieSession = require("connect-cookie-session");

connect(
    connect.cookieParser(), // cookieSession needs cookieParser
    cookieSession({
        // You should use your own secret key (and keep it secret!)
        secret : "d3b07384d113edec49eaa6238ad5ff00"
    }),
    function(req, res) {
        var accessCount = (req.session.accessCount || 0);
        req.session.accessCount = accessCount + 1;
        res.writeHead(200, {'Content-Type': 'text/plain'});
        res.end('You have accessed this site ' + accessCount + ' times');
    }
).listen(8080);
github AceMetrix / connect-cas / test / proxy-ticket.spec.js View on Github external
var serverSetup = function(options, done){
    var app = express()
    .use(connect.cookieParser())
    .use(connect.session({
        secret: 'ninja cat',
        key: 'sid'
    }))
    if (options.beforeMiddleware) app.use(options.beforeMiddleware);
    app.use(cas.proxyTicket(options));
    if (options.afterMiddleware) app.use(options.afterMiddleware);
    app.use(function(req, res, next){
        lastRequest = req;
        res.send('hello world');
    });
    var server = https.createServer({
        key: fs.readFileSync(__dirname + '/certs/localhost3000.key'),
        cert: fs.readFileSync(__dirname + '/certs/localhost3000.crt')
    }, app).listen(3000, done);
    return server;
github makarukudo / nodeigniter / app.js View on Github external
ni._initialize(function(){
    connect.createServer(
        connect.bodyParser(),
        connect.static('public'),
        connect.query(), 
        connect.cookieParser('ni_cookie'),
        connect.session({secret: 'kM43QtvEhmhH2KK9sJac',cookie: {maxAge: 36000}}),
        ni.router,
        ni.not_found
    ).listen(80);
    console.log('Application Started on Port: '+80);
});
github LockerProject / Locker / Connectors / Dropbox / dropbox.js View on Github external
*
*/

/**
 * web server/service to wrap interactions w/ GitHub API
 */

var fs = require('fs'),
    url = require('url'),
    express = require('express'),
    connect = require('connect'),
    request = require('request'),
    dbox = require('dropbox').DropboxClient,
    app = express.createServer(
                    connect.bodyParser(),
                    connect.cookieParser()),
    locker = require('../../Common/node/locker.js'),
    lfs = require('../../Common/node/lfs.js');

var me;

app.set('views', __dirname);
app.get('/', handleIndex);

var dapp=false;
function handleIndex(req, res) {
    res.writeHead(200, {'Content-Type': 'text/html'});
    if(dapp)
    {
        res.end(fs.readFileSync(__dirname + '/ui/index.html'));
    }else{
        res.end(fs.readFileSync(__dirname + '/ui/init.html'));
github LockerProject / Locker / Connectors / Twitter / pull_contacts.js View on Github external
}
process.chdir(cwd);


var http = require('http'),
    sys = require('sys');
    express = require('express'),
    connect = require('connect'),
    wwwdude = require('wwwdude'),
    lfs = require('../../Common/node/lfs.js');

var me = lfs.loadMeData();

var app = express.createServer(
    connect.bodyParser(),
    connect.cookieParser(),
    connect.session({secret : "locker"})
    );
    

var twitterClient = require('twitter-js')(me.consumerKey, me.consumerSecret, me.uri);

Array.prototype.addAll = function(anotherArray) {
    if(!anotherArray || !anotherArray.length)
        return;
    for(var i = 0; i &lt; anotherArray.length; i++)
        this.push(anotherArray[i]);
}


app.get('/friends',
function(req, res) {
github simonlast / storybook / server / server.js View on Github external
var express = require('express'),
  http = require('http'),
  connect = require('connect');

var saticServer = connect()
  .use(connect.static('public'))
  .use(connect.directory('public'))
  .use(connect.cookieParser());

var app = express();

app.configure( function(){
  app.use(saticServer);
  app.use(express.errorHandler());
  app.use(express.bodyParser());
});

var server = http.createServer(app);

server.listen(process.argv[2] || 80);