Skip to content

Commit

Permalink
Standardise /docs for each service
Browse files Browse the repository at this point in the history
  • Loading branch information
gycgabriel committed Oct 15, 2023
1 parent 60a6a1b commit 9d38c45
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 11 deletions.
12 changes: 8 additions & 4 deletions services/admin-service/src/app.ts
Original file line number Diff line number Diff line change
@@ -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}`);
Expand Down
1 change: 1 addition & 0 deletions services/admin-service/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"target": "es2016",
"module": "commonjs",
"rootDir": "./src",
"resolveJsonModule": true,
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
Expand Down
24 changes: 17 additions & 7 deletions services/matching-service/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,24 @@ 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;

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);
Expand All @@ -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));

Expand All @@ -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}`);
});

1 change: 1 addition & 0 deletions services/matching-service/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"target": "es2016",
"module": "commonjs",
"rootDir": "./src",
"resolveJsonModule": true,
"outDir": "./dist",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
Expand Down

0 comments on commit 9d38c45

Please sign in to comment.