本文整理汇总了TypeScript中express-serve-static-core.Response.sendStatus方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Response.sendStatus方法的具体用法?TypeScript Response.sendStatus怎么用?TypeScript Response.sendStatus使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类express-serve-static-core.Response
的用法示例。
在下文中一共展示了Response.sendStatus方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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);
};
示例2: ScParam
panelRouter.post(`/act/:cmdId`, (req:Request, res:Response) => {
if (!req.body) return res.sendStatus(400);
var cmdId = req.params.cmdId;
var param = req.body;
console.log(`/act/${cmdId}`);
var cmdMap:any = {};
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;
};
cmdMap[`${CommandId.cs_restartGame}`] = (param)=> {
db.game.restartGame(param.gameId);
};
cmdMap[`${CommandId.cs_fadeInRankPanel}`] = (param)=> {
var activityId = param.activityId;
var playerIdArr = param.playerIdArr;
this.io.emit(`${CommandId.fadeInRankPanel}`,
ScParam({playerDocArr: db.player.getPlayerRank(playerIdArr)}));
// return ServerConst.SEND_ASYNC;
// db.game.restartGame(param.gameId);
};
cmdMap[`${CommandId.cs_fadeOutRankPanel}`] = (param)=> {
this.io.emit(`${CommandId.fadeOutRankPanel}`);
};
cmdMap[`${CommandId.cs_fadeInCountDown}`] = (param)=> {
this.io.emit(`${CommandId.fadeInCountDown}`, param);
};
cmdMap[`${CommandId.cs_fadeOutCountDown}`] = (param)=> {
this.io.emit(`${CommandId.fadeOutCountDown}`);
};
cmdMap[`${CommandId.cs_fadeInActivityPanel}`] = (param)=> {
db.game.syncDataMap(()=> {
var gameIdArr = param.gameIdArr;
var gameDocArr = db.game.getDocArr(gameIdArr);
console.log('cs_fadeInActivityPanel', gameIdArr, gameDocArr);
for (var gameDoc of gameDocArr) {
console.log('gameDoc', gameDoc.id);
gameDoc.playerDocArr = [];
for (var playerId of gameDoc.playerIdArr) {
gameDoc.playerDocArr.push(db.player.dataMap[playerId]);
}
}
this.io.emit(`${CommandId.fadeInActivityPanel}`,
ScParam({gameDocArr: gameDocArr}));
})
};
cmdMap[`${CommandId.cs_fadeOutActivityPanel}`] = (param)=> {
this.io.emit(`${CommandId.fadeOutActivityPanel}`);
};
cmdMap[`${CommandId.cs_fadeInActivityExGame}`] = (param)=> {
var gameIdArr = param.gameIdArr;
var activityId = param.activityId;
var roundId = param.roundId;
var playerIdArr = param.playerIdArr;
var gameDocArr = mapToArr(db.game.dataMap);
var roundGameDocArr = [];
for (var gameDoc of gameDocArr) {
if (Math.floor(gameDoc.id / 1000) == roundId) {
roundGameDocArr.push(gameDoc.id);
}
}
var maxGameId = arrMaxElem(roundGameDocArr);
// var gameDocArr = db.game.getDocArr(gameIdArr);
// var playerIdArr:any = [];
// for (var gameDoc of gameDocArr) {
// playerIdArr = playerIdArr.concat(gameDoc.playerIdArr);
// }
// playerIdArr = playerIdArr.sort().filter(arrUniqueFilter);
console.log('ex game playerDoc Arr:', playerIdArr, 'maxGameId', maxGameId);
//组合球员
var t1 = playerIdArr.slice(0, 4);
var t2 = playerIdArr.slice(4, 8);
var t3 = playerIdArr.slice(8, 12);
var t4 = playerIdArr.slice(12, 16);
var lastTeamArr = [t1, t2, t3, t4];
//
//排序
playerIdArr = db.player.getPlayerIdArrRank(playerIdArr);
function minAbsScoreTeam(combineTeamArr, sameLimit = 3):any {
console.log('combine team', combineTeamArr.length, lastTeamArr);
var matchTeam = {t1: null, t2: null};
var minAbsScore = -1;
//.........这里部分代码省略.........
示例3: ScParam
panelRouter.post(`/stage/:cmdId`, (req:Request, res:Response) => {
if (!req.body) return res.sendStatus(400);
var cmdId = req.params.cmdId;
var param = req.body;
console.log(`/stage/${cmdId}`);
var cmdMap:any = {};
cmdMap[`${CommandId.cs_minLeftScore}`] = () => {
this.gameInfo.minLeftScore();
this.io.emit(`${CommandId.updateLeftScore}`, ScParam({leftScore: this.gameInfo.leftScore}));
screenPanelHanle.io.emit(`${CommandId.updateLeftScore}`, ScParam({leftScore: this.gameInfo.leftScore}));
};
cmdMap[`${CommandId.cs_minRightScore}`] = () => {
this.gameInfo.minRightScore();
this.io.emit(`${CommandId.updateRightScore}`, ScParam({rightScore: this.gameInfo.rightScore}));
screenPanelHanle.io.emit(`${CommandId.updateRightScore}`, ScParam({rightScore: this.gameInfo.rightScore}));
};
cmdMap[`${CommandId.cs_addLeftScore}`] = () => {
var straight = this.gameInfo.addLeftScore();
if (straight == 3) {
console.log("straight score 3");
this.io.emit(`${CommandId.straightScore3}`, ScParam({team: ViewEvent.STRAIGHT3_LEFT}));
}
if (straight == 5) {
}
this.io.emit(`${CommandId.updateLeftScore}`, ScParam({leftScore: this.gameInfo.leftScore}));
screenPanelHanle.io.emit(`${CommandId.updateLeftScore}`, ScParam({leftScore: this.gameInfo.leftScore}));
};
cmdMap[`${CommandId.cs_addRightScore}`] = () => {
var straight = this.gameInfo.addRightScore();
if (straight == 3) {
console.log("straight score 3 right");
this.io.emit(`${CommandId.straightScore3}`, ScParam({team: ViewEvent.STRAIGHT3_RIGHT}));
}
if (straight == 5) {
}
this.io.emit(`${CommandId.updateRightScore}`, ScParam({rightScore: this.gameInfo.rightScore}));
screenPanelHanle.io.emit(`${CommandId.updateRightScore}`, ScParam({rightScore: this.gameInfo.rightScore}));
};
cmdMap[`${CommandId.cs_unLimitScore}`] = (param) => {
this.gameInfo.unLimitScore = param.unLimitScore;
this.io.emit(`${CommandId.unLimitScore}`, ScParam({unLimitScore: this.gameInfo.unLimitScore}));
};
//// foul
cmdMap[`${CommandId.cs_addRightFoul}`] = () => {
var rightFoul:number = this.gameInfo.addRightFoul();
screenPanelHanle.io.emit(`${CommandId.updateRightFoul}`, ScParam({rightFoul: rightFoul}));
};
cmdMap[`${CommandId.cs_minRightFoul}`] = () => {
var rightFoul:number = this.gameInfo.minRightFoul();
screenPanelHanle.io.emit(`${CommandId.updateRightFoul}`, ScParam({rightFoul: rightFoul}));
};
cmdMap[`${CommandId.cs_addLeftFoul}`] = () => {
var leftFoul:number = this.gameInfo.addLeftFoul();
screenPanelHanle.io.emit(`${CommandId.updateLeftFoul}`, ScParam({leftFoul: leftFoul}));
};
cmdMap[`${CommandId.cs_minLeftFoul}`] = () => {
var leftFoul:number = this.gameInfo.minLeftFoul();
screenPanelHanle.io.emit(`${CommandId.updateLeftFoul}`, ScParam({leftFoul: leftFoul}));
};
// cmdMap[`${CommandId.cs_fadeInComingActivity}`] = () => {
// screenPanelHanle.io.emit(`${CommandId.fadeInComingActivity}`);
// };
////////////////////screen only /////////////////////
cmdMap[`${CommandId.cs_toggleTimer}`] = (param) => {
if (param) {
console.log('cs_toggleTimer', param);
this.gameInfo.toggleTimer(param.state);
this.io.emit(`${CommandId.toggleTimer}`, ScParam(param));
}
else {
this.gameInfo.toggleTimer();
this.io.emit(`${CommandId.toggleTimer}`);
}
};
cmdMap[`${CommandId.cs_resetTimer}`] = () => {
this.gameInfo.resetTimer();
this.io.emit(`${CommandId.resetTimer}`);
};
cmdMap[`${CommandId.cs_setGameTh}`] = (param) => {
this.gameInfo.gameTh = param.gameTh;
this.io.emit(`${CommandId.setGameTh}`, ScParam(param));
};
cmdMap[`${CommandId.cs_updatePlayer}`] = (param) => {
var playerId = param.playerId;
var playerIdx = param.idx;
if (this.gameInfo.gameState == GameInfo.GAME_STATE_ING) {
param.playerDoc = db.player.dataMap[playerId];
this.gameInfo.setPlayerInfoByIdx(playerIdx, db.player.getPlayerInfoById(playerId));
//.........这里部分代码省略.........