本文整理汇总了TypeScript中helmet.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: debug
// Configure localization
localization.configure({
locales: ['en-US', 'es'],
defaultLocale: 'en-US',
cookie: 'lang',
queryParameter: 'lang',
directory: `${ROOT}/src/locales`,
autoReload: isDev,
api: {
'__': 't', // now req.__ becomes req.t
'__n': 'tn' // and req.__n can be called as req.tn
}
});
// Setup Middlewares
app.use(helmet());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(cookieParser());
app.use(localization.init); // i18n init parses req for language headers, cookies, etc.
app.use(favicon(path.join(srcPath, 'public', 'favicon.ico')));
app.use(express.static(path.join(srcPath, 'public')));
if (isDev) {
app.use(morgan('dev'));
}
// Pass translation function to templates
app.use((req: CustomInterfaces.CustomRequest, res: CustomInterfaces.CustomResponse, next: Function) : void => {
debug('Passing translation functions to templates');
env.addGlobal('translate', req.t);
开发者ID:melxx001,项目名称:simple-nodejs-typescript-starter,代码行数:31,代码来源:server.ts
示例2: session
export var cookie = session({
store: new RedisStore({ client: redis }),
secret: config.cookie.default.secret,
duration: config.cookie.default.duration,
secure: config.isProduction,
httpOnly: true,
resave: true,
saveUninitialized: true
});
//cookieName: config.cookie.default.name,
export var csrfProtection = csrf({ key: config.cookie.default.name })
app.set('trust proxy', true);
app.use(helmet()); // will include 6 of the 9, leaving out contentSecurityPolicy, hpkp, and noCache.
app.use(compression({ memLevel: 9, level: 9 }));
// view engine setup
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
// Add the request logger before anything else so that it can
// accurately log requests.
app.use(logging.requestLogger);
// uncomment after placing your favicon in /public
app.use(favicon(__dirname + '/public/favicon.ico'));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(cookie);
开发者ID:zaksie,项目名称:gotouch,代码行数:31,代码来源:app.ts
示例3: configExpressServer
private configExpressServer() {
this.app.use(helmet({
noCache: true,
referrerPolicy: true
}));
// todo CHANGE origin in production mode based on your requirement
this.app.use(cors({
origin: [/https?:\/\/*:*/],
methods: ['GET', 'POST', 'PUT', 'DELETE'],
allowedHeaders: ['X-Requested-With', 'Content-Type', 'Content-Length', 'X-Auth-Token', 'X-Auth-User'],
exposedHeaders: ['Content-Type', 'Content-Length', 'X-Auth-Token']
}));
this.app.use(loggerMiddleware);
this.app.use(morgan(this.setting.env == 'development' ? 'dev' : 'combined'));
this.app.use(bodyParser.urlencoded({limit: '50mb', extended: false}));
this.app.use(bodyParser.json({limit: '50mb'}));
// closing connection after sending response ???
this.app.use((req: IExtRequest, res: express.Response, next: express.NextFunction) => {
res.set('Connection', 'Close');
next();
});
this.app.enable('trust proxy');
this.app.disable('case sensitive routing');
this.app.disable('strict routing');
this.app.disable('x-powered-by');
this.app.disable('etag');
}
开发者ID:VestaRayanAfzar,项目名称:express-api-template,代码行数:28,代码来源:ServerApp.ts
示例4: init
static init(application:Object, exp:Object):void {
let _clientFiles = (process.env.NODE_ENV === 'production') ? '/client/dist/' : '/client/dev/';
let _root = process.cwd();
application.use(exp.static(_root));
application.use(exp.static(_root + _clientFiles));
application.use(bodyParser.json());
application.use(morgan('dev'));
application.use(contentLength.validateMax({max: 999}));
application.use(helmet());
}
开发者ID:ericmdantas,项目名称:Gen-App,代码行数:11,代码来源:routes.conf.ts
示例5: require
}
// Dev-only middleware
const webpack = require('webpack')
const compiler = webpack(require('../config/webpack.config.js'))
const hot = require('webpack-hot-middleware')
const devserver = require('webpack-dev-middleware')
server.use(devserver(compiler, {
publicPath: '/',
stats: { colors: true },
historyApiFallback: true,
}))
server.use(hot(compiler))
} else {
// Production-only middleware
const helmet = require('helmet')
server.use(helmet())
}
server.use(renderMiddleware(app))
const port = process.env.PORT || 8000
server.listen(port, () => {
console.log(`Application started on port ${port}`)
})
开发者ID:chrisdevereux,项目名称:ts-react,代码行数:30,代码来源:server.ts
注:本文中的helmet.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论