本文整理汇总了TypeScript中express-serve-static-core.Response类的典型用法代码示例。如果您正苦于以下问题:TypeScript Response类的具体用法?TypeScript Response怎么用?TypeScript Response使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Response类的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1:
app.use((err: any, req: Request, res: Response) => {
res.status(err['status'] || 500);
res.render('error', {
message: err['message'],
error: {}
});
});
示例2:
app.use(function(err: any, req: Request, res: Response, next: NextFunction) {
res.status(err.status || 500);
res.json({
message: err.message,
error: err
});
});
示例3:
app.use((err:any, req:Request, res:Response)=>
{
res.status(err.status || 500);
res.render('error', {
content: 'sub/error',
message: err.message,
error: {}
});
});
示例4:
const errorHandler = ( err: any, req: Request, res: Response, next: NextFunction ) => {
let stack: string = '';
if ( this.app.get( 'env' ) === 'development' ) {
this.debugErrors( err );
this.debugErrors( req.headers );
stack = err.stack;
}
res.status( err.status || 500 );
res.render( 'error', {
message: err.message,
status: err.status,
stack: stack
} );
};
示例5: function
app.get("/news", function(request: Request, response: Response) {
if(session.isAuthenticated(request)) {
database.getNews(session.getUser(request), response);
} else {
response.status(HttpStatus.FORBIDDEN).send("");
}
});
示例6: requireLogin
export function requireLogin(req: Request, res: Response, next) {
if (!req.session.authenticated) {
return res.status(401).json({ error: 'You must log in!' });
}
next();
};
示例7: IsLoggedInMiddleware
export function IsLoggedInMiddleware(req: Request, res: Response, next: Function) {
// if user is authenticated in the session, carry on
if (req.isAuthenticated() && req.user !== undefined) {
return next();
}
res.sendStatus(401);
};
示例8: parseInt
postRead: (req, res:Response, next) => {
if (req.erm.totalCount) {
let perPage = parseInt(req.query.perPage) || parseInt(process.env.DEFAULT_QUERY_LIMIT);
let page = req.query.page || 1;
res.set(paging.getHeaders(page, perPage, req.erm.totalCount));
}
next();
},
示例9:
cmdMap[`${CommandId.cs_startGame}`] = (param)=> {
if (db.game.isGameFinish(param.gameId)) {
res.send({isFinish: true})
}
else {
stagePanelHandle.startGame(param.gameId);
res.send({isFinish: false});
}
return ServerConst.SEND_ASYNC;
};
示例10:
cmdMap[`${CommandId.cs_saveGameRec}`] = (param) => {
if (this.gameInfo.isFinish) {
res.send(false);
}
else {
db.game.saveGameRecToPlayer(this.gameInfo, () => {
});
res.send(true);
}
return ServerConst.SEND_ASYNC;
};