Skip to content

Commit

Permalink
feat: Frontend setup
Browse files Browse the repository at this point in the history
  • Loading branch information
Yongbeom-Kim committed Nov 11, 2024
1 parent 429f083 commit 2622d25
Show file tree
Hide file tree
Showing 13 changed files with 281 additions and 74 deletions.
9 changes: 9 additions & 0 deletions peerprep/frontend/.env.development
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
VITE_AUTH_API_URL=http://localhost:3001/auth
VITE_MATCHING_API_URL=http://localhost:3000/matchingrequest
VITE_USER_API_URL=http://localhost:3001/api/users
VITE_USERS_API_URL=http://localhost:3001/users
VITE_ASSESSCODE_API_URL=http://localhost:1234/api/gpt/assess
VITE_QUESTION_API_URL=http://localhost:8080/api/questions
VITE_TESTCASE_API_URL=http://localhost:8080/api/testcases
VITE_WS_PROVIDER_URL=ws://localhost:1234/
VITE_SOCKET_IO_URL=http://localhost:1234
9 changes: 9 additions & 0 deletions peerprep/frontend/.env.production
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
VITE_AUTH_API_URL=http://user.peerprep.app/auth
VITE_MATCHING_API_URL=http://matching.peerprep.app/matchingrequest
VITE_USER_API_URL=http://user.peerprep.app/api/users
VITE_USERS_API_URL=http://user.peerprep.app/users
VITE_QUESTION_API_URL=http://question.peerperp.app/api/questions
VITE_TESTCASE_API_URL=http://question.peerperp.app/api/testcases
VITE_ASSESSCODE_API_URL=http://collab.peerprep.app/api/gpt/assess
VITE_WS_PROVIDER_URL=ws://collab.peerprep.app/
VITE_SOCKET_IO_URL=http://collab.peerprep.app/
2 changes: 1 addition & 1 deletion peerprep/frontend/src/api/assesscodeApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios, { AxiosError } from 'axios';

const API_URL = 'http://localhost:1234/api/gpt/assess';
const API_URL = import.meta.env.VITE_ASSESSCODE_API_URL;

// Define a custom error class for API errors
export class ApiError extends Error {
Expand Down
2 changes: 1 addition & 1 deletion peerprep/frontend/src/api/authApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import axios, { AxiosError } from 'axios';
import { User } from '../models/User';

// Base URL for authentication APIs
const API_URL = 'http://localhost:3001/auth';
const API_URL = import.meta.env.VITE_AUTH_API_URL;

class ApiError extends Error {
constructor(message: string, public statusCode?: number) {
Expand Down
2 changes: 1 addition & 1 deletion peerprep/frontend/src/api/matchingApi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios, { AxiosError } from 'axios';

// Set up axios instance with base URL
const API_URL = "http://localhost:3000/matchingrequest";
const API_URL = import.meta.env.VITE_MATCHING_API_URL;

export class ApiError extends Error {
constructor(message: string, public statusCode?: number) {
Expand Down
2 changes: 1 addition & 1 deletion peerprep/frontend/src/api/questionApi.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import axios, { AxiosError } from 'axios';
import { Question } from '../models/Question';

const API_URL = 'http://localhost:8080/api/questions';
const API_URL = import.meta.env.VITE_QUESTION_API_URL;

export class ApiError extends Error {
constructor(message: string, public statusCode?: number) {
Expand Down
2 changes: 1 addition & 1 deletion peerprep/frontend/src/api/testcaseApi.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import axios from 'axios';

const API_URL = 'http://localhost:8080/api/testcases';
const API_URL = import.meta.env.VITE_TESTCASE_API_URL;

export interface Testcase {
questionId: number;
Expand Down
2 changes: 1 addition & 1 deletion peerprep/frontend/src/api/userApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import axios, { AxiosError } from 'axios';
import { User } from '../models/User';

// Set up axios instance with base URL
const API_URL = "http://localhost:3001/api/users";
const API_URL = import.meta.env.VITE_USER_API_URL;

class ApiError extends Error {
constructor(message: string, public statusCode?: number) {
Expand Down
2 changes: 1 addition & 1 deletion peerprep/frontend/src/api/usersApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import axios, { AxiosError } from 'axios';
import { User } from '../models/User';

// Base URL for user APIs
const API_URL = 'http://localhost:3001/users';
const API_URL = import.meta.env.VITE_USERS_API_URL;

class ApiError extends Error {
constructor(message: string, public statusCode?: number) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ const CollaborationServiceIntegratedView: React.FC = () => {

useEffect(() => {
const ydoc = new Y.Doc();
const provider = new WebsocketProvider('ws://localhost:1234/' + sessionId, 'collaborative-doc', ydoc);
const provider = new WebsocketProvider(import.meta.env.VITE_WS_PROVIDER_URL + sessionId, 'collaborative-doc', ydoc);
const newYText = ydoc.getText('codemirror');
setYText(newYText);

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React, { useState, useEffect } from 'react';
import io from 'socket.io-client';

const socket = io('http://localhost:1234', {
const socket = io(import.meta.env.VITE_SOCKET_IO_URL, {
reconnectionAttempts: 3, // attempt reconnection 3 times
timeout: 5000, // connection timeout
});
Expand Down
2 changes: 1 addition & 1 deletion peerprep/frontend/tsconfig.app.tsbuildinfo
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"root":["./src/App.tsx","./src/jest.setup.ts","./src/main.tsx","./src/setupTests.ts","./src/vite-env.d.ts","./src/y-codemirror.d.ts","./src/api/assesscodeApi.ts","./src/api/authApi.ts","./src/api/matchingApi.ts","./src/api/questionApi.ts","./src/api/testcaseApi.ts","./src/api/userApi.ts","./src/api/usersApi.ts","./src/components/Footer.tsx","./src/components/Navbar.tsx","./src/controllers/QuestionController.tsx","./src/models/Question.tsx","./src/models/Request.tsx","./src/models/User.tsx","./src/views/CollabServiceViews/CollabServiceIntegratedView.tsx","./src/views/CollabServiceViews/CollabServiceMainView.tsx","./src/views/CollabServiceViews/components/Chat.tsx","./src/views/MatchingServiceViews/MatchingServiceMainView.tsx","./src/views/MatchingServiceViews/SessionStubView.tsx","./src/views/QuestionServiceViews/QuestionForm.tsx","./src/views/QuestionServiceViews/QuestionList.tsx","./src/views/QuestionServiceViews/QuestionManagement.tsx","./src/views/UserServiceViews/AdminDashBoard.tsx","./src/views/UserServiceViews/Login.tsx","./src/views/UserServiceViews/PrivateRoute.tsx","./src/views/UserServiceViews/Profile.tsx","./src/views/UserServiceViews/SignUp.tsx"],"errors":true,"version":"5.6.2"}
{"root":["./src/App.tsx","./src/jest.setup.ts","./src/main.tsx","./src/setupTests.ts","./src/vite-env.d.ts","./src/y-codemirror.d.ts","./src/api/assesscodeApi.ts","./src/api/authApi.ts","./src/api/matchingApi.ts","./src/api/questionApi.ts","./src/api/testcaseApi.ts","./src/api/userApi.ts","./src/api/usersApi.ts","./src/components/Footer.tsx","./src/components/Navbar.tsx","./src/controllers/QuestionController.tsx","./src/models/Question.tsx","./src/models/Request.tsx","./src/models/User.tsx","./src/views/CollabServiceViews/CollabServiceIntegratedView.tsx","./src/views/CollabServiceViews/CollabServiceMainView.tsx","./src/views/CollabServiceViews/components/Chat.tsx","./src/views/MatchingServiceViews/MatchingServiceMainView.tsx","./src/views/MatchingServiceViews/SessionStubView.tsx","./src/views/QuestionServiceViews/QuestionForm.tsx","./src/views/QuestionServiceViews/QuestionList.tsx","./src/views/QuestionServiceViews/QuestionManagement.tsx","./src/views/UserServiceViews/AdminDashBoard.tsx","./src/views/UserServiceViews/Login.tsx","./src/views/UserServiceViews/PrivateRoute.tsx","./src/views/UserServiceViews/Profile.tsx","./src/views/UserServiceViews/SignUp.tsx"],"version":"5.6.2"}
Loading

0 comments on commit 2622d25

Please sign in to comment.