diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json index f146668..fa758d1 100644 --- a/.devcontainer/devcontainer.json +++ b/.devcontainer/devcontainer.json @@ -32,7 +32,8 @@ "ms-ossdata.vscode-pgsql", "GitHub.copilot", "GitHub.vscode-pull-request-github", - "Gruntfuggly.todo-tree" + "Gruntfuggly.todo-tree", + "vitest.explorer" ], "settings": { "todo-tree.ripgrep.ripgrep": "/usr/bin/rg", @@ -67,7 +68,8 @@ } }, "remoteEnv": { - "DATABASE_URL": "postgresql://postgres:postgres@db:5432/teaching_api?schema=public" + "DATABASE_URL": "postgresql://postgres:postgres@db:5432/teaching_api?schema=public", + "TEST_DATABASE_URL": "postgresql://postgres:postgres@db:5432/teaching_api_test?schema=public" } // Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root. // "remoteUser": "root" diff --git a/.devcontainer/docker-compose.yml b/.devcontainer/docker-compose.yml index e167c6e..8fadb2e 100644 --- a/.devcontainer/docker-compose.yml +++ b/.devcontainer/docker-compose.yml @@ -15,6 +15,7 @@ services: environment: - NODE_ENV=development - DATABASE_URL=postgresql://postgres:postgres@db:5432/teaching_api?schema=public + - TEST_DATABASE_URL=postgresql://postgres:postgres@db:5432/teaching_api_test?schema=public - PORT=3002 # Runs app on the same network as the database container, allows "forwardPorts" in devcontainer.json function. diff --git a/.example.env b/.example.env index 4368687..dec7fab 100644 --- a/.example.env +++ b/.example.env @@ -1,11 +1,9 @@ -DATABASE_URL="postgresql://user:pw@localhost:5432/teaching_website" -USER_ID="b6651212-0765-4d1c-ba5c-71632bf53d2a" -USER_EMAIL="Max.Muster@gbsl.ch" -ALLOWED_ORIGINS="http://localhost:3000" -ALLOW_SUBDOMAINS="false" -MSAL_CLIENT_ID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -MSAL_TENANT_ID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -ADMIN_USER_GROUP_ID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" -GITHUB_CLIENT_SECRET="xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" -GITHUB_CLIENT_ID="xxxxxxxxxxxxxxxxxxxx" -GITHUB_REDIRECT_URI="http://localhost:3000/gh-callback" \ No newline at end of file +USER_ID="" +USER_EMAIL="" +APP_NAME="infTeachingApi" +ALLOWED_ORIGINS="gbsl.website" +BETTER_AUTH_SECRET="$(openssl rand -base64 32)" +BETTER_AUTH_URL="http://localhost:3002" +MSAL_CLIENT_ID="" +MSAL_CLIENT_SECRET="" +MSAL_TENANT_ID="" \ No newline at end of file diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..925dc86 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,50 @@ +name: Tests + +on: + pull_request: + push: + branches: + - main + +jobs: + test: + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:17.2 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: teaching_api_test + ports: + - 5432:5432 + options: >- + --health-cmd="pg_isready -U postgres -d teaching_api_test" + --health-interval=10s + --health-timeout=5s + --health-retries=5 + + steps: + - name: Checkout repository + uses: actions/checkout@v6 + + - name: Set up Node.js + uses: actions/setup-node@v6 + with: + node-version: '24.18' + cache: 'yarn' + + - name: Install dependencies + run: yarn install --frozen-lockfile + + - name: Generate Prisma client + env: + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/teaching_api_test?schema=public + run: yarn prisma generate + + - name: Run tests + env: + DATABASE_URL: postgresql://postgres:postgres@localhost:5432/teaching_api_test?schema=public + TEST_DATABASE_URL: postgresql://postgres:postgres@localhost:5432/teaching_api_test?schema=public + run: yarn test diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b8..0000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.idea/codeStyles/codeStyleConfig.xml b/.idea/codeStyles/codeStyleConfig.xml deleted file mode 100644 index a55e7a1..0000000 --- a/.idea/codeStyles/codeStyleConfig.xml +++ /dev/null @@ -1,5 +0,0 @@ - - - - \ No newline at end of file diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml deleted file mode 100644 index 90a5fb6..0000000 --- a/.idea/dataSources.xml +++ /dev/null @@ -1,17 +0,0 @@ - - - - - postgresql - true - org.postgresql.Driver - jdbc:postgresql://localhost:5432/teaching_api - - - - - - $ProjectFileDir$ - - - \ No newline at end of file diff --git a/.idea/misc.xml b/.idea/misc.xml deleted file mode 100644 index 07115cd..0000000 --- a/.idea/misc.xml +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/.idea/modules.xml b/.idea/modules.xml deleted file mode 100644 index b387e8b..0000000 --- a/.idea/modules.xml +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/.idea/runConfigurations/dev.xml b/.idea/runConfigurations/dev.xml deleted file mode 100644 index 46d8ec8..0000000 --- a/.idea/runConfigurations/dev.xml +++ /dev/null @@ -1,12 +0,0 @@ - - - - - -