本文整理汇总了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();
});
}
};
示例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);
}
示例3: initSession
function initSession() {
const cookieParser = require('cookie-parser');
app.use(cookieParser());
const session = require('cookie-session');
app.use(session({
secret: config.web.sessionSecret
}));
}
示例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'
示例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)