Skip to content

Commit b5f6f31

Browse files
committed
Merge branch 'master' into clean-up-docker-files
2 parents 49e0c89 + 9eb74d5 commit b5f6f31

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

41 files changed

+853
-586
lines changed

frontend/workflows/pullrequest.yml renamed to .github/workflows/pullrequest.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,11 @@ jobs:
1919
node-version: "18" # You can specify the Node.js version you need
2020

2121
- name: Install dependencies
22-
run: npm install
22+
run: |
23+
cd frontend
24+
npm install
2325
24-
- name: Build
25-
run: npm run build
26+
- name: Build and lint
27+
run: |
28+
cd frontend
29+
npm run build

.gitignore

Lines changed: 4 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,8 @@
11
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
22

33
# dependencies
4-
/node_modules
5-
/frontend/node_modules
6-
/backend/node_modules
7-
/QuestionService/node_modules
8-
/QuestionService/javascript
9-
/AuthService/javascript
10-
/AuthService/node_modules
11-
/MatchingService/javascript
12-
/MatchingService/node_modules
13-
/UserService/node_modules
14-
/UserService/javascript
15-
/ApiGatewayService/javascript
16-
/ApiGatewayService/node_modules
17-
/backend/javascript
18-
/CollabService/javascript
19-
/CollabService/node_modules
20-
/ChatService/node_modules
21-
/ChatService/javascript
4+
node_modules
5+
javascript
226
/.pnp
237
.pnp.js
248

@@ -27,11 +11,8 @@
2711
/coverage
2812

2913
# production
30-
/frontend/build
31-
/backend/build
32-
/QuestionService/build
33-
/CollabService/build
34-
/ChatService/build
14+
build
15+
3516
# misc
3617
.DS_Store
3718
.env

ApiGatewayService/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@ app.use("/userservice", (req, res) => {
2828
proxy.web(req, res, { target: "http://user-service:3004" });
2929
});
3030

31-
3231
// Start the server
3332
app.listen(3001, () => {
3433
console.log("API Gateway listening on port 3001");

AuthService/package-lock.json

Lines changed: 16 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

AuthService/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"dotenv": "^16.3.1",
1515
"express": "~4.16.1",
1616
"firebase": "^10.4.0",
17-
"http-errors": "~1.6.3"
17+
"http-errors": "~1.6.3",
18+
"mime": "^1.6.0"
1819
},
1920
"devDependencies": {
2021
"@types/express": "^4.17.18",

AuthService/src/auth/auth.controller.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,13 @@ export async function handleSignUp(req: Request, res: Response) {
88
const signedUp = await signUp(email, password);
99
res.status(200).send(signedUp);
1010
} catch (error) {
11-
console.error(error);
12-
res.status(500).send(error);
11+
if (error instanceof Error) {
12+
console.error(error.message);
13+
res.status(500).send(error.message);
14+
} else {
15+
console.error(error);
16+
res.status(500).send(error);
17+
}
1318
}
1419
}
1520

@@ -20,8 +25,13 @@ export async function handleLogin(req: Request, res: Response) {
2025
const loggedIn = await login(email, password);
2126
res.status(200).send(loggedIn);
2227
} catch (error) {
23-
console.error(error);
24-
res.status(500).send(error);
28+
if (error instanceof Error) {
29+
console.error(error.message);
30+
res.status(500).send(error.message);
31+
} else {
32+
console.error(error);
33+
res.status(500).send(error);
34+
}
2535
}
2636
}
2737

AuthService/src/auth/auth.service.ts

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,17 +12,26 @@ import { firebaseConfig } from "../firebase/firebase.config";
1212
initializeApp(firebaseConfig);
1313
const auth = getAuth();
1414

15+
interface SignupCredential {
16+
user: UserCredential;
17+
token: string;
18+
}
19+
1520
export async function signUp(
1621
email: string,
1722
password: string
18-
): Promise<UserCredential> {
23+
): Promise<SignupCredential> {
1924
try {
2025
const user: UserCredential = await createUserWithEmailAndPassword(
2126
auth,
2227
email,
2328
password
2429
);
25-
return Promise.resolve(user);
30+
const token: string = await user.user.getIdToken();
31+
return Promise.resolve({
32+
user: user,
33+
token: token,
34+
});
2635
} catch (error: any) {
2736
return Promise.reject(error);
2837
}

AuthService/src/index.ts

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,35 +4,19 @@ import {
44
handleLogin,
55
handleLogout,
66
handleSignUp,
7-
handleDelete
7+
handleDelete,
88
} from "./auth/auth.controller";
9-
// import { Socket, Server } from 'socket.io';
10-
// import { initializeApp } from 'firebase/app';
11-
// import { getFirestore } from 'firebase/firestore';
12-
// import { firebaseConfig } from "./firebase/firebase.config";
13-
// import { Server as ServerHttp } from 'http';
149

1510
const app = express();
1611
const port = 3003;
1712
app.use(cors());
1813
app.use(express.json());
1914

20-
app.get("/", (req, res) => {
21-
res.send("Hello World!");
22-
});
23-
24-
2515
app.post("/signup", handleSignUp);
2616
app.post("/login", handleLogin);
2717
app.delete("/logout", handleLogout);
2818
app.delete("/delete", handleDelete);
2919

30-
31-
32-
// httpServer.listen(socketPort, () => {
33-
// console.log(`socket listening on port ${socketPort}`);
34-
// });
35-
3620
app.listen(port, () => {
3721
console.log(`Auth Service listening on port ${port}`);
3822
});

QuestionService/package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@
1414
"dotenv": "^16.3.1",
1515
"express": "~4.16.1",
1616
"firebase": "^10.4.0",
17-
"http-errors": "~1.6.3"
17+
"http-errors": "~1.6.3",
18+
"axios": "^1.5.1"
1819
},
1920
"devDependencies": {
2021
"@types/express": "^4.17.18",

QuestionService/src/question/question.controller.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,13 @@
11
import { Request, Response } from "express";
2-
import {addQuestion, db, deleteQuestion, updateQuestion} from "./question.service";
32
import {
4-
getDocs,
5-
collection,
6-
} from "firebase/firestore";
3+
addQuestion,
4+
db,
5+
deleteQuestion,
6+
isValidToken,
7+
updateQuestion,
8+
} from "./question.service";
9+
import { getDocs, collection } from "firebase/firestore";
10+
import axios from "axios";
711

812
interface Question {
913
title: string;
@@ -22,8 +26,19 @@ interface Example {
2226

2327
export async function handleGetQuestions(req: Request, res: Response) {
2428
try {
25-
// console.log(req.query.email);
26-
// const { email } = req.query;
29+
console.log("getting questions");
30+
const { token } = req.query;
31+
if (!token) {
32+
res.status(500).send("unauthorized access");
33+
}
34+
if (typeof token === "string") {
35+
const response = await isValidToken(token);
36+
if (!response) {
37+
res.status(500).send("unauthorized access");
38+
}
39+
} else {
40+
res.status(500).send("invalid params");
41+
}
2742
const query = await getDocs(collection(db, "questions"));
2843
const result = await Promise.all(
2944
query.docs.map(async (d) => {
@@ -96,7 +111,7 @@ export async function handleUpdateQuestion(req: Request, res: Response) {
96111
examples,
97112
} = req.body;
98113
console.log(`updating question ${questionId}: ${title}`);
99-
const question = await updateQuestion(questionId,{
114+
const question = await updateQuestion(questionId, {
100115
title: title,
101116
tags: tags,
102117
categories: categories,

0 commit comments

Comments
 (0)