• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript cookie-parser.default函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中cookie-parser.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了default函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: function

module.exports = function(app) {

    var env = config.env;

    //Compression middleware (should be placed before express.static)
    //The middleware will attempt to compress response bodies for all request that traverse through the middleware, based on the given options.
    app.use(compression({
        //The byte threshold for the response body size before compression is considered for the response, defaults to 1kb. 
        threshold: 512
    }));


    //app.use(passport.initialize());
    app.use(express.static(path.join(config.root, 'client')));
    app.set('appPath', 'client');
    app.use(multer().array('image', 1));

    app.set('view engine', 'html');
    //The extended option allows to choose between parsing the URL-encoded data 
    //with the querystring library (when false) or the qs library (when true).
    app.use(bodyParser.urlencoded({ extended: false }));
    app.use(bodyParser.json());
    
    // CookieParser should be above session
    app.use(cookieParser());
    app.use(cookieSession({ secret: config.secrets.cookie }));
    app.use(compression());
    //app.use(morgan('dev'));
    //app.use(passport.initialize());
    app.use(express.static(path.join(config.root, 'client/build')));
    app.use(express.static(path.join(config.root, 'node_modules')));
    app.set('appPath', 'client/build');

   

    // use passport session
    app.use(passport.initialize());
    app.use(session({
        secret: config.secrets.session,
        resave: true,
        saveUninitialized: true,
        store: new mongoStore({ mongooseConnection: mongoose.connection })
    }));


    // Use winston on production
    //var log = 'dev';
    var log;
    if (env !== 'development') {
        log = {
            stream: {
                write: message => winston.info(message)
            }
        };
    } else if (env === 'development') {
        log = 'dev'
    }    
    // Don't log during tests
    // Logging middleware
    if (env !== 'test') app.use(morgan(log));

    if (env === 'development' || env === 'test') {
        app.use(require('errorhandler')());
    }

    if (env !== 'test') {
        app.use(csrf());

        // This could be moved to view-helpers :-)
        app.use(function(req, res, next) {
            res.locals.csrf_token = req.csrfToken();
            next();
        });
    }
};
开发者ID:SaurabhLpRocks,项目名称:Team-Stack,代码行数:75,代码来源:express.ts


示例2: require

import https = require('https');
import http = require('http');

import express = require('express');
var logger = require('connect-logger');
var cookieParser = require('cookie-parser');
import session = require('express-session');
var FileStore = require('session-file-store')(session);
var expressHandlebars = require('hbs');

var controllerFactory = require('./controllers/index');

// setup express
var app = express();
app.use(logger());
app.use(cookieParser('8d705e4b-c142-420e-955a-a1a58263b6bd'));
app.use(session({
  store: new FileStore(),
  secret: '13603e53-f0af-41dd-b020-dbf5c9e7768e',
  resave: false,
  saveUninitialized: true
}));

// configure handlebars as the view engine
expressHandlebars.registerPartials(__dirname + '/views');

// configure express to use handlebars as the view engine
app.set('view engine', 'hbs');
// change express default where to look for views on the server
app.set('views', __dirname + '/views');
开发者ID:Billbrockbank,项目名称:pres-o365-node,代码行数:30,代码来源:server.ts


示例3: setupBodyParsing

function setupBodyParsing(app): void {
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
}
开发者ID:ncphillips,项目名称:ts-node,代码行数:5,代码来源:bodyParsing.ts


示例4: require

let logger = require('morgan');
let cookieParser = require('cookie-parser');
let bodyParser = require('body-parser');

let app = express();

// view engine setup
app.set('views', path.join(__dirname, '../views'));
app.set('view engine', 'ejs');

// uncomment after placing your favicon in /public
// app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger('dev'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({extended: false}));
app.use(cookieParser());
app.use(require('node-sass-middleware')({
  src: path.join(__dirname, '../public'),
  dest: path.join(__dirname, '../public'),
  indentedSyntax: false,
  sourceMap: true
}));

//
// connect to database and register models
///////////////////////////////////////////////////////////
import * as db from './models/mongooseModels';

//
// serve static files
///////////////////////////////////////////////////////////
开发者ID:Toktik,项目名称:node-seed,代码行数:31,代码来源:app.ts


示例5: function

	constructor(config : IServerConfig) {
		this.config = config;
		mongoose.Promise = promise;
		mongoose.connect(this.config.dbURI, function (err) {
			if (err) {
				return console.log('Cannot connect to database', err);
			}
			return console.log('Database connected.');
		});

		this.app = express();
		// view engine setup
		this.app.set('views', path.join(__dirname, 'views'));
		this.app.set('view engine', 'jade');

		// use compression
		this.app.use(compression());
		// uncomment after placing your favicon in /public
		// app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
		this.app.use(logger('dev'));
		this.app.use(cookieParser());
		this.app.use(bodyParser.json({ limit: '50mb'}));
		this.app.use(bodyParser.urlencoded({limit: '50mb', extended: true}));
		this.app.use(express.static(path.join(__dirname, 'public'), {maxAge: 3000000000}));

		this.app.use(accessController.statusChecker);

		this.app.use('/', routes);
		this.app.use('/users', users);
		this.app.use('/comics', comics);

		this.app.use('/comics/edit', express.static(path.join(__dirname, 'public')));
		this.app.use('/comics/canvas', express.static(path.join(__dirname, 'public')));
		this.app.use('/create', express.static(path.join(__dirname, 'public')));
		this.app.use('/canvas', express.static(path.join(__dirname, 'public')));
		// catch 404 and forward to error handler
		this.app.use(function(req, res, next) {
		  var err = new Error('Not Found');
		  err.status = 404;
		  next(err);
		});

		// error handlers

		// development error handler
		// will print stacktrace
		if (this.app.get('env') === 'development') {
		  this.app.use(function(err, req, res, next) {
		    res.status(err.status || 500);
		    res.render('error', {
		      message: err.message,
		      error: err
		    });
		  });
		}

		// production error handler
		// no stacktraces leaked to user
		this.app.use(function(err, req, res, next) {
		  res.status(err.status || 500);
		  res.render('error', {
		    message: err.message,
		    error: {}
		  });
		});
	}
开发者ID:ffanzhang,项目名称:CheweyComicsContinued,代码行数:66,代码来源:app.ts


示例6: function

export var init = function() {
  var app = express();
  // Compress content
  app.use(compression({
    threshold: 512
  }));

  // view engine setup
  app.set('views', path.join(__dirname, '../../views'));
  app.set('view engine', 'ejs');

  // uncomment after placing your favicon in /public
  //app.use(favicon(__dirname + '/public/favicon.ico'));
  app.use(morgan('dev', {
    stream:BunyanStream
  }));
  app.use(bodyParser.json({limit: '128mb'}));
  app.use(bodyParser.urlencoded({ extended: false }));
  app.use(cookieParser());
  app.use(express.static(path.join(__dirname, '../../public'), {maxAge: 0}));
  var mongoStore = new MongoStore({
      mongooseConnection: mongoose.connection,
      clear_interval: 3600
    });
  app.use(session({
    secret: options.sessionSecret,
    saveUninitialized:true,
    resave:true,
    store: mongoStore
  }));
  // Remember Me middleware
  app.use( function (req, res, next) {
    if ( req.method == 'POST' && req.url == '/login' ) {
      if ( req.body.rememberme ) {
        req.session.cookie.maxAge = 90*24*60*60*1000; // Rememeber 'me' for 90 days
      } else {
        req.session.cookie.expires = false;
      }
    }
    next();
  });

  PassportHandler.init(app);

  app.get('/', function(req,res) {
    if (req.isAuthenticated()) {
      res.redirect(options.baseUrl + '/view');
    } else {
      res.redirect(options.baseUrl + '/login');
    }
  });
  app.use('/view', ViewRoute);
  app.use('/service',ServiceRoute);

  ShareJSHandler.init(app, mongoStore);

  // catch 404 and forward to error handler
  app.use(function(req, res, next) {
    res.status(404);
    res.send("404 - "+req.path+" Not Found");
  });

  // error handlers

  // development error handler
  // will print stacktrace
  if (app.get('env') === 'development') {
    app.use(function(err, req, res, next) {
      res.status(err.status || 500);
      res.render('error', {
        message: err.message,
        error: err
      });
    });
  }

  // production error handler
  // no stacktraces leaked to user
  app.use(function(err, req, res, next) {
    res.status(err.status || 500);
    res.render('error', {
      message: err.message,
      error: {}
    });
  });

  return app;
};
开发者ID:MisterTea,项目名称:TidalWave,代码行数:88,代码来源:app-handler.ts



注:本文中的cookie-parser.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript cookie-session.default函数代码示例发布时间:2022-05-25
下一篇:
TypeScript cookie.parse函数代码示例发布时间:2022-05-25
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap