diff --git a/services/admin-service/src/app.ts b/services/admin-service/src/app.ts index c59e5226..0fd3f79e 100644 --- a/services/admin-service/src/app.ts +++ b/services/admin-service/src/app.ts @@ -1,12 +1,16 @@ -import express, {Express} from 'express'; +import express, { Express } from "express"; +import swaggerUi from "swagger-ui-express"; +import swaggerFile from "../openapiDoc.json"; const app: Express = express(); -const port : number = parseInt(process.env.PORT || "5005"); +const port: number = parseInt(process.env.PORT || "5005"); -import router from './routes/index'; +import router from "./routes/index"; -app.use('/api/admin-service', router); +app.use("/api/admin-service", router); + +app.use("/docs", swaggerUi.serve, swaggerUi.setup(swaggerFile)); app.listen(port, () => { console.log(`⚡️[server]: Server is running at http://localhost:${port}`); diff --git a/services/admin-service/tsconfig.json b/services/admin-service/tsconfig.json index dd7087eb..25b30fd4 100644 --- a/services/admin-service/tsconfig.json +++ b/services/admin-service/tsconfig.json @@ -3,6 +3,7 @@ "target": "es2016", "module": "commonjs", "rootDir": "./src", + "resolveJsonModule": true, "outDir": "./dist", "esModuleInterop": true, "forceConsistentCasingInFileNames": true, diff --git a/services/matching-service/src/app.ts b/services/matching-service/src/app.ts index c8bb5b8a..995179bc 100644 --- a/services/matching-service/src/app.ts +++ b/services/matching-service/src/app.ts @@ -2,10 +2,16 @@ import express from "express"; import logger from "morgan"; import { Server } from "socket.io"; import matchingRoutes from "./routes/matchingRoutes"; -import { handleConnection, handleDisconnect, handleLooking } from "./controllers/matchingController"; +import { + handleConnection, + handleDisconnect, + handleLooking, +} from "./controllers/matchingController"; import { handleCancelLooking } from "./controllers/matchingController"; import { handleLeaveMatch } from "./controllers/matchingController"; import { handleSendMessage } from "./controllers/matchingController"; +import swaggerUi from "swagger-ui-express"; +import swaggerFile from "../swagger-output.json"; const app = express(); const port = process.env.PORT || 5002; @@ -13,6 +19,7 @@ const port = process.env.PORT || 5002; app.use(express.json()); app.use(logger("dev")); app.use("/api/matching-service", matchingRoutes); +app.use("/docs", swaggerUi.serve, swaggerUi.setup(swaggerFile)); const httpServer = require("http").createServer(app); export const io = new Server(httpServer); @@ -22,11 +29,17 @@ app.set("io", io); io.on("connection", (socket) => { let { userId, userMatchReq, timer } = handleConnection(socket); - socket.on("disconnect", handleDisconnect(socket, timer, userId, userMatchReq)); + socket.on( + "disconnect", + handleDisconnect(socket, timer, userId, userMatchReq) + ); - socket.on("lookingForMatch", handleLooking(socket, userId, userMatchReq, timer)); + socket.on( + "lookingForMatch", + handleLooking(socket, userId, userMatchReq, timer) + ); - socket.on("cancelLooking", handleCancelLooking(userId, timer, userMatchReq)) + socket.on("cancelLooking", handleCancelLooking(userId, timer, userMatchReq)); socket.on("leaveMatch", handleLeaveMatch(userId, socket)); @@ -35,11 +48,8 @@ io.on("connection", (socket) => { socket.on("matchFound", async (userId: string, matchedUserId: string) => { // todo - in the FE handle this }); - - }); httpServer.listen(port, () => { console.log(`Matching service is running at http://localhost:${port}`); }); - diff --git a/services/matching-service/tsconfig.json b/services/matching-service/tsconfig.json index dd7087eb..25b30fd4 100644 --- a/services/matching-service/tsconfig.json +++ b/services/matching-service/tsconfig.json @@ -3,6 +3,7 @@ "target": "es2016", "module": "commonjs", "rootDir": "./src", + "resolveJsonModule": true, "outDir": "./dist", "esModuleInterop": true, "forceConsistentCasingInFileNames": true,