本文整理汇总了TypeScript中errorhandler类的典型用法代码示例。如果您正苦于以下问题:TypeScript errorhandler类的具体用法?TypeScript errorhandler怎么用?TypeScript errorhandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了errorhandler类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: error
export default function error(): any {
if (process.env.NODE_ENV !== "development") {
return defaultRoutes.error500;
} else {
return errorhandler();
}
}
开发者ID:nicholas-robson,项目名称:dkydev_webapp,代码行数:7,代码来源:error.ts
示例2: config
private config() {
const app = this.app;
const port = this.normalizePort(process.env.PORT || this.port);
// set server port
app.set('port', port);
// view engine setup
app.set('views', path.join(__dirname, '/views'));
app.set('view engine', 'jade');
// uncomment after placing your favicon in /public
//app.use(favicon(path.join(__dirname, 'public', 'favicon.ico')));
app.use(logger(this.logLevel));
app.use(bodyParser.json());
app.use(bodyParser.urlencoded({
extended: false
}));
app.use(cookieParser());
app.use(cors());
app.use(express.static(path.resolve(__dirname + '/client/statics')));
if (process.env.NODE_ENV === 'development') {
// only use in development
app.use(errorhandler({
log: (err, str, req) => this.errorNotification(err, str, req)
}));
}
}
开发者ID:thehachez,项目名称:maduk,代码行数:27,代码来源:app.ts
示例3: config
config(router: Express.Router) {
var app = Express();
app.use((req, res, next) => {
console.log("middleware function called");
next();
})
app.use(BodyParser.urlencoded({ extended: false }));
app.use(BodyParser.json());
app.use(CookieParser());
app.use(router);
app.use(morgan("combined", { "stream": { write: (message) => { Logger.info(message) } } }));
if (process.env.NODE_ENV === 'dev') {
app.use(errorhandler());
}
return app;
}
开发者ID:frontians-web,项目名称:base-middlewares,代码行数:21,代码来源:Middlewares.ts
示例4: express
sampler.pushSome(task);
} else {
nextTask = task;
}
}
return {
task: sampler ? sampler[0] : nextTask,
numCompleted: _.size(completedTasks),
numTotal,
}
}
const app = express();
app.use(bodyParser.urlencoded({extended: false}));
app.use(errorhandler());
app.use(express.static(path.resolve(staticDir)));
app.get('/', utils.wrapPromise(async (req, res) => {
const nextTask = await getNextTask();
if (nextTask.task) {
console.log(nextTask.task);
const html = await renderTemplate(nextTask);
res.send(html);
} else {
res.send('DONE');
process.exit(0);
}
}));
app.post('/submit', utils.wrapPromise(async (req, res) => {
开发者ID:danvk,项目名称:localturk,代码行数:31,代码来源:localturk.ts
示例5: function
export default function(app) {
let env = app.get('env');
app.set('views', config.root + '/server/views');
app.set('view engine', 'jade');
app.use(compression());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(methodOverride());
app.use(cookieParser());
app.use(passport.initialize());
app.set('appPath', path.join(config.root, 'client'));
if ('production' === env) {
app.use(favicon(path.join(config.root, 'client', 'favicon.ico')));
app.use(express.static(app.get('appPath')));
app.use(morgan('dev'));
}
if ('development' === env) {
app.use(require('connect-livereload')());
}
if ('development' === env || 'test' === env) {
app.use(express.static(path.join(config.root, '.tmp')));
app.use(express.static(app.get('appPath')));
app.use(morgan('dev'));
app.use(errorHandler()); // Error handler - has to be last
}
}
开发者ID:Jeremy-Doucet,项目名称:Blog-Example-Typescript,代码行数:31,代码来源:express.ts
示例6: newInstance
newInstance(config: IConfig, env: string): express.Express {
var app = express();
app.set("views", config.root + "/server/views");
app.set("view engine", "html");
app.use(compression());
app.use(bodyParser.urlencoded({ extended: false }));
app.use(bodyParser.json());
app.use(methodOverride());
app.use(cookieParser());
// Persist sessions with mongoStore / sequelizeStore
// We need to enable sessions for passport-twitter because it"s an
// oauth 1.0 strategy, and Lusca depends on sessions
/*app.use(session({
secret: config.secrets.session,
saveUninitialized: true,
resave: false,
store: new mongoStore({
mongooseConnection: mongoose.connection,
db: "opcrates-bot-server"
})
}));*/
app.set("appPath", path.join(config.root, "client"));
app.use(morgan("dev"));
app.use(express.static(app.get("appPath")));
if ("development" === env || "test" === env) {
app.use(express.static(path.join(config.root, ".tmp")));
app.use(errorHandler()); // Error handler - has to be last
}
return app;
}
开发者ID:Tmeister,项目名称:generator-typescript-express,代码行数:35,代码来源:applicationFactory.ts
示例7: config
/**
* Configure application
*
* @class Server
* @method config
*/
public config() {
//add static paths
this.app.use(express.static(path.join(__dirname, "public")));
//configure pug
this.app.set("views", path.join(__dirname, "views"));
this.app.set("view engine", "pug");
//mount logger
this.app.use(logger("dev"));
//mount json form parser
this.app.use(bodyParser.json());
//mount query string parser
this.app.use(bodyParser.urlencoded({
extended: true
}));
//mount cookie parser middleware
this.app.use(cookieParser("SECRET_GOES_HERE"));
// catch 404 and forward to error handler
this.app.use(function(err: any, req: express.Request, res: express.Response, next: express.NextFunction) {
err.status = 404;
next(err);
});
//error handling
this.app.use(errorHandler());
}
开发者ID:HaoranYi,项目名称:gitProj,代码行数:37,代码来源:server.ts
示例8: errorHandler
app.use((err: any, req: express.Request, res: express.Response, next: express.NextFunction) => {
if (app.get('env') === 'development') {
let errHandler = errorHandler();
errHandler(err, req, res, next);
} else {
res.send(500);
}
});
开发者ID:tarurar,项目名称:github-maturity,代码行数:8,代码来源:index.ts
示例9: Error
export let init=()=>{
if(SERVER_CONFIG.env==DEV){
app.use(errorHandler({log:errorNotification}));
}
init=()=>{
throw new Error('timeout-parser.ts: Timeout parser has been initialized.');
}
};
开发者ID:guoyu07,项目名称:react-node-cms,代码行数:8,代码来源:error-parser.ts
示例10: function
export default function(app) {
let rootPath = path.normalize(`${__dirname}/../..`);
let clientPath: string = path.join(rootPath, 'client');
app.use(express.static(clientPath));
app.set('clientPath', clientPath);
app.use(bodyParser.urlencoded({ extended: true }));
app.use(bodyParser.json());
app.use(methodOverride());
// let env = app.get('env');
let env = process.env.NODE_ENV || 'development';
if (env === 'development') {
app.use(errorHandler());
}
}
开发者ID:AlanJui,项目名称:jspm-md,代码行数:19,代码来源:express.ts
注:本文中的errorhandler类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论