Skip to content

Commit

Permalink
constant-urls-added
Browse files Browse the repository at this point in the history
  • Loading branch information
vahdetprlk committed Jul 17, 2024
1 parent 68e8e9c commit ab3cafc
Show file tree
Hide file tree
Showing 17 changed files with 48 additions and 59 deletions.
28 changes: 28 additions & 0 deletions frontend/src/contants/contants.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
export const changeUrlBase = "http://localhost:8000/user/pwd/update";
export const changeUsernameUrl = "http://127.0.0.1:8000/user/username";
export const userDetailUrl = "http://127.0.0.1:8000/user/details";
export const updateUserUrl = "http://127.0.0.1:8000/user/update";
export const pictureUrl = "http://localhost:8014/bucket/image/serve";
export const avatarUpdateUrl = "http://localhost:8014/bucket/image";
export const forgotpasswordUrl = "http://127.0.0.1:8000/user/pwd/forgot";
export const userGetByIdUrl = "http://127.0.0.1:8000/user/get/id";
export const requestsList = "http://127.0.0.1:8000/friends/request";
export const acceptUrl = "http://127.0.0.1:8000/friends/accept";
export const rejectUrl = "http://127.0.0.1:8000/friends/reject";
export const friendList = "http://127.0.0.1:8000/friends/list";
export const friendDelete = "http://127.0.0.1:8000/friends/delete";
export const singleUserDetailUrl = "http://127.0.0.1:8000/user/get/id";
export const gameDetailUrl = "http://127.0.0.1:8000/game/list";
export const joinUrl = "http://127.0.0.1:8000/game/join";
export const matchHistoryUrl = "http://127.0.0.1:8000/game/history";
export const gameCreateUrl = "http://127.0.0.1:8000/game/room";
export const registerUrl = "http://localhost:8000/user/register";
export const loginUrl = "http://127.0.0.1:8000/user/login";
export const IntraOAuthUrl = "http://127.0.0.1:8000/auth/intra"
export const resetUrlBase = "http://localhost:8004/user/pwd/change";
export const url = "http://127.0.0.1:8000/user/2fa";
export const twofaUrl = "http://127.0.0.1:8000/user/2fa";
export const searchUrl = "http://127.0.0.1:8000/user/search";
export const friendAdd = "http://127.0.0.1:8000/friends/add";
export const ValidateAccessToken = "http://127.0.0.1:8000/auth/token/validate";
export const ValidateRefreshToken = "http://127.0.0.1:8000/auth/token/refresh";
3 changes: 1 addition & 2 deletions frontend/src/routes/changepassword/Changepassword.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { navigateTo } from "../../utils/navTo.js";
import { insertIntoElement } from "../../utils/utils.js";

const changeUrlBase = "http://localhost:8000/user/pwd/update";
import { changeUrlBase } from "../../contants/contants.js"

export async function fetchChangepassword() {
const access_token = localStorage.getItem("access_token");
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/routes/conflictusername/Conflictusername.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { navigateTo } from "../../utils/navTo.js";
import { insertIntoElement, toggleHidden } from "../../utils/utils.js";
import { changeUsernameUrl } from "../../contants/contants.js";

const url = "http://127.0.0.1:8000/user/username";

export async function fetchConflictusername() {
const form = document.getElementById("uname-code");
Expand All @@ -22,7 +22,7 @@ export async function fetchConflictusername() {
toggleHidden('login-spinner');

try {
const response = await fetch(url, {
const response = await fetch(changeUsernameUrl, {
method: "PATCH",
headers: {
"Content-Type": "application/json",
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/routes/edit/Edit.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { navigateTo } from "../../utils/navTo.js";
import { insertIntoElement } from "../../utils/utils.js";

const userDetailUrl = "http://127.0.0.1:8000/user/details";
const updateUserUrl = "http://127.0.0.1:8000/user/update";
const pictureUrl = "http://localhost:8014/bucket/image/serve";
const avatarUpdateUrl = "http://localhost:8014/bucket/image";
import { userDetailUrl, updateUserUrl, pictureUrl, avatarUpdateUrl } from "../../contants/contants.js";

export async function fetchEdit() {
const access_token = localStorage.getItem("access_token");
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/routes/forgotpassword/Forgotpassword.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { forgotpasswordUrl } from "../../contants/contants.js";


const forgotpasswordUrl = "http://127.0.0.1:8000/user/pwd/forgot"; //post body email
export async function fetchForgotpassword() {
document.querySelector('form').addEventListener('submit', async function(event) {
event.preventDefault();
Expand Down
8 changes: 1 addition & 7 deletions frontend/src/routes/friendrequests/Friendrequests.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
import { navigateTo } from "../../utils/navTo.js";
import { goPagination } from "../../utils/utils.js";


const userGetByIdUrl = "http://127.0.0.1:8000/user/get/id";
const userDetailUrl = "http://127.0.0.1:8000/user/details";
const requestsList = "http://127.0.0.1:8000/friends/request";
const acceptUrl = "http://127.0.0.1:8000/friends/accept";
const rejectUrl = "http://127.0.0.1:8000/friends/reject";
import { userGetByIdUrl, userDetailUrl, requestsList, acceptUrl, rejectUrl } from "../../contants/contants.js";

let currentPage = 1; // Current page

Expand Down
6 changes: 1 addition & 5 deletions frontend/src/routes/friends/Friends.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
import { navigateTo } from "../../utils/navTo.js";
import { userStatuses } from "../../utils/utils.js";
import { goPagination } from "../../utils/utils.js";
const friendList = "http://127.0.0.1:8000/friends/list";
const friendDelete = "http://127.0.0.1:8000/friends/delete";
const userDetailUrl = "http://127.0.0.1:8000/user/details";
const singleUserDetailUrl = "http://127.0.0.1:8000/user/get/id";
const pictureUrl = "http://localhost:8014/bucket/image/serve";
import { friendList, friendDelete, userDetailUrl, singleUserDetailUrl, pictureUrl } from "../../contants/contants.js";

let currentPage = 1; // Current page
export async function fetchFriends() {
Expand Down
6 changes: 1 addition & 5 deletions frontend/src/routes/join/Join.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { navigateTo } from "../../utils/navTo.js";
import { goPagination } from "../../utils/utils.js";


const userDetailUrl = "http://127.0.0.1:8000/user/details";
const gameDetailUrl = "http://127.0.0.1:8000/game/list";
const joinUrl = "http://127.0.0.1:8000/game/join";
import { userDetailUrl, gameDetailUrl, joinUrl } from "../../contants/contants.js";

let currentPage = 1; // Current page

Expand Down
4 changes: 1 addition & 3 deletions frontend/src/routes/login/Login.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { insertIntoElement, toggleHidden } from "../../utils/utils.js";
import { navigateTo } from "../../utils/navTo.js";

const loginUrl = "http://127.0.0.1:8000/user/login";
const IntraOAuthUrl = "http://127.0.0.1:8000/auth/intra"
import { loginUrl, IntraOAuthUrl } from "../../contants/contants.js";

export async function fetchLogin() {

Expand Down
5 changes: 1 addition & 4 deletions frontend/src/routes/otherprofile/Otherprofile.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,7 @@

import { navigateTo } from "../../utils/navTo.js";
import { goPagination } from "../../utils/utils.js";

const userGetByIdUrl = "http://127.0.0.1:8000/user/get/id";
const matchHistoryUrl = "http://127.0.0.1:8000/game/history";
const pictureUrl = "http://localhost:8014/bucket/image/serve";
import { userGetByIdUrl, matchHistoryUrl, pictureUrl } from "../../contants/contants.js";

let currentPage = 1; // Current page

Expand Down
5 changes: 1 addition & 4 deletions frontend/src/routes/profile/Profile.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { navigateTo } from "../../utils/navTo.js";
import { goPagination } from "../../utils/utils.js";

const userDetailUrl = "http://127.0.0.1:8000/user/details";
const matchHistoryUrl = "http://127.0.0.1:8000/game/history";
const pictureUrl = "http://localhost:8014/bucket/image/serve";
import { userDetailUrl, matchHistoryUrl, pictureUrl } from "../../contants/contants.js;

let currentPage = 1; // Current page

Expand Down
3 changes: 2 additions & 1 deletion frontend/src/routes/quickplay/Quickplay.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { navigateTo } from "../../utils/navTo.js";
import { insertIntoElement } from "../../utils/utils.js";
const gameCreateUrl = "http://127.0.0.1:8000/game/room";
import { gameCreateUrl } from "../../contants/contants.js";

export async function fetchQuickplay() {
const access_token = localStorage.getItem("access_token");
if (!access_token) {
Expand Down
4 changes: 2 additions & 2 deletions frontend/src/routes/register/Register.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { navigateTo } from "../../utils/navTo.js";
import { insertIntoElement, toggleHidden } from "../../utils/utils.js";
import { registerUrl } from "../../contants/contants.js";

const url = "http://localhost:8000/user/register";
const form = document.getElementById("register");

export async function fetchRegister () {
Expand All @@ -28,7 +28,7 @@ form.addEventListener("submit", (e) => {
toggleHidden('register');
// toggleHidden('register-spinner');

fetch(url, {
fetch(registerUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/routes/resetpassword/Resetpassword.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { navigateTo } from "../../utils/navTo.js";
import { insertIntoElement, toggleHidden } from "../../utils/utils.js";

const resetUrlBase = "http://localhost:8004/user/pwd/change";
import { resetUrlBase } from "../../contants/contants.js";

export async function fetchResetpassword() {
document.querySelector('form').addEventListener('submit', async function(event) {
Expand Down
6 changes: 2 additions & 4 deletions frontend/src/routes/twofa/TwoFA.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
import { navigateTo } from "../../utils/navTo.js";
import { insertIntoElement, toggleHidden } from "../../utils/utils.js";


const url = "http://127.0.0.1:8000/user/2fa";
import { twofaUrl } from "../../contants/contants.js";

export async function fetch2FA() {

Expand All @@ -22,7 +20,7 @@ form.addEventListener("submit", (e) => {
toggleHidden('2fa-code');
toggleHidden('login-spinner');

fetch(url, {
fetch(twofaUrl, {
method: "POST",
headers: {
"Content-Type": "application/json",
Expand Down
7 changes: 1 addition & 6 deletions frontend/src/routes/users/Users.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import { navigateTo } from "../../utils/navTo.js";
import { userStatuses } from "../../utils/utils.js";
import { goPagination } from "../../utils/utils.js";


const searchUrl = "http://127.0.0.1:8000/user/search";
const friendAdd = "http://127.0.0.1:8000/friends/add";
const userDetailUrl = "http://127.0.0.1:8000/user/details";
const pictureUrl = "http://localhost:8014/bucket/image/serve";
import { searchUrl, friendAdd, userDetailUrl, pictureUrl } from "../../contants/contants.js;

let currentPage = 1; // Current page

Expand Down
6 changes: 1 addition & 5 deletions frontend/src/utils/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { navigateTo } from "./navTo";
import{ ValidateAccessToken, ValidateRefreshToken, userDetailUrl } from "../contants/contants";

export const insertIntoElement = (elementId, element) => {
const el = document.getElementById(elementId);
Expand Down Expand Up @@ -27,16 +28,13 @@ export const toggleHidden = (elementId) => {
}
}



export let socket = null;
export let userStatuses = {};

export async function onlineStatus() {
let userId = 0;

async function getUserId() {
const userDetailUrl = "http://127.0.0.1:8000/user/details";
const access_token = localStorage.getItem("access_token");
const response = await fetch(userDetailUrl, {
method: "GET",
Expand Down Expand Up @@ -140,8 +138,6 @@ export function goPagination(totalPages, currentPage, onClick, elementId) {
paginationContainer.appendChild(nextButton);
}

const ValidateAccessToken = "http://127.0.0.1:8000/auth/token/validate";
const ValidateRefreshToken = "http://127.0.0.1:8000/auth/token/refresh";
export async function CheckAuth() {
const access_token = localStorage.getItem("access_token");
if (!access_token) {
Expand Down

0 comments on commit ab3cafc

Please sign in to comment.