mirror of
https://github.com/monkeytypegame/monkeytype.git
synced 2024-11-11 01:15:49 +08:00
27 lines
578 B
JavaScript
27 lines
578 B
JavaScript
import cors from "cors";
|
|
import helmet from "helmet";
|
|
import addApiRoutes from "./api/routes";
|
|
import express, { urlencoded, json } from "express";
|
|
import contextMiddleware from "./middlewares/context";
|
|
import errorHandlingMiddleware from "./middlewares/error";
|
|
|
|
function buildApp() {
|
|
const app = express();
|
|
|
|
app.use(urlencoded({ extended: true }));
|
|
app.use(json());
|
|
app.use(cors());
|
|
app.use(helmet());
|
|
|
|
app.set("trust proxy", 1);
|
|
|
|
app.use(contextMiddleware);
|
|
|
|
addApiRoutes(app);
|
|
|
|
app.use(errorHandlingMiddleware);
|
|
|
|
return app;
|
|
}
|
|
|
|
export default buildApp();
|