log to acces.log file

This commit is contained in:
Halit Aksoy 2022-05-05 23:56:02 +03:00
parent ff00dab464
commit de33ee5f92

View File

@ -5,6 +5,7 @@ import cors from "cors";
import { generateKey } from "./key_factory"; import { generateKey } from "./key_factory";
import { MatchMaker } from "./matcmaker"; import { MatchMaker } from "./matcmaker";
import { CommonMancalaGame, MancalaGame } from "mancala.js"; import { CommonMancalaGame, MancalaGame } from "mancala.js";
import fs from "fs";
import { import {
channel_game_move, channel_game_move,
channel_leave_game, channel_leave_game,
@ -20,6 +21,11 @@ import { GameMove } from "./models/GameMove";
const app = express(); const app = express();
app.use(cors()); app.use(cors());
app.use(
morgan("common", {
stream: fs.createWriteStream("./access.log", { flags: "a" }),
})
);
app.use(morgan("dev")); app.use(morgan("dev"));
const server = http.createServer(app); const server = http.createServer(app);
@ -80,7 +86,6 @@ rtmt.listenMessage(channel_game_move, (userKey: string, message: Object) => {
} }
} catch (err: any) { } catch (err: any) {
console.log(err); console.log(err);
deleteGame(game);
rtmt.sendMessage(game.player1Id, channel_on_game_crashed, err); rtmt.sendMessage(game.player1Id, channel_on_game_crashed, err);
rtmt.sendMessage(game.player2Id, channel_on_game_crashed, err); rtmt.sendMessage(game.player2Id, channel_on_game_crashed, err);
} }