From 8d106964f4b8079501816e46ad1cc9cec6e515ce Mon Sep 17 00:00:00 2001 From: Axel Adlercreutz <39679469+DoebelnAtz@users.noreply.github.com> Date: Fri, 11 Apr 2025 11:29:54 +0300 Subject: [PATCH] fix (#271) * fix * update requests * fixes * ssl * fix test * remove pgbouncer * cleanup --- Dockerfile | 6 +- {data => gradesa/data}/README.md | 0 {data => gradesa/data}/migrate.sh | 22 +- .../migrations/00001_empty_migration.sql | 0 .../migrations/00002_add_users_table.sql | 0 .../migrations/00003_add_form_tables.sql | 0 .../data}/migrations/00004_populate_forms.sql | 0 .../00005_drag_and_drop_exercise.sql | 0 .../migrations/00005_update_form_schema.sql | 0 .../data}/migrations/00006_add_advice.sql | 0 .../data}/migrations/00007_add_salt.sql | 0 .../data}/migrations/00008_add_username.sql | 0 .../data}/migrations/00009_add_admin_user.sql | 0 .../data}/migrations/00009_click_exercise.sql | 0 .../data}/migrations/00009_grammar_items.sql | 0 .../data}/migrations/00010_messages_table.sql | 0 .../migrations/00011_free_form_exercise.sql | 0 .../00012_free_form_adjustments.sql | 0 {data => gradesa/data}/reset-db.sh | 2 +- {data => gradesa/data}/schema.sql | 0 gradesa/package.json | 4 +- gradesa/schema.sql | 299 ++++++++++++++++++ gradesa/src/backend/config.js | 5 +- gradesa/src/backend/test/migrator.js | 2 +- gradesa/src/shared/hooks/useQuery.js | 6 +- package.json | 6 +- 26 files changed, 333 insertions(+), 19 deletions(-) rename {data => gradesa/data}/README.md (100%) rename {data => gradesa/data}/migrate.sh (52%) rename {data => gradesa/data}/migrations/00001_empty_migration.sql (100%) rename {data => gradesa/data}/migrations/00002_add_users_table.sql (100%) rename {data => gradesa/data}/migrations/00003_add_form_tables.sql (100%) rename {data => gradesa/data}/migrations/00004_populate_forms.sql (100%) rename {data => gradesa/data}/migrations/00005_drag_and_drop_exercise.sql (100%) rename {data => gradesa/data}/migrations/00005_update_form_schema.sql (100%) rename {data => gradesa/data}/migrations/00006_add_advice.sql (100%) rename {data => gradesa/data}/migrations/00007_add_salt.sql (100%) rename {data => gradesa/data}/migrations/00008_add_username.sql (100%) rename {data => gradesa/data}/migrations/00009_add_admin_user.sql (100%) rename {data => gradesa/data}/migrations/00009_click_exercise.sql (100%) rename {data => gradesa/data}/migrations/00009_grammar_items.sql (100%) rename {data => gradesa/data}/migrations/00010_messages_table.sql (100%) rename {data => gradesa/data}/migrations/00011_free_form_exercise.sql (100%) rename {data => gradesa/data}/migrations/00012_free_form_adjustments.sql (100%) rename {data => gradesa/data}/reset-db.sh (95%) rename {data => gradesa/data}/schema.sql (100%) create mode 100644 gradesa/schema.sql diff --git a/Dockerfile b/Dockerfile index 7b690d1..2974caa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,12 +18,16 @@ ENV SESSION_SECRET=secret \ DB_NAME=postgres +RUN apk update && \ + apk add --no-cache wget && \ + wget https://github.com/peterldowns/pgmigrate/releases/download/v0.0.6%2Bcommit.4f90829/pgmigrate-linux-amd64 -O /usr/local/bin/pgmigrate && \ + chmod +x /usr/local/bin/pgmigrate # Copy package files from gradesa COPY gradesa/package*.json ./ # Install ALL dependencies (including dev) for build -RUN npm ci +RUN npm i # Copy app files including .env.production COPY gradesa/ . diff --git a/data/README.md b/gradesa/data/README.md similarity index 100% rename from data/README.md rename to gradesa/data/README.md diff --git a/data/migrate.sh b/gradesa/data/migrate.sh similarity index 52% rename from data/migrate.sh rename to gradesa/data/migrate.sh index 7336f03..ca0d03c 100755 --- a/data/migrate.sh +++ b/gradesa/data/migrate.sh @@ -3,11 +3,29 @@ set -euo pipefail cd "$(dirname "$0")" - +echo $(pwd) echo "Migrating" -pgmigrate migrate -d postgres://ohtu:password@localhost:7742/gradesa -m migrations +# Get database connection details from environment variables if available, otherwise use defaults +DB_HOST=${DB_HOST:-localhost} +DB_PORT=${DB_PORT:-7742} +DB_USER=${DB_USER:-ohtu} +DB_PASSWORD=${DB_PASSWORD:-password} +DB_NAME=${DB_NAME:-gradesa} + +# Construct the database connection string +DB_URL="postgres://${DB_USER}:${DB_PASSWORD}@${DB_HOST}:${DB_PORT}/${DB_NAME}" + +# Run the migration +pgmigrate migrate -d "$DB_URL" -m migrations echo "Migrating done" +# Check if --skip-schema-gen flag is provided +if [[ "$*" == *--skip-schema-gen* ]]; then + echo "Skipping schema generation" + exit 0 +fi + + # We generate the schema file to make sure that the schema is up to date # The github workflow will check for uncommitted changes and fail if there is # a difference between the schema file and the actual schema in the database diff --git a/data/migrations/00001_empty_migration.sql b/gradesa/data/migrations/00001_empty_migration.sql similarity index 100% rename from data/migrations/00001_empty_migration.sql rename to gradesa/data/migrations/00001_empty_migration.sql diff --git a/data/migrations/00002_add_users_table.sql b/gradesa/data/migrations/00002_add_users_table.sql similarity index 100% rename from data/migrations/00002_add_users_table.sql rename to gradesa/data/migrations/00002_add_users_table.sql diff --git a/data/migrations/00003_add_form_tables.sql b/gradesa/data/migrations/00003_add_form_tables.sql similarity index 100% rename from data/migrations/00003_add_form_tables.sql rename to gradesa/data/migrations/00003_add_form_tables.sql diff --git a/data/migrations/00004_populate_forms.sql b/gradesa/data/migrations/00004_populate_forms.sql similarity index 100% rename from data/migrations/00004_populate_forms.sql rename to gradesa/data/migrations/00004_populate_forms.sql diff --git a/data/migrations/00005_drag_and_drop_exercise.sql b/gradesa/data/migrations/00005_drag_and_drop_exercise.sql similarity index 100% rename from data/migrations/00005_drag_and_drop_exercise.sql rename to gradesa/data/migrations/00005_drag_and_drop_exercise.sql diff --git a/data/migrations/00005_update_form_schema.sql b/gradesa/data/migrations/00005_update_form_schema.sql similarity index 100% rename from data/migrations/00005_update_form_schema.sql rename to gradesa/data/migrations/00005_update_form_schema.sql diff --git a/data/migrations/00006_add_advice.sql b/gradesa/data/migrations/00006_add_advice.sql similarity index 100% rename from data/migrations/00006_add_advice.sql rename to gradesa/data/migrations/00006_add_advice.sql diff --git a/data/migrations/00007_add_salt.sql b/gradesa/data/migrations/00007_add_salt.sql similarity index 100% rename from data/migrations/00007_add_salt.sql rename to gradesa/data/migrations/00007_add_salt.sql diff --git a/data/migrations/00008_add_username.sql b/gradesa/data/migrations/00008_add_username.sql similarity index 100% rename from data/migrations/00008_add_username.sql rename to gradesa/data/migrations/00008_add_username.sql diff --git a/data/migrations/00009_add_admin_user.sql b/gradesa/data/migrations/00009_add_admin_user.sql similarity index 100% rename from data/migrations/00009_add_admin_user.sql rename to gradesa/data/migrations/00009_add_admin_user.sql diff --git a/data/migrations/00009_click_exercise.sql b/gradesa/data/migrations/00009_click_exercise.sql similarity index 100% rename from data/migrations/00009_click_exercise.sql rename to gradesa/data/migrations/00009_click_exercise.sql diff --git a/data/migrations/00009_grammar_items.sql b/gradesa/data/migrations/00009_grammar_items.sql similarity index 100% rename from data/migrations/00009_grammar_items.sql rename to gradesa/data/migrations/00009_grammar_items.sql diff --git a/data/migrations/00010_messages_table.sql b/gradesa/data/migrations/00010_messages_table.sql similarity index 100% rename from data/migrations/00010_messages_table.sql rename to gradesa/data/migrations/00010_messages_table.sql diff --git a/data/migrations/00011_free_form_exercise.sql b/gradesa/data/migrations/00011_free_form_exercise.sql similarity index 100% rename from data/migrations/00011_free_form_exercise.sql rename to gradesa/data/migrations/00011_free_form_exercise.sql diff --git a/data/migrations/00012_free_form_adjustments.sql b/gradesa/data/migrations/00012_free_form_adjustments.sql similarity index 100% rename from data/migrations/00012_free_form_adjustments.sql rename to gradesa/data/migrations/00012_free_form_adjustments.sql diff --git a/data/reset-db.sh b/gradesa/data/reset-db.sh similarity index 95% rename from data/reset-db.sh rename to gradesa/data/reset-db.sh index f746410..fad2066 100755 --- a/data/reset-db.sh +++ b/gradesa/data/reset-db.sh @@ -5,6 +5,6 @@ set -euo pipefail cd "$(dirname "$0")" psql "postgres://ohtu:password@localhost:7742/gradesa" -c "DROP SCHEMA public CASCADE;CREATE SCHEMA public;" -cd ../ +cd ../../ npm run db:migrate echo "Migration DONE" \ No newline at end of file diff --git a/data/schema.sql b/gradesa/data/schema.sql similarity index 100% rename from data/schema.sql rename to gradesa/data/schema.sql diff --git a/gradesa/package.json b/gradesa/package.json index 8ace6bc..d76f4ac 100644 --- a/gradesa/package.json +++ b/gradesa/package.json @@ -6,7 +6,7 @@ "scripts": { "dev": "next dev", "build": "next build", - "start": "next start", + "start": "sh ./data/migrate.sh --skip-schema-gen && next start", "lint": "next lint", "test": "vitest --disable-console-intercept " }, @@ -46,4 +46,4 @@ "ts-node": "^10.9.2", "vitest": "^3.0.4" } -} +} \ No newline at end of file diff --git a/gradesa/schema.sql b/gradesa/schema.sql new file mode 100644 index 0000000..0f30785 --- /dev/null +++ b/gradesa/schema.sql @@ -0,0 +1,299 @@ +CREATE OR REPLACE FUNCTION public.updated_at() + RETURNS trigger + LANGUAGE plpgsql +AS $function$ + BEGIN + NEW.updated_at = NOW(); + RETURN NEW; + END; +$function$ +; + +CREATE TABLE public.click_answers ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + user_id bigint NOT NULL, + click_exercise_id bigint NOT NULL, + answer text[] NOT NULL, + target_words text[] NOT NULL, + is_correct boolean NOT NULL GENERATED ALWAYS AS ((answer = target_words)) STORED +); + +CREATE TRIGGER updated_at BEFORE UPDATE ON public.click_answers FOR EACH ROW EXECUTE FUNCTION updated_at(); + +CREATE TABLE public.click_exercises ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + title text NOT NULL, + category text NOT NULL, + target_words text[] NOT NULL, + all_words text[] NOT NULL +); + +ALTER TABLE public.click_exercises +ADD CONSTRAINT click_exercises_all_words_target_words_key +UNIQUE (all_words, target_words); + +ALTER TABLE public.click_exercises +ADD CONSTRAINT click_exercises_id_target_words_key +UNIQUE (id, target_words); + +ALTER TABLE public.click_answers +ADD CONSTRAINT click_answers_click_exercise_id_fkey +FOREIGN KEY (click_exercise_id) REFERENCES click_exercises(id) ON DELETE CASCADE; + +ALTER TABLE public.click_answers +ADD CONSTRAINT click_answers_click_exercise_id_target_words_fkey +FOREIGN KEY (click_exercise_id, target_words) REFERENCES click_exercises(id, target_words) ON UPDATE CASCADE ON DELETE CASCADE; + +CREATE TABLE public.users ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + email text UNIQUE NOT NULL, + password_hash text NOT NULL, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + salt text NOT NULL, + username text NOT NULL DEFAULT ''::text, + is_admin boolean DEFAULT false +); + +ALTER TABLE public.click_answers +ADD CONSTRAINT click_answers_user_id_fkey +FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; + +CREATE TABLE public.click_to_exercises ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + click_id bigint, + exercise_id bigint +); + +ALTER TABLE public.click_to_exercises +ADD CONSTRAINT click_to_exercises_click_id_fkey +FOREIGN KEY (click_id) REFERENCES click_exercises(id); + +CREATE TABLE public.exercises ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now() +); + +ALTER TABLE public.click_to_exercises +ADD CONSTRAINT click_to_exercises_exercise_id_fkey +FOREIGN KEY (exercise_id) REFERENCES exercises(id); + +CREATE TABLE public.draggable_words ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + word text NOT NULL, + correct_answer text NOT NULL +); + +ALTER TABLE public.draggable_words +ADD CONSTRAINT draggable_words_id_correct_answer_key +UNIQUE (id, correct_answer); + +ALTER TABLE public.draggable_words +ADD CONSTRAINT draggable_words_word_correct_answer_key +UNIQUE (word, correct_answer); + +CREATE TABLE public.exercises_to_grammar_items ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + grammar_item_id bigint, + exercise_id bigint +); + +ALTER TABLE public.exercises_to_grammar_items +ADD CONSTRAINT exercises_to_grammar_items_exercise_id_fkey +FOREIGN KEY (exercise_id) REFERENCES exercises(id); + +CREATE TABLE public.grammar_items ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + grammar_item text UNIQUE NOT NULL +); + +ALTER TABLE public.exercises_to_grammar_items +ADD CONSTRAINT exercises_to_grammar_items_grammar_item_id_fkey +FOREIGN KEY (grammar_item_id) REFERENCES grammar_items(id); + +CREATE SEQUENCE public.feedbacks_id_seq; + +CREATE TABLE public.feedbacks ( + id integer PRIMARY KEY NOT NULL DEFAULT nextval('feedbacks_id_seq'::regclass), + email character varying(255) NOT NULL, + message text NOT NULL, + user_id integer NOT NULL, + timestamp timestamp with time zone DEFAULT CURRENT_TIMESTAMP +); + +ALTER SEQUENCE public.feedbacks_id_seq OWNED BY public.feedbacks.id; + +CREATE TABLE public.form_parts ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + form_id bigint NOT NULL, + title_en text, + title_de text, + step_label text NOT NULL, + advice_en text, + advice_de text, + advice_threshold numeric(5,2) DEFAULT 3 +); + +ALTER TABLE public.form_parts +ADD CONSTRAINT check_step_label +CHECK ((step_label ~ '^[A-Za-z0-9]$'::text)); + +ALTER TABLE public.form_parts +ADD CONSTRAINT unique_step_label +UNIQUE (form_id, step_label); + +CREATE TABLE public.forms ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + public_id text UNIQUE NOT NULL, + title_en text, + title_de text, + description_en text, + description_de text +); + +ALTER TABLE public.form_parts +ADD CONSTRAINT form_parts_form_id_fkey +FOREIGN KEY (form_id) REFERENCES forms(id) ON DELETE RESTRICT; + +CREATE TABLE public.free_form_answers ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + free_form_exercise_id bigint NOT NULL, + answer text NOT NULL, + is_correct boolean DEFAULT false, + feedback text +); + +CREATE INDEX free_form_answers_free_form_exercise_id_idx ON public.free_form_answers USING btree (free_form_exercise_id); + +CREATE TABLE public.free_form_exercises ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + exercise_id bigint NOT NULL, + question text NOT NULL +); + +ALTER TABLE public.free_form_answers +ADD CONSTRAINT free_form_answers_free_form_exercise_id_fkey +FOREIGN KEY (free_form_exercise_id) REFERENCES free_form_exercises(id) ON DELETE CASCADE; + +ALTER TABLE public.free_form_exercises +ADD CONSTRAINT free_form_exercises_exercise_id_fkey +FOREIGN KEY (exercise_id) REFERENCES exercises(id) ON DELETE CASCADE; + +CREATE TABLE public.free_form_user_answers ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + answer text NOT NULL, + free_form_exercise_id bigint NOT NULL, + is_correct boolean DEFAULT false, + user_id bigint NOT NULL +); + +ALTER TABLE public.free_form_user_answers +ADD CONSTRAINT free_form_user_answers_free_form_exercise_id_user_id_key +UNIQUE (free_form_exercise_id, user_id); + +ALTER TABLE public.free_form_user_answers +ADD CONSTRAINT free_form_user_answers_free_form_exercise_id_fkey +FOREIGN KEY (free_form_exercise_id) REFERENCES free_form_exercises(id) ON DELETE CASCADE; + +ALTER TABLE public.free_form_user_answers +ADD CONSTRAINT free_form_user_answers_user_id_fkey +FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; + +CREATE TABLE public.part_questions ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + form_part_id bigint NOT NULL, + title_en text, + title_de text +); + +ALTER TABLE public.part_questions +ADD CONSTRAINT part_questions_form_part_id_fkey +FOREIGN KEY (form_part_id) REFERENCES form_parts(id) ON DELETE RESTRICT; + +CREATE TABLE public.pgmigrate_migrations ( + id text PRIMARY KEY NOT NULL, + checksum text NOT NULL, + execution_time_in_millis bigint NOT NULL, + applied_at timestamp with time zone NOT NULL +); + +CREATE TABLE public.user_answers ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + user_id bigint NOT NULL, + draggable_words_id bigint NOT NULL, + answer text NOT NULL, + correct_answer text NOT NULL, + is_correct boolean NOT NULL GENERATED ALWAYS AS ((answer = correct_answer)) STORED +); + +ALTER TABLE public.user_answers +ADD CONSTRAINT user_answers_draggable_words_id_correct_answer_fkey +FOREIGN KEY (draggable_words_id, correct_answer) REFERENCES draggable_words(id, correct_answer) ON UPDATE CASCADE ON DELETE CASCADE; + +ALTER TABLE public.user_answers +ADD CONSTRAINT user_answers_draggable_words_id_fkey +FOREIGN KEY (draggable_words_id) REFERENCES draggable_words(id) ON DELETE CASCADE; + +ALTER TABLE public.user_answers +ADD CONSTRAINT user_answers_user_id_fkey +FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; + +CREATE TABLE public.user_question_answers ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + answer integer NOT NULL, + user_id bigint NOT NULL, + part_question_id bigint NOT NULL +); + +ALTER TABLE public.user_question_answers +ADD CONSTRAINT user_question_answers_user_id_part_question_id_key +UNIQUE (user_id, part_question_id); + +ALTER TABLE public.user_question_answers +ADD CONSTRAINT user_question_answers_part_question_id_fkey +FOREIGN KEY (part_question_id) REFERENCES part_questions(id) ON DELETE RESTRICT; + +ALTER TABLE public.user_question_answers +ADD CONSTRAINT user_question_answers_user_id_fkey +FOREIGN KEY (user_id) REFERENCES users(id) ON DELETE CASCADE; + +CREATE TABLE public.words_to_exercises ( + id bigint PRIMARY KEY NOT NULL GENERATED BY DEFAULT AS IDENTITY, + created_at timestamp with time zone NOT NULL DEFAULT now(), + updated_at timestamp with time zone NOT NULL DEFAULT now(), + word_id bigint, + exercise_id bigint +); + +ALTER TABLE public.words_to_exercises +ADD CONSTRAINT words_to_exercises_exercise_id_fkey +FOREIGN KEY (exercise_id) REFERENCES exercises(id); + +ALTER TABLE public.words_to_exercises +ADD CONSTRAINT words_to_exercises_word_id_fkey +FOREIGN KEY (word_id) REFERENCES draggable_words(id); diff --git a/gradesa/src/backend/config.js b/gradesa/src/backend/config.js index 47c8fc2..3d6faaa 100644 --- a/gradesa/src/backend/config.js +++ b/gradesa/src/backend/config.js @@ -56,10 +56,6 @@ function create() { } return val ?? ""; } - // Unused-vars - // function readStringOptional(key, defaultValue) { - // return getFromEnv(key) ?? defaultValue; - // } function readInt(key) { const val = getFromEnv(key); @@ -86,6 +82,7 @@ function create() { user: readString("DB_USER"), password: readString("DB_PASSWORD"), database: readString("DB_NAME"), + ssl: isProduction, }, }; diff --git a/gradesa/src/backend/test/migrator.js b/gradesa/src/backend/test/migrator.js index 6f26a31..ef25ce7 100644 --- a/gradesa/src/backend/test/migrator.js +++ b/gradesa/src/backend/test/migrator.js @@ -79,7 +79,7 @@ export class Migrator { get migrationsDir() { return path - .join(__dirname, "../../../../data", "migrations") + .join(__dirname, "../../../data", "migrations") .replace("dist/", ""); } } diff --git a/gradesa/src/shared/hooks/useQuery.js b/gradesa/src/shared/hooks/useQuery.js index 5202840..929b272 100644 --- a/gradesa/src/shared/hooks/useQuery.js +++ b/gradesa/src/shared/hooks/useQuery.js @@ -4,12 +4,8 @@ import { useState, useEffect, useRef, useMemo } from "react"; import { useIsMounted } from "./useIsMounted"; import { useUser } from "@/context/user.context"; -const baseUrl = - process.env.NEXT_ENV === "production" - ? "https://tbd.com" - : "http://localhost:3000"; export const axiosInstance = axios.create({ - baseURL: `${baseUrl}/api`, + baseURL: `/api`, }); /** diff --git a/package.json b/package.json index 5c2c810..8039d7f 100644 --- a/package.json +++ b/package.json @@ -4,8 +4,8 @@ "packageManager": "npm@10.2.4", "description": "GRADESA is a freely accessible website where language learners at language centres as well as university students of German studies can autonomously work on their German grammar skills and knowledge.", "scripts": { - "db:migrate": "./data/migrate.sh", - "db:reset": "./data/reset-db.sh", + "db:migrate": "./gradesa/data/migrate.sh", + "db:reset": "./gradesa/data/reset-db.sh", "prepare": "husky install", "dev": "npm run --prefix gradesa dev", "format:check": "prettier --check \"**/*.{js,jsx,md,yml}\"", @@ -29,4 +29,4 @@ }, "author": "", "license": "ISC" -} +} \ No newline at end of file