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

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

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

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



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

        constructor() {

            var session = require('cookie-session');
            var flash = require('flash');

            var app = express();

            app.use(express.static('build/client'));
            app.use('/server', express.static('server'));
            app.use('/client', express.static('client'));
            app.use('/bower_components', express.static('bower_components'));
            app.use('/node_modules', express.static('node_modules'));

            app.use(cookieParser());
            app.use(session({ secret: 'victoriasecret', resave: true, saveUninitialized: true }));
            app.use(passport.initialize());
            app.use(passport.session());
            app.use(bodyParser.json());
            app.use(bodyParser.urlencoded({ extended: true }));
            app.use('/api/auth', Auth());

            Database.init('test');
            Passport.init();

            app.listen(3000);
        }
开发者ID:zzeneg,项目名称:NodeSimpleWebsite,代码行数:26,代码来源:server.ts


示例3: initSession

function initSession() {
    const cookieParser = require('cookie-parser');
    app.use(cookieParser());

    const session = require('cookie-session');
    app.use(session({
        secret: config.web.sessionSecret
    }));
}
开发者ID:yegor-sytnyk,项目名称:contoso-express,代码行数:9,代码来源:server.ts


示例4: express

import {HomeUiText, IHomeUiText} from './src/resources/home/HomeUiText';
import {Job, IJob} from './src/shared/models/Job';
import {ExperienceItem, IExperienceItem} from './src/shared/models/ExperienceItem';
import {TechnologyType} from './src/shared/models/Enums'

var app: any = express();
var homeUiText = new HomeUiText();

app.use(express.static('./src/public'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.text({ type: 'text/html'}));
app.use(cookieParser('JrSecret7'));
app.use(cookieSession({
  name: 'session',
  keys: ['key1', 'key2']
}))

app.set('view engine', 'ejs');
app.set('views', './src/server/views/pages');

var Routes = {
	Home: 		'/',
	CV: 		'/cv/',
	LiveChat: 	'/livechat',
	Assessment: '/assessment',
	UnitTests: 	'/tests',
	Login: 		'/login',
	Logout: 	'/logout',
	Register:	'/register',
	ForgottenPassword: '/forgottenPassword'
开发者ID:JustinRickard,项目名称:CV,代码行数:31,代码来源:ServerApp.ts


示例5: require

var cookieSession = require('cookie-session')

import terminal = require('./service/terminal')

import { routes } from './conf/routes'
import { port } from './conf/config'

let app = express()
console.log(__dirname)
console.log(__dirname, path.join(__dirname, '../public'))
app.use(express.static(path.join(__dirname, '../public')))
app.use(bodyParser.json())
app.use(cookieParser())
app.use(cookieSession({
  	name: 'session',
	httpOnly: false,
  	keys: ['key1', 'key2']
}))

routes(app)

// app.listen(port)



var server = http.createServer(app)

server.listen(port)


console.log('listen port ' + port)
开发者ID:junjun16818,项目名称:webos,代码行数:31,代码来源:server.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
TypeScript cookies.get函数代码示例发布时间:2022-05-25
下一篇:
TypeScript cookie-parser.default函数代码示例发布时间: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