當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript helmet.default函數代碼示例

本文整理匯總了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;未經允許,請勿轉載。