diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 44f1f4cb..8910a96b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -18,77 +18,65 @@ jobs: SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }} SENTRY_LOG_LEVEL: info steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/cache@v3 + - uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'yarn' + - uses: actions/cache@v4 with: path: | **/node_modules key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-modules- - - uses: cachix/install-nix-action@v22 - with: - github_access_token: ${{ secrets.BOT_GITHUB_PAT }} - - uses: cachix/cachix-action@v12 - with: - name: hacksc - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - name: Derive appropriate SHAs for base and head for `nx affected` commands uses: nrwl/nx-set-shas@v3 - - run: nix develop --command yarn install --frozen-lockfile - - run: nix develop --command yarn nx run-many --target=install --parallel - - run: nix develop --command yarn nx affected:build --parallel --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} + - run: yarn install --frozen-lockfile + - run: yarn nx affected:build --parallel --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} test: name: Test affected apps runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/cache@v3 + - uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'yarn' + - uses: actions/cache@v4 with: path: | **/node_modules key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-modules- - - uses: cachix/install-nix-action@v22 - with: - github_access_token: ${{ secrets.BOT_GITHUB_PAT }} - - uses: cachix/cachix-action@v12 - with: - name: hacksc - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - name: Derive appropriate SHAs for base and head for `nx affected` commands uses: nrwl/nx-set-shas@v3 - - run: nix develop --command yarn install --frozen-lockfile - - run: nix develop --command yarn nx run-many --target=install --parallel - - run: nix develop --command yarn nx affected:test --parallel --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} + - run: yarn install --frozen-lockfile + - run: yarn nx affected:test --parallel --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} lint: name: Lint affected apps runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 with: fetch-depth: 0 - - uses: actions/cache@v3 + - uses: actions/setup-node@v4 + with: + node-version: '18' + cache: 'yarn' + - uses: actions/cache@v4 with: path: | **/node_modules key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} restore-keys: | ${{ runner.os }}-modules- - - uses: cachix/install-nix-action@v22 - with: - github_access_token: ${{ secrets.BOT_GITHUB_PAT }} - - uses: cachix/cachix-action@v12 - with: - name: hacksc - authToken: '${{ secrets.CACHIX_AUTH_TOKEN }}' - name: Derive appropriate SHAs for base and head for `nx affected` commands uses: nrwl/nx-set-shas@v3 - - run: nix develop --command yarn install --frozen-lockfile - - run: nix develop --command yarn nx run-many --target=install --parallel - - run: nix develop --command yarn nx affected:lint --parallel --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} + - run: yarn install --frozen-lockfile + - run: yarn nx affected:lint --parallel --base=${{ env.NX_BASE }} --head=${{ env.NX_HEAD }} diff --git a/apps/podium-service/libs/calculatePoints.ts b/apps/podium-service/libs/calculatePoints.ts index 4c152adf..1ef761ff 100644 --- a/apps/podium-service/libs/calculatePoints.ts +++ b/apps/podium-service/libs/calculatePoints.ts @@ -1,3 +1,5 @@ +import { Ranking } from '../types/types'; + /* Overall rankings are calculated as follows: - Rank 1: 10 pts @@ -15,10 +17,13 @@ const calculatePoints = (rankings: Ranking[]): number => { switch (r.rank) { case 1: totalPoints += 10; + break; case 2: totalPoints += 5; + break; case 3: totalPoints += 2; + break; default: totalPoints += 1; } diff --git a/apps/podium-service/libs/calculateRankings.ts b/apps/podium-service/libs/calculateRankings.ts index 69f826aa..1f3bf603 100644 --- a/apps/podium-service/libs/calculateRankings.ts +++ b/apps/podium-service/libs/calculateRankings.ts @@ -1,5 +1,6 @@ -import { calculatePoints } from 'apps/podium-service/libs/calculatePoints'; -import { supabase } from 'apps/podium-service/libs/supabase'; +import { RankedProject, RankedProjectData } from '../types/types'; +import { calculatePoints } from './calculatePoints'; +import { supabase } from './supabase'; interface ProjectPointsData { project: RankedProject; diff --git a/apps/podium-service/libs/isLocked.ts b/apps/podium-service/libs/isLocked.ts index d46330b0..edf8dc69 100644 --- a/apps/podium-service/libs/isLocked.ts +++ b/apps/podium-service/libs/isLocked.ts @@ -1,4 +1,4 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { supabase } from './supabase'; const isLocked = async (verticalId: string): Promise => { try { diff --git a/apps/podium-service/pages/api/add_projects.ts b/apps/podium-service/pages/api/add_projects.ts index e03bfe51..e660b8b2 100644 --- a/apps/podium-service/pages/api/add_projects.ts +++ b/apps/podium-service/pages/api/add_projects.ts @@ -1,4 +1,4 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { supabase } from '../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( @@ -8,7 +8,7 @@ export default async function handler( const { method, body } = req; switch (method) { - case 'POST': + case 'POST': { const fields = [ 'name', 'teamMembers', @@ -51,12 +51,10 @@ export default async function handler( typeof p.vertical !== 'string' || typeof p.name !== 'string' ) { - return res - .status(400) - .json({ - error: - 'Invalid request! Name and vertical are required and must be strings.', - }); + return res.status(400).json({ + error: + 'Invalid request! Name and vertical are required and must be strings.', + }); } else if (!verticals?.[p.vertical]) { return res .status(400) @@ -85,6 +83,7 @@ export default async function handler( } catch (error) { return res.status(500).json({ error: 'Internal Server Error' }); } + } default: res.status(405).end(); break; diff --git a/apps/podium-service/pages/api/comments/[projectId].ts b/apps/podium-service/pages/api/comments/[projectId].ts index bad205c0..71a64ae6 100644 --- a/apps/podium-service/pages/api/comments/[projectId].ts +++ b/apps/podium-service/pages/api/comments/[projectId].ts @@ -1,4 +1,5 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { CommentData } from '../../../types/types'; +import { supabase } from '../../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( diff --git a/apps/podium-service/pages/api/comments/[projectId]/user/[userId].ts b/apps/podium-service/pages/api/comments/[projectId]/user/[userId].ts index b5ccc570..6b584902 100644 --- a/apps/podium-service/pages/api/comments/[projectId]/user/[userId].ts +++ b/apps/podium-service/pages/api/comments/[projectId]/user/[userId].ts @@ -1,4 +1,4 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { supabase } from '../../../../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( @@ -14,12 +14,9 @@ export default async function handler( try { const { comment } = body; if (!comment || typeof comment !== 'string') { - return res - .status(400) - .json({ - error: - 'Invalid request! Comment is required and must be a string.', - }); + return res.status(400).json({ + error: 'Invalid request! Comment is required and must be a string.', + }); } const { error } = await supabase.from('comments').insert({ diff --git a/apps/podium-service/pages/api/comments/id/[commentId].ts b/apps/podium-service/pages/api/comments/id/[commentId].ts index a4f4813c..c2184e70 100644 --- a/apps/podium-service/pages/api/comments/id/[commentId].ts +++ b/apps/podium-service/pages/api/comments/id/[commentId].ts @@ -1,4 +1,4 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { supabase } from '../../../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( @@ -13,12 +13,9 @@ export default async function handler( try { const { comment } = body; if (!comment || typeof comment !== 'string') { - return res - .status(400) - .json({ - error: - 'Invalid request! Comment is required and must be a string.', - }); + return res.status(400).json({ + error: 'Invalid request! Comment is required and must be a string.', + }); } const { error } = await supabase diff --git a/apps/podium-service/pages/api/judges.ts b/apps/podium-service/pages/api/judges.ts index 01a0d365..0279158a 100644 --- a/apps/podium-service/pages/api/judges.ts +++ b/apps/podium-service/pages/api/judges.ts @@ -1,4 +1,5 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { JudgeData } from '../../types/types'; +import { supabase } from '../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( diff --git a/apps/podium-service/pages/api/judges/[judgeId].ts b/apps/podium-service/pages/api/judges/[judgeId].ts index 4a7058da..57f69dba 100644 --- a/apps/podium-service/pages/api/judges/[judgeId].ts +++ b/apps/podium-service/pages/api/judges/[judgeId].ts @@ -1,4 +1,4 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { supabase } from '../../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( @@ -38,12 +38,10 @@ export default async function handler( try { const { verticalId } = body; if (!verticalId || typeof verticalId !== 'string') { - return res - .status(400) - .json({ - error: - 'Invalid request! Vertical ID is required and must be a string.', - }); + return res.status(400).json({ + error: + 'Invalid request! Vertical ID is required and must be a string.', + }); } const { error } = await supabase diff --git a/apps/podium-service/pages/api/lock/[verticalId].ts b/apps/podium-service/pages/api/lock/[verticalId].ts index ac93eb11..1e11e4fc 100644 --- a/apps/podium-service/pages/api/lock/[verticalId].ts +++ b/apps/podium-service/pages/api/lock/[verticalId].ts @@ -1,5 +1,5 @@ -import { calculateRankings } from 'apps/podium-service/libs/calculateRankings'; -import { supabase } from 'apps/podium-service/libs/supabase'; +import { calculateRankings } from '../../../libs/calculateRankings'; +import { supabase } from '../../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( diff --git a/apps/podium-service/pages/api/notes/[verticalId]/[projectId]/[userId].ts b/apps/podium-service/pages/api/notes/[verticalId]/[projectId]/[userId].ts index 7dc0231d..c871aff8 100644 --- a/apps/podium-service/pages/api/notes/[verticalId]/[projectId]/[userId].ts +++ b/apps/podium-service/pages/api/notes/[verticalId]/[projectId]/[userId].ts @@ -1,4 +1,5 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { NotesData } from '../../../../../types/types'; +import { supabase } from '../../../../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( @@ -37,12 +38,9 @@ export default async function handler( try { const { notes } = body; if (!notes || typeof notes !== 'string') { - return res - .status(400) - .json({ - error: - 'Invalid request! Notes are required and must be a string.', - }); + return res.status(400).json({ + error: 'Invalid request! Notes are required and must be a string.', + }); } const { error } = await supabase.from('notes').insert({ diff --git a/apps/podium-service/pages/api/projects.ts b/apps/podium-service/pages/api/projects.ts index f731bbbd..115b204a 100644 --- a/apps/podium-service/pages/api/projects.ts +++ b/apps/podium-service/pages/api/projects.ts @@ -1,4 +1,4 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { supabase } from '../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( diff --git a/apps/podium-service/pages/api/projects/[verticalId].ts b/apps/podium-service/pages/api/projects/[verticalId].ts index 8aca10b1..75178e63 100644 --- a/apps/podium-service/pages/api/projects/[verticalId].ts +++ b/apps/podium-service/pages/api/projects/[verticalId].ts @@ -1,4 +1,4 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { supabase } from '../../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( @@ -40,7 +40,7 @@ export default async function handler( } catch (error) { return res.status(500).json({ error: 'Internal Server Error' }); } - case 'POST': + case 'POST': { const fields = [ 'name', 'teamMembers', @@ -87,6 +87,7 @@ export default async function handler( } catch (error) { return res.status(500).json({ error: 'Internal Server Error' }); } + } default: res.status(405).end(); break; diff --git a/apps/podium-service/pages/api/projects/[verticalId]/[projectId].ts b/apps/podium-service/pages/api/projects/[verticalId]/[projectId].ts index 66f9e68e..23fb888e 100644 --- a/apps/podium-service/pages/api/projects/[verticalId]/[projectId].ts +++ b/apps/podium-service/pages/api/projects/[verticalId]/[projectId].ts @@ -1,4 +1,5 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { EditableProjectData, ProjectData } from '../../../../types/types'; +import { supabase } from '../../../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( @@ -32,7 +33,7 @@ export default async function handler( } catch (error) { return res.status(500).json({ error: 'Internal Server Error' }); } - case 'PUT': + case 'PUT': { const fields = [ 'name', 'teamMembers', @@ -86,6 +87,7 @@ export default async function handler( } catch (error) { return res.status(500).json({ error: 'Internal Server Error' }); } + } case 'DELETE': try { const { error } = await supabase diff --git a/apps/podium-service/pages/api/ranking.ts b/apps/podium-service/pages/api/ranking.ts index 33c80b76..3658157b 100644 --- a/apps/podium-service/pages/api/ranking.ts +++ b/apps/podium-service/pages/api/ranking.ts @@ -1,4 +1,4 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { supabase } from '../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( diff --git a/apps/podium-service/pages/api/ranking/[verticalId].ts b/apps/podium-service/pages/api/ranking/[verticalId].ts index e11d2df2..3ed42d0b 100644 --- a/apps/podium-service/pages/api/ranking/[verticalId].ts +++ b/apps/podium-service/pages/api/ranking/[verticalId].ts @@ -1,6 +1,6 @@ -import { calculateRankings } from 'apps/podium-service/libs/calculateRankings'; -import { isLocked } from 'apps/podium-service/libs/isLocked'; -import { supabase } from 'apps/podium-service/libs/supabase'; +import { calculateRankings } from '../../../libs/calculateRankings'; +import { isLocked } from '../../../libs/isLocked'; +import { supabase } from '../../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( diff --git a/apps/podium-service/pages/api/ranking/[verticalId]/[userId].ts b/apps/podium-service/pages/api/ranking/[verticalId]/[userId].ts index c7d1c571..bdb85b29 100644 --- a/apps/podium-service/pages/api/ranking/[verticalId]/[userId].ts +++ b/apps/podium-service/pages/api/ranking/[verticalId]/[userId].ts @@ -1,4 +1,4 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { supabase } from '../../../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( diff --git a/apps/podium-service/pages/api/verticals.ts b/apps/podium-service/pages/api/verticals.ts index fa7d31b8..13b443be 100644 --- a/apps/podium-service/pages/api/verticals.ts +++ b/apps/podium-service/pages/api/verticals.ts @@ -1,4 +1,4 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { supabase } from '../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( @@ -34,11 +34,9 @@ export default async function handler( try { const { name, description } = body; if (!name || typeof name !== 'string') { - return res - .status(400) - .json({ - error: 'Invalid request! Name is required and must be a string.', - }); + return res.status(400).json({ + error: 'Invalid request! Name is required and must be a string.', + }); } const { error } = await supabase diff --git a/apps/podium-service/pages/api/verticals/[verticalId].ts b/apps/podium-service/pages/api/verticals/[verticalId].ts index 5792104e..24013934 100644 --- a/apps/podium-service/pages/api/verticals/[verticalId].ts +++ b/apps/podium-service/pages/api/verticals/[verticalId].ts @@ -1,4 +1,4 @@ -import { supabase } from 'apps/podium-service/libs/supabase'; +import { supabase } from '../../../libs/supabase'; import { NextApiRequest, NextApiResponse } from 'next'; export default async function handler( @@ -10,7 +10,7 @@ export default async function handler( const projectId = query.projectId as string; switch (method) { - case 'PUT': + case 'PUT': { const fields = ['name', 'description']; const updateVertical = {}; @@ -36,6 +36,7 @@ export default async function handler( } catch (error) { return res.status(500).json({ error: 'Internal Server Error' }); } + } default: res.status(405).end(); break; diff --git a/apps/podium-service/public/.gitkeep b/apps/podium-service/public/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/apps/podium-service/types/types.ts b/apps/podium-service/types/types.ts index b00eb465..b23515c1 100644 --- a/apps/podium-service/types/types.ts +++ b/apps/podium-service/types/types.ts @@ -1,10 +1,10 @@ -interface VerticalData { +export interface VerticalData { verticalId: string; name: string; description: string | null; } -interface ProjectData { +export interface ProjectData { projectId: string; name: string; teamMembers: string[] | null; @@ -16,15 +16,15 @@ interface ProjectData { verticalName: string; } -interface EditableProjectData extends ProjectData { +export interface EditableProjectData extends ProjectData { verticalNew: string; } -interface Ranking { +export interface Ranking { rank: number; } -interface RankedProject { +export interface RankedProject { projectId: string; projectName: string; verticalId: string; @@ -32,11 +32,11 @@ interface RankedProject { rankings: Ranking[]; } -interface RankedProjectData extends Omit { +export interface RankedProjectData extends Omit { rank: number; } -interface JudgeData { +export interface JudgeData { id: string; name: string; email: string; @@ -44,13 +44,13 @@ interface JudgeData { verticalName: string | null; } -interface CommentData { +export interface CommentData { comment: string; name: string; profilePicUrl: string; createdAt: Date; } -interface NotesData { +export interface NotesData { notes: string; }