当前位置: 首页>>代码示例>>TypeScript>>正文


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

本文整理汇总了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;未经允许,请勿转载。