Skip to content

Instantly share code, notes, and snippets.

@morintd

morintd/app.ts Secret

Created March 14, 2024 17:48
Show Gist options
  • Save morintd/a515410c627067ba659f74084fad9554 to your computer and use it in GitHub Desktop.
Save morintd/a515410c627067ba659f74084fad9554 to your computer and use it in GitHub Desktop.
import { Request, Response } from "express";
import cookieParser from "cookie-parser";
import express from "express";
import { TicTacToeController } from "../tic-tac-toe/tic-tac-toe.controller";
import { TicTacToeModule } from "../tic-tac-toe/tic-tac-toe.module";
import { BoardService } from "../tic-tac-toe/board.repository";
function createApp() {
const app = express();
app.use(express.json());
app.use(express.urlencoded({ extended: false }));
app.use(cookieParser());
const service = new BoardService();
const module = new TicTacToeModule(new TicTacToeController(service));
module.configure(app);
// eslint-disable-next-line @typescript-eslint/no-explicit-any
app.use((error: any, _req: Request, res: Response) => {
console.log({ error, _req, res });
return res.status(error.status || 500).json(error.body);
});
return app;
}
export default createApp;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment