Seperate servers

This commit is contained in:
Owen Schwartz 2024-12-07 22:07:13 -05:00
parent ef7723561e
commit 37f51bec9b
No known key found for this signature in database
GPG key ID: 8271FDFFD9E0CCBD
8 changed files with 214 additions and 189 deletions

32
server/internalServer.ts Normal file
View file

@ -0,0 +1,32 @@
import express from "express";
import helmet from "helmet";
import cors from "cors";
import cookieParser from "cookie-parser";
import config from "@server/config";
import logger from "@server/logger";
import { errorHandlerMiddleware, notFoundMiddleware } from "@server/middlewares";
import internal from "@server/routers/internal";
const internalPort = config.server.internal_port;
export function createInternalServer() {
const internalServer = express();
internalServer.use(helmet());
internalServer.use(cors());
internalServer.use(cookieParser());
internalServer.use(express.json());
const prefix = `/api/v1`;
internalServer.use(prefix, internal);
internalServer.use(notFoundMiddleware);
internalServer.use(errorHandlerMiddleware);
internalServer.listen(internalPort, (err?: any) => {
if (err) throw err;
logger.info(`Internal server is running on http://localhost:${internalPort}`);
});
return internalServer;
}