Skip to content

Commit

Permalink
Merge pull request #89 from nicolelim02/chore/refactor
Browse files Browse the repository at this point in the history
Shift code into src
  • Loading branch information
guanquann authored Oct 29, 2024
2 parents 9aeead1 + 7df047d commit be6e597
Show file tree
Hide file tree
Showing 44 changed files with 35 additions and 33 deletions.
4 changes: 2 additions & 2 deletions backend/collab-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"main": "server.ts",
"type": "module",
"scripts": {
"start": "tsx server.ts",
"dev": "tsx watch server.ts",
"start": "tsx src/server.ts",
"dev": "tsx watch src/server.ts",
"test": "cross-env NODE_ENV=test && jest",
"test:watch": "cross-env NODE_ENV=test && jest --watch",
"lint": "eslint ."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import yaml from "yaml";
import swaggerUi from "swagger-ui-express";
import cors from "cors";

import collabRoutes from "./src/routes/collabRoutes.ts";
import collabRoutes from "./routes/collabRoutes.ts";

dotenv.config();

Expand Down
File renamed without changes.
4 changes: 2 additions & 2 deletions backend/collab-service/src/handlers/websocketHandler.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Socket } from "socket.io";
import { io } from "../../server";
import redisClient from "../../config/redis";
import { io } from "../server";
import redisClient from "../config/redis";

enum CollabEvents {
// Receive
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import http from "http";
import app, { allowedOrigins } from "./app.ts";
import { handleWebsocketCollabEvents } from "./src/handlers/websocketHandler";
import { handleWebsocketCollabEvents } from "./handlers/websocketHandler.ts";
import { Server } from "socket.io";
import { connectRedis } from "./config/redis.ts";

Expand Down
4 changes: 2 additions & 2 deletions backend/matching-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
"main": "server.ts",
"type": "module",
"scripts": {
"start": "tsx server.ts",
"dev": "tsx watch server.ts",
"start": "tsx src/server.ts",
"dev": "tsx watch src/server.ts",
"test": "cross-env NODE_ENV=test && jest",
"test:watch": "cross-env NODE_ENV=test && jest --watch",
"lint": "eslint ."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import yaml from "yaml";
import fs from "fs";
import cors from "cors";

import matchingRoutes from "./src/routes/matchingRoutes.ts";
import matchingRoutes from "./routes/matchingRoutes.ts";

dotenv.config();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import amqplib, { Connection } from "amqplib";
import dotenv from "dotenv";
import { matchUsers } from "../src/utils/mq_utils";
import { MatchRequestItem } from "../src/handlers/matchHandler";
import { Complexities, Categories, Languages } from "../src/utils/constants";
import { matchUsers } from "../utils/mq_utils";
import { MatchRequestItem } from "../handlers/matchHandler";
import { Complexities, Categories, Languages } from "../utils/constants";

dotenv.config();

Expand Down
2 changes: 1 addition & 1 deletion backend/matching-service/src/handlers/matchHandler.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { v4 as uuidv4 } from "uuid";
import { sendToQueue } from "../../config/rabbitmq";
import { sendToQueue } from "../config/rabbitmq";
import { sendMatchFound } from "./websocketHandler";

interface Match {
Expand Down
2 changes: 1 addition & 1 deletion backend/matching-service/src/handlers/websocketHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
getMatchByUid,
getMatchById,
} from "./matchHandler";
import { io } from "../../server";
import { io } from "../server";
import { v4 as uuidv4 } from "uuid";
import { questionService } from "../utils/api";

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import http from "http";
import app, { allowedOrigins } from "./app.ts";
import { handleWebsocketMatchEvents } from "./src/handlers/websocketHandler.ts";
import { handleWebsocketMatchEvents } from "./handlers/websocketHandler.ts";
import { Server } from "socket.io";
import { connectToRabbitMq } from "./config/rabbitmq.ts";

Expand Down
2 changes: 1 addition & 1 deletion backend/matching-service/src/utils/mq_utils.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { getPendingRequests } from "../../config/rabbitmq";
import { getPendingRequests } from "../config/rabbitmq";
import { createMatch, MatchRequestItem } from "../handlers/matchHandler";
import { isActiveRequest, isUserConnected } from "../handlers/websocketHandler";

Expand Down
4 changes: 2 additions & 2 deletions backend/question-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"type": "module",
"scripts": {
"seed": "tsx src/scripts/seed.ts",
"start": "tsx server.ts",
"dev": "tsx watch server.ts",
"start": "tsx src/server.ts",
"dev": "tsx watch src/server.ts",
"test": "cross-env NODE_ENV=test && jest",
"test:watch": "cross-env NODE_ENV=test && jest --watch",
"lint": "eslint ."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import yaml from "yaml";
import fs from "fs";
import cors from "cors";

import questionRoutes from "./src/routes/questionRoutes.ts";
import questionRoutes from "./routes/questionRoutes.ts";

dotenv.config();

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
MONGO_OBJ_ID_MALFORMED_MESSAGE,
} from "../utils/constants.ts";

import { upload } from "../../config/multer";
import { upload } from "../config/multer.ts";
import { uploadFileToFirebase } from "../utils/utils";
import { QnListSearchFilterParams, RandomQnCriteria } from "../utils/types.ts";

Expand Down
2 changes: 1 addition & 1 deletion backend/question-service/src/scripts/seed.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { exit } from "process";
import connectDB from "../../config/db";
import connectDB from "../config/db";
import Question from "../models/Question";

export async function seedQuestions() {
Expand Down
File renamed without changes.
6 changes: 4 additions & 2 deletions backend/question-service/src/utils/utils.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import mongoose from "mongoose";
import { v4 as uuidv4 } from "uuid";

import { bucket } from "../../config/firebase";
import { bucket } from "../config/firebase";

import Question from "../models/Question";

Expand Down Expand Up @@ -50,5 +50,7 @@ export const uploadFileToFirebase = async (
};

export const sortAlphabetically = (arr: string[]) => {
return [...arr].sort((a, b) => a.localeCompare(b, undefined, { sensitivity: 'base' }));
return [...arr].sort((a, b) =>
a.localeCompare(b, undefined, { sensitivity: "base" }),
);
};
2 changes: 1 addition & 1 deletion backend/question-service/tests/questionRoutes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NextFunction, Request, Response } from "express";
import { faker } from "@faker-js/faker";
import supertest from "supertest";
import app from "../app";
import app from "../src/app";
import Question from "../src/models/Question";
import {
DUPLICATE_QUESTION_MESSAGE,
Expand Down
4 changes: 2 additions & 2 deletions backend/user-service/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
"main": "app.ts",
"type": "module",
"scripts": {
"start": "tsx server.ts",
"dev": "tsx watch server.ts",
"start": "tsx ./src/server.ts",
"dev": "tsx watch ./src/server.ts",
"lint": "eslint .",
"test": "cross-env NODE_ENV=test jest --detectOpenHandles",
"test:watch": "cross-env NODE_ENV=test jest --watch --detectOpenHandles"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import http from "http";
import index from "./app.ts";
import dotenv from "dotenv";
import { connectToDB } from "./model/repository";
import { connectToDB } from "./model/repository.ts";
import { seedAdminAccount } from "./scripts/seed.ts";
import { connectRedis } from "./config/redis.ts";

Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions backend/user-service/tests/authRoutes.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import bcrypt from "bcrypt";
import { faker } from "@faker-js/faker";
import supertest from "supertest";
import app from "../app";
import UserModel from "../model/user-model";
import app from "../src/app";
import UserModel from "../src/model/user-model";

jest.setTimeout(10000);

Expand Down
2 changes: 1 addition & 1 deletion backend/user-service/tests/setup.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import mongoose from "mongoose";
import redisClient from "../config/redis";
import redisClient from "../src/config/redis";

beforeAll(async () => {
const mongoUri =
Expand Down
6 changes: 3 additions & 3 deletions backend/user-service/tests/userRoutes.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import bcrypt from "bcrypt";
import mongoose from "mongoose";
import { faker } from "@faker-js/faker";
import supertest from "supertest";
import app from "../app";
import UserModel from "../model/user-model";
import app from "../src/app";
import UserModel from "../src/model/user-model";

const request = supertest(app);

Expand All @@ -13,7 +13,7 @@ faker.seed(0);

const mockSendMail = jest.fn();

jest.mock("../middleware/basic-access-control", () => ({
jest.mock("../src/middleware/basic-access-control", () => ({
verifyAccessToken: jest.fn((req, res, next) => {
req.user = {
id: new mongoose.Types.ObjectId().toHexString(),
Expand Down

0 comments on commit be6e597

Please sign in to comment.