本文整理匯總了TypeScript中@sample-stack/utils.logger.warn方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript logger.warn方法的具體用法?TypeScript logger.warn怎麽用?TypeScript logger.warn使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@sample-stack/utils.logger
的用法示例。
在下文中一共展示了logger.warn方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: callback
origin: (origin, callback) => {
if (corsWhitelist.indexOf(origin) !== -1) {
callback(null, true);
} else {
// TODO: only throw when in debug mode
logger.error('url (%s) is not in the whitelist', origin);
// callback(new Error('Not allowed by CORS'))
logger.warn('allowing all origins temporarily, you need to disable it.');
callback(null, true);
}
},
示例2: require
import { invert, isArray } from 'lodash';
import { GRAPHIQL_ROUTE } from '../ENDPOINTS';
import { logger } from '@sample-stack/utils';
var reqlib: any = require('app-root-path');
let persistCache = true;
let queryMap;
try {
queryMap = reqlib.require('@sample-stack/graphql-gql/extracted_queries.json');
} catch (err) {
logger.warn('extracted_queries.json file is unavailable, disabling persist queries');
}
export const persistedQueryMiddleware = (req, res, next) => {
if (queryMap) {
const invertedMap = invert(queryMap);
if (isArray(req.body)) {
req.body = req.body.map(body => {
const id = body['id'];
return {
query: invertedMap[id],
...body,
};
});
next();
} else {
if (!__DEV__ || (req.get('Referer') || '').indexOf(GRAPHIQL_ROUTE) < 0) {
res.status(500).send('Unknown GraphQL query has been received, rejecting...');