Skip to content
Open
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
60 changes: 24 additions & 36 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
5 changes: 5 additions & 0 deletions apps/podium-service/libs/calculatePoints.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import { Ranking } from '../types/types';

/*
Overall rankings are calculated as follows:
- Rank 1: 10 pts
Expand All @@ -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;
}
Expand Down
5 changes: 3 additions & 2 deletions apps/podium-service/libs/calculateRankings.ts
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
2 changes: 1 addition & 1 deletion apps/podium-service/libs/isLocked.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { supabase } from 'apps/podium-service/libs/supabase';
import { supabase } from './supabase';

const isLocked = async (verticalId: string): Promise<boolean> => {
try {
Expand Down
15 changes: 7 additions & 8 deletions apps/podium-service/pages/api/add_projects.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -8,7 +8,7 @@ export default async function handler(
const { method, body } = req;

switch (method) {
case 'POST':
case 'POST': {
const fields = [
'name',
'teamMembers',
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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;
Expand Down
3 changes: 2 additions & 1 deletion apps/podium-service/pages/api/comments/[projectId].ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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({
Expand Down
11 changes: 4 additions & 7 deletions apps/podium-service/pages/api/comments/id/[commentId].ts
Original file line number Diff line number Diff line change
@@ -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(
Expand All @@ -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
Expand Down
3 changes: 2 additions & 1 deletion apps/podium-service/pages/api/judges.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
12 changes: 5 additions & 7 deletions apps/podium-service/pages/api/judges/[judgeId].ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions apps/podium-service/pages/api/lock/[verticalId].ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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({
Expand Down
2 changes: 1 addition & 1 deletion apps/podium-service/pages/api/projects.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
5 changes: 3 additions & 2 deletions apps/podium-service/pages/api/projects/[verticalId].ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion apps/podium-service/pages/api/ranking.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
6 changes: 3 additions & 3 deletions apps/podium-service/pages/api/ranking/[verticalId].ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
Original file line number Diff line number Diff line change
@@ -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(
Expand Down
10 changes: 4 additions & 6 deletions apps/podium-service/pages/api/verticals.ts
Original file line number Diff line number Diff line change
@@ -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(
Expand Down Expand Up @@ -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
Expand Down
Loading