本文整理汇总了TypeScript中errorhandler.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1:
import errorHandler from "errorhandler";
import app from "./app";
import logger from "./util/logger";
if (app.get("env") === "development") {
app.use(errorHandler());
}
const server = app.listen(app.get("port"), () => {
logger.info(
" App is running at http://localhost:%d in %s mode",
app.get("port"),
app.get("env"),
);
logger.info(" Press CTRL-C to stop\n");
});
export default server;
开发者ID:klakovsky,项目名称:blank-nt-post,代码行数:18,代码来源:server.ts
示例2: configure
function configure(server: express.Application): void {
server.use(errorHandler());
configuration.http_address = "0.0.0.0";
configuration.http_port = process.env.PORT;
configuration.databaseName = process.env.MONGODB_URL;
configuration.githubApplication.scope = ["user", "public_repo"];
configuration.githubApplication.dnsName = process.env.HTTP_ADDRESS;
}
开发者ID:ciuliot,项目名称:github-tracker,代码行数:10,代码来源:heroku.ts
示例3: configure
function configure(server: express.Application): void {
server.use(errorHandler());
configuration.http_address = process.env.OPENSHIFT_NODEJS_IP;
configuration.http_port = process.env.OPENSHIFT_NODEJS_PORT;
configuration.databaseName = util.format("%sgittrack", process.env.OPENSHIFT_MONGODB_DB_URL);
configuration.githubApplication.scope = ["user", "public_repo"];
configuration.githubApplication.dnsName = process.env.OPENSHIFT_APP_DNS;
}
开发者ID:ciuliot,项目名称:github-tracker,代码行数:10,代码来源:openshift.ts
示例4: config
private config() {
this.app.use(bodyParser.json())
this.app.use(bodyParser.urlencoded({ extended: true }))
this.app.use(cors())
this.app.use(compression())
this.app.use((err: any, req, res, next) => {
err.status = 404
next(err)
})
this.app.use(errorHandler())
}
开发者ID:magic8bot,项目名称:magic8bot,代码行数:14,代码来源:server.ts
示例5: usePlugins
private usePlugins(): void {
this.app.use(morgan(":method :url :status - :response-time ms"));
if (config.get("isDev")) {
this.app.use(errorhandler());
}
this.app.use(cors());
this.app.use(bodyParser.urlencoded({extended: true}));
this.app.use(bodyParser.json());
this.app.use(expressValidator());
this.app.use(compression());
if(config.get("isDev")) {
this.app.use(express.static(path.join(__dirname, "public")));
}else{
this.app.use(express.static(path.join(__dirname, "public"), {maxAge: "10h"}));
}
this.app.use(auth());
this.app.use(favicon(path.join(__dirname, "/public/favicon.ico")));
logs.info("App configured");
}
开发者ID:ZulusK,项目名称:Budgetarium,代码行数:19,代码来源:App.ts
示例6: function
//cookie: { secure: true } //?invalid csrf token?
}));
var sessionCheck = function(req, res, next) {
if (req.session.login === true) {
next();
} else {
res.redirect('/login');
}
};
app.use(express.static(__dirname + '/public'));
app.use('/exam_images', express.static(c.image_dir));
app.use('/figures', express.static(c.figure_dir));
// development only
if ('development' == app.get('env')) {
app.use(errorhandler());
}
app.get("/", sessionCheck, routes.index);
app.post("/", index_post.index);
app.get("/login", login.index);
app.post('/login', login_post.index);
app.get("/logout", logout.index);
app.get("/result/:exam_id", result.index);
app.get("/images", images.index);
app.get("/image_folder", image_folder.index);
app.get("/search", search.index);
app.post("/search", search_post.index);
process.on('uncaughtException', function(err) {
console.log(err);
开发者ID:KoichiHirahata,项目名称:FindingsSite,代码行数:31,代码来源:server.ts
示例7: BmaApi
createServersAndListen: async (name:string, server:Server, interfaces:NetworkInterface[], httpLogs:boolean, logger:any, staticPath:string|null, routingCallback:any, listenWebSocket:any, enableFileUpload:boolean = false) => {
const app = express();
// all environments
if (httpLogs) {
app.use(morgan('\x1b[90m:remote-addr - :method :url HTTP/:http-version :status :res[content-length] - :response-time ms\x1b[0m', {
stream: {
write: function(message:string){
message && logger && logger.trace(message.replace(/\n$/,''));
}
}
}));
}
// DDOS protection
const whitelist = interfaces.map(i => i.ip);
if (whitelist.indexOf('127.0.0.1') === -1) {
whitelist.push('127.0.0.1');
}
const ddosConf = server.conf.dos || {};
ddosConf.silentStart = true
ddosConf.whitelist = _.uniq((ddosConf.whitelist || []).concat(whitelist));
const ddosInstance = new ddos(ddosConf);
app.use(ddosInstance.express);
// CORS for **any** HTTP request
app.use(cors());
if (enableFileUpload) {
// File upload for backup API
app.use(fileUpload());
}
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(bodyParser.json({ limit: '10mb' }));
// development only
if (app.get('env') == 'development') {
app.use(errorhandler());
}
const handleRequest = (method:any, uri:string, promiseFunc:(...args:any[])=>Promise<any>, theLimiter:any) => {
const limiter = theLimiter || BMALimitation.limitAsUnlimited();
method(uri, async function(req:any, res:any) {
res.set('Access-Control-Allow-Origin', '*');
res.type('application/json');
try {
if (!limiter.canAnswerNow()) {
throw BMAConstants.ERRORS.HTTP_LIMITATION;
}
limiter.processRequest();
let result = await promiseFunc(req);
// HTTP answer
res.status(200).send(JSON.stringify(result, null, " "));
} catch (e) {
let error = getResultingError(e, logger);
// HTTP error
res.status(error.httpCode).send(JSON.stringify(error.uerr, null, " "));
}
});
};
const handleFileRequest = (method:any, uri:string, promiseFunc:(...args:any[])=>Promise<any>, theLimiter:any) => {
const limiter = theLimiter || BMALimitation.limitAsUnlimited();
method(uri, async function(req:any, res:any) {
res.set('Access-Control-Allow-Origin', '*');
try {
if (!limiter.canAnswerNow()) {
throw BMAConstants.ERRORS.HTTP_LIMITATION;
}
limiter.processRequest();
let fileStream:any = await promiseFunc(req);
// HTTP answer
fileStream.pipe(res);
} catch (e) {
let error = getResultingError(e, logger);
// HTTP error
res.status(error.httpCode).send(JSON.stringify(error.uerr, null, " "));
throw e
}
});
};
routingCallback(app, {
httpGET: (uri:string, promiseFunc:(...args:any[])=>Promise<any>, limiter:any) => handleRequest(app.get.bind(app), uri, promiseFunc, limiter),
httpPOST: (uri:string, promiseFunc:(...args:any[])=>Promise<any>, limiter:any) => handleRequest(app.post.bind(app), uri, promiseFunc, limiter),
httpGETFile: (uri:string, promiseFunc:(...args:any[])=>Promise<any>, limiter:any) => handleFileRequest(app.get.bind(app), uri, promiseFunc, limiter)
});
if (staticPath) {
app.use(express.static(staticPath));
}
const httpServers = interfaces.map(() => {
const httpServer = http.createServer(app);
const sockets:any = {};
let nextSocketId = 0;
//.........这里部分代码省略.........
开发者ID:Kalmac,项目名称:duniter,代码行数:101,代码来源:network.ts
示例8: function
// Catch All
app.use(express.static(__dirname + '/public'));
app.use(function (req: express.Request, res: express.Response, next) {
res.status(404);
if (req.accepts('html')) {
res.render('_shared/404');
return;
}
if (req.accepts('json')) {
res.send({ error: 'Not found' });
return;
}
res.type('txt').send('Not found');
});
app.use(errorhandler({ dumpExceptions: true, showStack: true }));
// Start the server
var httpServer = http.createServer(app);
io = io.listen(httpServer);
io.set('log level', 1);
httpServer.listen(1337); // use 0 to assign random port
httpServer.on('listening', function () {
console.log('listening on port: ', httpServer.address().port);
});
// var httpsServer = https.createServer(options, app);
// httpsServer.listen(443);
开发者ID:irysius,项目名称:NodeSiteTemplate,代码行数:30,代码来源:app.ts
示例9: configure
function configure(server: express.Application) {
server.use(errorHandler({ dumpExceptions: true, showStack: true }));
}
开发者ID:ciuliot,项目名称:github-tracker,代码行数:3,代码来源:development.ts
注:本文中的errorhandler.default函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论