Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(dev): change endpoint access endpoint from client for server #128

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion client/src/pages/catalogue/api/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,10 @@ import {
CATALOGUE_DEFAULT_PAGE_NUMBER,
CATALOGUE_DEFAULT_PAGE_SIZE,
} from "shared/config/frontend";
import { apiConfig } from "shared/config/api";

const getInstrumentsByCriteriaPaginated =
new GetInstrumentsByCriteriaPaginatedApi();
new GetInstrumentsByCriteriaPaginatedApi(apiConfig);

export interface CatalogueLoader {
instrumentPage: GetInstrumentByCriteriaPageResponse;
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/catalogue/ui/Catalogue.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ import { CatalogueLoader } from "pages/catalogue";
import { NavigationBarWidget } from "widgets/catalogue-navbar";
import { SearchBarInputField } from "pages/catalogue/ui/SearchBarInput.field";
import { useDarkMode } from "shared/dark-mode/use-dark-mode";
import { apiConfig } from "shared/config/api";

const getInstrumentsByCriteriaPaginated =
new GetInstrumentsByCriteriaPaginatedApi();
new GetInstrumentsByCriteriaPaginatedApi(apiConfig);

export function CataloguePage() {
const { darkMode } = useDarkMode();
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/create-instrument/api/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { ActionFunction } from "react-router-dom";
import Jwt from "domain/model/jwt";
import { CreateInstrumentApi } from "generated/api/create-instrument-api";
import { parseInstrumentDetails } from "shared/model";
import { apiConfig } from "shared/config/api";

export interface CreateInstrumentAction {
errors: string[] | null;
}

const createInstrument = new CreateInstrumentApi();
const createInstrument = new CreateInstrumentApi(apiConfig);

export const action: ActionFunction = async ({
request,
Expand Down
9 changes: 5 additions & 4 deletions client/src/pages/create-instrument/api/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ import type {
import { GetInstrumentBasicMaterialsApi } from "generated/api/get-instrument-basic-materials-api";
import { GetCountriesApi } from "generated/api";
import { GetManufacturersApi } from "generated/api";
import { apiConfig } from "shared/config/api";

const getInstrumentTypes = new GetInstrumentTypesApi();
const getInstrumentBasicMaterials = new GetInstrumentBasicMaterialsApi();
const getCountries = new GetCountriesApi();
const getManufacturers = new GetManufacturersApi();
const getInstrumentTypes = new GetInstrumentTypesApi(apiConfig);
const getInstrumentBasicMaterials = new GetInstrumentBasicMaterialsApi(apiConfig);
const getCountries = new GetCountriesApi(apiConfig);
const getManufacturers = new GetManufacturersApi(apiConfig);

export interface CreateInstrumentLoader {
instrumentTypes: InstrumentType[];
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/edit-instrument/api/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { ActionFunction } from "react-router-dom";
import Jwt from "domain/model/jwt";
import { EditInstrumentApi } from "generated/api/edit-instrument-api";
import { parseInstrumentDetails } from "shared/model";
import { apiConfig } from "shared/config/api";

export interface EditInstrumentAction {
errors: string[];
}

const editInstrument = new EditInstrumentApi();
const editInstrument = new EditInstrumentApi(apiConfig);

export const action: ActionFunction = async ({
request,
Expand Down
13 changes: 7 additions & 6 deletions client/src/pages/edit-instrument/api/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,14 @@ import { GetInstrumentBasicMaterialsApi } from "generated/api/get-instrument-bas
import { GetCountriesApi } from "generated/api/get-countries-api";
import { GetManufacturersApi } from "generated/api/get-manufacturers-api";
import { GetInstrumentPhotoApi } from "generated/api/get-instrument-photo-api";
import { apiConfig } from "shared/config/api";

const getInstrumentById = new GetInstrumentByIdApi();
const getInstrumentTypes = new GetInstrumentTypesApi();
const getInstrumentBasicMaterials = new GetInstrumentBasicMaterialsApi();
const getCountries = new GetCountriesApi();
const getManufacturers = new GetManufacturersApi();
const getInstrumentPhoto = new GetInstrumentPhotoApi();
const getInstrumentById = new GetInstrumentByIdApi(apiConfig);
const getInstrumentTypes = new GetInstrumentTypesApi(apiConfig);
const getInstrumentBasicMaterials = new GetInstrumentBasicMaterialsApi(apiConfig);
const getCountries = new GetCountriesApi(apiConfig);
const getManufacturers = new GetManufacturersApi(apiConfig);
const getInstrumentPhoto = new GetInstrumentPhotoApi(apiConfig);

export interface EditInstrumentLoader {
instrumentForEdit: InstrumentDetail;
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/favorite/api/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ import { InstrumentDetail } from "generated/model";
import { ListFavoriteApi } from "generated/api/list-favorite-api";
import Jwt from "domain/model/jwt";
import { LOGIN } from "shared/config/paths";
import { apiConfig } from "shared/config/api";

export interface FavoriteLoader {
instrumentDetails: InstrumentDetail[];
}

const listFavorite = new ListFavoriteApi();
const listFavorite = new ListFavoriteApi(apiConfig);

export const loader: LoaderFunction = async (): Promise<
FavoriteLoader | Response
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/login/api/action.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import { ActionFunction, redirect } from "react-router-dom";
import { parseLoginForm } from "./../model/parse-login-form";
import { BasicLoginApi } from "generated/api";
import { PROFILE } from "shared/config/paths";
import { apiConfig } from "shared/config/api";

export interface LoginAction {
errors: string[];
}

const basicLoginApi = new BasicLoginApi();
const basicLoginApi = new BasicLoginApi(apiConfig);

export const action: ActionFunction = async ({
request,
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/profile/api/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,9 @@ import { GetUserProfileApi } from "generated/api/get-user-profile-api";
import { ProfileDetails } from "generated/model";
import { LOGIN } from "shared/config/paths";
import { redirect } from "react-router-dom";
import { apiConfig } from "shared/config/api";

const getUserProfile = new GetUserProfileApi();
const getUserProfile = new GetUserProfileApi(apiConfig);

export const loader = async (): Promise<ProfileDetails | Response> => {
const jwt = Jwt.extractFromCookie();
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/profile/ui/Profile.page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,9 @@ import { LOGIN } from "shared/config/paths";
import { deleteCookie } from "shared/cookie/cookie";
import { COOKIE_JWT_KEY, COOKIE_SESSIONID } from "shared/config/frontend";
import { useDarkMode } from "shared/dark-mode/use-dark-mode";
import { apiConfig } from "shared/config/api";

const logout = new LogoutApi();
const logout = new LogoutApi(apiConfig);

export function ProfilePage() {
useJwt();
Expand Down
3 changes: 2 additions & 1 deletion client/src/pages/registration/api/action.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { ActionFunction } from "react-router-dom";
import { parseForm } from "pages/registration/model/parseForm";
import { UserRegistrationApi } from "generated/api/user-registration-api";
import { apiConfig } from "shared/config/api";

const userRegistrationApi = new UserRegistrationApi();
const userRegistrationApi = new UserRegistrationApi(apiConfig);

export interface RegistrationAction {
errors: string[];
Expand Down
3 changes: 2 additions & 1 deletion client/src/shared/config/api.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Configuration } from "generated/configuration";

export const apiConfig = new Configuration({
basePath: "http://localhost:50505",
// basePath: "http://88.201.171.120:10001",
basePath: "http://localhost:5000",
});
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,15 @@ import { InstrumentId } from "generated/model";
import Jwt from "domain/model/jwt";
import { COOKIE_JWT_KEY } from "shared/config/frontend";
import { getCookie } from "shared/cookie/cookie";
import { apiConfig } from "shared/config/api";

interface Props {
instrumentId: InstrumentId;
}

const listFavorite = new ListFavoriteApi();
const removeFavorite = new RemoveFavoriteApi();
const addFavorite = new AddFavoriteApi();
const listFavorite = new ListFavoriteApi(apiConfig);
const removeFavorite = new RemoveFavoriteApi(apiConfig);
const addFavorite = new AddFavoriteApi(apiConfig);

export const FavoriteButton = (props: Props) => {
const jwt = useRef<string | undefined>(getCookie(COOKIE_JWT_KEY));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,15 @@ import actionBtnStyle from "./styles/Action.button.module.css";
import { InstrumentDetail } from "generated/model";
import { RemoveFavoriteApi } from "generated/api/remove-favorite-api";
import { useDarkMode } from "shared/dark-mode/use-dark-mode";
import { apiConfig } from "shared/config/api";

interface Props {
instrument: InstrumentDetail;
setSuccessModal: (successModal: boolean) => void;
setErrorModal: (errorModal: boolean) => void;
}

const removeFavoriteApi = new RemoveFavoriteApi();
const removeFavoriteApi = new RemoveFavoriteApi(apiConfig);

export const RemoveInstrumentButton = (props: Props) => {
const { darkMode } = useDarkMode();
Expand Down
3 changes: 2 additions & 1 deletion client/src/shared/instrument-card/ui/InstrumentPhoto.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,13 @@ import styles from "./styles/InstrumentPhoto.module.css";
import React, { useEffect, useState } from "react";
import { GetInstrumentPhotoApi } from "generated/api/get-instrument-photo-api";
import { InstrumentDetail } from "generated/model";
import { apiConfig } from "shared/config/api";

interface Props {
instrument: InstrumentDetail;
}

const getInstrumentPhoto = new GetInstrumentPhotoApi();
const getInstrumentPhoto = new GetInstrumentPhotoApi(apiConfig);

export const InstrumentPhoto = (props: Props) => {
const [photo, setPhoto] = useState<string | undefined>();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useEffect, useState } from "react";
import { GetCountriesApi } from "generated/api/get-countries-api";
import { Country } from "generated/model";
import { apiConfig } from "shared/config/api";

interface Props {
onValueChange: (names: Country[]) => void;
}

const getCountries = new GetCountriesApi();
const getCountries = new GetCountriesApi(apiConfig);

export const CountryFilter = ({ onValueChange }: Props) => {
const [countries, setCountries] = useState<Country[]>([]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import React, { useEffect, useState } from "react";
import textStyle from "./Text.module.css";
import { GetInstrumentTypesApi } from "generated/api/get-instrument-types-api";
import { InstrumentType } from "generated/model/instrument-type";
import { apiConfig } from "shared/config/api";

const getInstrumentTypes = new GetInstrumentTypesApi();
const getInstrumentTypes = new GetInstrumentTypesApi(apiConfig);

interface Props {
onValueChange: (i: InstrumentType[]) => void;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useEffect, useState } from "react";
import { GetManufacturersApi } from "generated/api/get-manufacturers-api";
import { Manufacturer, ManufacturerName } from "generated/model";
import { apiConfig } from "shared/config/api";

interface Props {
onValueChange: (names: ManufacturerName[]) => void;
}

const getManufacturers = new GetManufacturersApi();
const getManufacturers = new GetManufacturersApi(apiConfig);

export const ManufacturerNameFilter = ({ onValueChange }: Props) => {
const [manufacturers, setManufacturers] = useState<Manufacturer[]>([]);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import React, { useEffect, useState } from "react";
import { GetInstrumentBasicMaterialsApi } from "generated/api";
import { BasicMaterial } from "generated/model";
import { apiConfig } from "shared/config/api";

interface Props {
onValueChange: (names: BasicMaterial[]) => void;
}

const getInstrumentMaterials = new GetInstrumentBasicMaterialsApi();
const getInstrumentMaterials = new GetInstrumentBasicMaterialsApi(apiConfig);

export const MaterialFilter = ({ onValueChange }: Props) => {
const [materials, setMaterials] = useState<BasicMaterial[]>([]);
Expand Down
2 changes: 1 addition & 1 deletion tools/docker/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ services:
# platforms:
# - "linux/amd64"
# - "linux/arm64"
container_name: "${MUSE_CLIENT_IMAGE:-muse-client}"
container_name: muse-client
ports:
- ${CLIENT_PORT}:80
networks:
Expand Down
4 changes: 2 additions & 2 deletions tools/docker/env/dev.env
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
SERVER_PORT=10001
SERVER_DEBUG_PORT=50504
SERVER_DEBUG_PORT=10002

CLIENT_PORT=50001
CLIENT_DEV_PORT=3003
CLIENT_DEV_PORT=50002

POSTGRES_PORT=5555
POSTGRES_USER=muse
Expand Down
7 changes: 3 additions & 4 deletions tools/scripts/buildAndPush.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,9 @@ fi

dockerTag=$2

if [ -z "$2" ]
then
echo -e "\033[0;33mNo Docker Tag provided. Latest will be used.\033[0m"
dockerTag="latest"
if [ -z "$2" ]; then
echo -e "\033[0;33mNo Docker Tag provided. Latest will be used.\033[0m"
dockerTag="latest"
fi

(cd "$rootDir" && ./tools/scripts/openapi/regenerateOpenApi.sh)
Expand Down
9 changes: 5 additions & 4 deletions tools/scripts/clean.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,14 @@ rootDir="$currentDir/../../"

stage=$1

if [ -z "$1" ]
then
echo -e "\033[0;33mNo stage provided. 'local' stage will be used.\033[0m"
stage="local"
if [ -z "$1" ]; then
echo -e "\033[0;33mNo stage provided. 'local' stage will be used.\033[0m"
stage="local"
fi

(cd "$rootDir/server" && exec ./gradlew clean)

#https://github.com/docker/docs/issues/20709
(cd "$rootDir" && exec docker compose \
-f ./tools/docker/docker-compose.yml \
--env-file ./tools/docker/env/$stage.env \
Expand Down
1 change: 1 addition & 0 deletions tools/scripts/client/buildImage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ fi

echo [MUSE CLIENT] creating docker image "$imageFullName"...
(DOCKER_BUILDKIT=1 docker buildx build \
--no-cache \
--platform linux/arm64,linux/amd64 \
-f "${rootDir}/client/Dockerfile" \
-t "$imageFullName" \
Expand Down
Loading
Loading