Skip to content

Commit

Permalink
Merge branch 'main' into 1495-implement-image-upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Jaehyeon1020 committed May 5, 2024
2 parents 06e1cbd + 9fe4048 commit dbc5dfc
Show file tree
Hide file tree
Showing 48 changed files with 13,336 additions and 10,642 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion .envrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
set -a
source .env.development
source .env.stage
set +a
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@ node_modules
@generated
collection
.next
.eslintrc.js
*.config.js
1 change: 1 addition & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ module.exports = {
root: true,
parser: '@typescript-eslint/parser',
parserOptions: {
project: true,
emitDecoratorMetadata: true,
ecmaFeatures: {
jsx: true
Expand Down
2 changes: 0 additions & 2 deletions .github/actions/setup-pnpm/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ runs:
using: 'composite'
steps:
- uses: pnpm/action-setup@v3
with:
version: latest
- uses: actions/setup-node@v4
with:
node-version: 20
Expand Down
12 changes: 6 additions & 6 deletions .github/workflows/cd-dev.yml → .github/workflows/cd-stage.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: CD - Development
name: CD - Stage

on:
push:
Expand Down Expand Up @@ -76,18 +76,18 @@ jobs:
tags: ghcr.io/${{ github.repository_owner }}/codedang-iris:latest

run-server:
name: Run development server
name: Run stage server
runs-on: self-hosted
needs: [build-client-api, build-admin-api, build-iris]
environment: development
environment: stage
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
sparse-checkout: |
docker-compose.yml
scripts/deploy.sh
.env.development
.env.stage
apps/infra/stage/Caddyfile
grafana-logs/promtail/promtail-config.yml
Expand Down Expand Up @@ -143,8 +143,8 @@ jobs:

- name: Run Bruno Collection (Client)
working-directory: ./collection/client
run: bru run --env development
run: bru run --env stage

- name: Run Bruno Collection (Admin)
working-directory: ./collection/admin
run: bru run --env development
run: bru run --env stage
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ jobs:
- name: Load Next.js environment
if: ${{ matrix.target == 'frontend' }}
run: |
echo "NEXT_PUBLIC_BASEURL=https://dev-aws.codedang.com/api" >> apps/frontend/.env
echo "NEXT_PUBLIC_GQL_BASEURL=https://dev-aws.codedang.com/graphql" >> apps/frontend/.env
echo "NEXT_URL=https://dev.codedang.com" >> apps/frontend/.env
echo "NEXT_PUBLIC_BASEURL=https://stage.codedang.com/api" >> apps/frontend/.env
echo "NEXT_PUBLIC_GQL_BASEURL=https://stage.codedang.com/graphql" >> apps/frontend/.env
echo "NEXT_URL=https://stage.codedang.com" >> apps/frontend/.env
- name: Build (backend admin)
if: ${{ matrix.target == 'backend-admin' }}
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/reset-seed.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Reset Seed (Development)
name: Reset Seed (Stage)

on: workflow_dispatch

Expand All @@ -7,8 +7,8 @@ jobs:
name: Reset Seed
runs-on: self-hosted
steps:
- name: Load DATABASE_URL From Existing .env.development
run: export DATABASE_URL=$(grep "^DATABASE_URL=" .env.development | cut -d '=' -f2)
- name: Load DATABASE_URL From Existing .env.stage
run: export DATABASE_URL=$(grep "^DATABASE_URL=" .env.stage | cut -d '=' -f2)

- name: Run Reset Seed Command
run: docker exec backend-client npx prisma migrate reset -f
Expand Down
9 changes: 9 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ dist/
.env.test.local
.env.production.local
.env.local
.env.stage.local

# Ignore all local history of files
.history
Expand Down Expand Up @@ -133,3 +134,11 @@ go.work

# PEM-encoded certificate data
*.pem

# nyc files
.nyc_output
coverage

*.pkg


1 change: 1 addition & 0 deletions .npmrc
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
auto-install-peers=true
package-import-method=clone-or-copy
package-manager-strict=false
2 changes: 1 addition & 1 deletion apollo.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module.exports = {
excludes: ['**/__generated__/**'],
service: {
name: 'codedang-graphql-app',
url: 'https://dev.codedang.com/graphql'
url: 'https://stage.codedang.com/graphql'
}
}
}
8 changes: 8 additions & 0 deletions apps/backend/.nycrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"extends": "@istanbuljs/nyc-config-typescript",
"all": true,
"check-coverage": true,
"include": ["{apps,libs}/**/*.{service,resolver}.ts"],
"exclude": ["**/*.spec.ts"],
"reporter": ["lcov", "text"]
}
4 changes: 2 additions & 2 deletions apps/backend/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
### BUILDER ###
ARG target=client

FROM node:20-alpine AS builder
FROM node:20.12.2-alpine AS builder
ARG target

COPY . /build
Expand All @@ -18,7 +18,7 @@ RUN npx prisma generate
RUN npm run build ${target}

### PRODUCTION ###
FROM node:20-alpine
FROM node:20.12.2-alpine
ARG target

ENV NODE_ENV=production
Expand Down
24 changes: 17 additions & 7 deletions apps/backend/apps/client/src/submission/submission.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -641,15 +641,25 @@ export class SubmissionService implements OnModuleInit {
}): Promise<Partial<Submission>[]> {
const paginator = this.prisma.getPaginator(cursor)

await this.prisma.contestRecord.findUniqueOrThrow({
const isAdmin = await this.prisma.user.findFirst({
where: {
// eslint-disable-next-line @typescript-eslint/naming-convention
contestId_userId: {
contestId,
userId
}
id: userId,
role: 'Admin'
}
})

if (!isAdmin) {
await this.prisma.contestRecord.findUniqueOrThrow({
where: {
// eslint-disable-next-line @typescript-eslint/naming-convention
contestId_userId: {
contestId,
userId
}
}
})
}

await this.prisma.contestProblem.findFirstOrThrow({
where: {
problem: {
Expand All @@ -666,7 +676,7 @@ export class SubmissionService implements OnModuleInit {
where: {
problemId,
contestId,
userId
userId: isAdmin ? undefined : userId // Admin 계정인 경우 자신이 생성한 submission이 아니더라도 조회가 가능
},
select: {
id: true,
Expand Down
3 changes: 2 additions & 1 deletion apps/backend/libs/logger/src/pino-option.logger.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ export const pinoLoggerModuleOption: Params = {
req.body = req.raw?.body
return req
}
}
},
redact: ['req.body.password']
}
}
72 changes: 38 additions & 34 deletions apps/backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,51 +13,52 @@
"test": "pnpm run pretest && cross-env DATABASE_URL=$TEST_DATABASE_URL mocha \"*/**/*.spec.ts\"",
"test:watch": "pnpm run pretest && cross-env DATABASE_URL=$TEST_DATABASE_URL mocha --watch \"*/**/*.spec.ts\"",
"test:debug": "pnpm run pretest && cross-env DATABASE_URL=$TEST_DATABASE_URL mocha --inspect \"*/**/*.spec.ts\"",
"test:coverage": "nyc npm run test",
"studio": "npx prisma studio",
"studio:test": "cross-env DATABASE_URL=$TEST_DATABASE_URL npx prisma studio"
},
"dependencies": {
"@apollo/server": "^4.10.2",
"@aws-sdk/client-s3": "^3.540.0",
"@aws-sdk/client-ses": "^3.540.0",
"@aws-sdk/credential-provider-node": "^3.540.0",
"@golevelup/nestjs-rabbitmq": "^5.1.0",
"@apollo/server": "^4.10.4",
"@aws-sdk/client-s3": "^3.567.0",
"@aws-sdk/client-ses": "^3.567.0",
"@aws-sdk/credential-provider-node": "^3.567.0",
"@golevelup/nestjs-rabbitmq": "^5.3.0",
"@nestjs-modules/mailer": "^1.11.2",
"@nestjs/apollo": "^12.1.0",
"@nestjs/axios": "^3.0.2",
"@nestjs/cache-manager": "^2.2.2",
"@nestjs/common": "^10.3.5",
"@nestjs/config": "^3.2.1",
"@nestjs/core": "^10.3.5",
"@nestjs/common": "^10.3.8",
"@nestjs/config": "^3.2.2",
"@nestjs/core": "^10.3.8",
"@nestjs/graphql": "^12.1.1",
"@nestjs/jwt": "^10.2.0",
"@nestjs/passport": "^10.0.3",
"@nestjs/platform-express": "^10.3.5",
"@nestjs/swagger": "^7.3.0",
"@nestjs/platform-express": "^10.3.8",
"@nestjs/swagger": "^7.3.1",
"@opentelemetry/api": "~1.8.0",
"@opentelemetry/exporter-metrics-otlp-http": "^0.49.1",
"@opentelemetry/exporter-trace-otlp-http": "^0.49.1",
"@opentelemetry/host-metrics": "^0.35.0",
"@opentelemetry/instrumentation-express": "^0.36.1",
"@opentelemetry/instrumentation-http": "^0.49.1",
"@opentelemetry/resources": "^1.22.0",
"@opentelemetry/sdk-metrics": "^1.22.0",
"@opentelemetry/sdk-node": "^0.49.1",
"@opentelemetry/sdk-trace-node": "^1.22.0",
"@opentelemetry/semantic-conventions": "^1.22.0",
"@prisma/client": "^5.11.0",
"@prisma/instrumentation": "~5.11.0",
"@opentelemetry/exporter-metrics-otlp-http": "^0.51.0",
"@opentelemetry/exporter-trace-otlp-http": "^0.51.0",
"@opentelemetry/host-metrics": "^0.35.1",
"@opentelemetry/instrumentation-express": "^0.38.0",
"@opentelemetry/instrumentation-http": "^0.51.0",
"@opentelemetry/resources": "^1.24.0",
"@opentelemetry/sdk-metrics": "^1.24.0",
"@opentelemetry/sdk-node": "^0.51.0",
"@opentelemetry/sdk-trace-node": "^1.24.0",
"@opentelemetry/semantic-conventions": "^1.24.0",
"@prisma/client": "^5.13.0",
"@prisma/instrumentation": "~5.13.0",
"argon2": "^0.40.1",
"axios": "^1.6.8",
"cache-manager": "^5.4.0",
"cache-manager-redis-yet": "^4.2.0",
"cache-manager": "^5.5.2",
"cache-manager-redis-yet": "^5.0.0",
"chai-exclude": "^2.1.0",
"class-transformer": "^0.5.1",
"class-validator": "^0.14.1",
"colorette": "^2.0.20",
"cookie-parser": "^1.4.6",
"cross-env": "^7.0.3",
"dayjs": "^1.11.10",
"dayjs": "^1.11.11",
"exceljs": "^4.4.0",
"generate-password": "^1.7.1",
"graphql": "^16.8.1",
Expand All @@ -74,36 +75,39 @@
"pino-http": "^9.0.0",
"pino-pretty": "^11.0.0",
"reflect-metadata": "^0.2.1",
"sql-formatter": "^15.3.0",
"zod": "^3.22.4"
"sql-formatter": "^15.3.1",
"zod": "^3.23.5"
},
"devDependencies": {
"@faker-js/faker": "^8.4.1",
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@nestjs/cli": "^10.3.2",
"@nestjs/schematics": "^10.1.1",
"@nestjs/testing": "^10.3.5",
"@nestjs/testing": "^10.3.8",
"@types/cache-manager": "^4.0.6",
"@types/chai": "^4.3.14",
"@types/chai": "^4.3.15",
"@types/chai-as-promised": "^7.1.8",
"@types/express": "^4.17.21",
"@types/graphql-upload": "8.0.12",
"@types/mocha": "^10.0.6",
"@types/node": "^20.11.30",
"@types/nodemailer": "^6.4.14",
"@types/node": "^20.12.8",
"@types/nodemailer": "^6.4.15",
"@types/passport-jwt": "^4.0.1",
"@types/proxyquire": "^1.3.31",
"@types/sinon": "^17.0.3",
"chai": "^4.4.1",
"chai-as-promised": "^7.1.1",
"mocha": "^10.3.0",
"prisma": "^5.11.0",
"mocha": "^10.4.0",
"nyc": "^15.1.0",
"prisma": "^5.13.0",
"prisma-nestjs-graphql": "^20.0.2",
"proxyquire": "^2.1.3",
"sinon": "^17.0.1",
"source-map-support": "^0.5.21",
"ts-loader": "^9.5.1",
"ts-node": "^10.9.2",
"tsconfig-paths": "^4.2.0",
"typescript": "^5.4.3"
"typescript": "^5.4.5"
},
"prisma": {
"seed": "ts-node prisma/seed.ts"
Expand Down
4 changes: 2 additions & 2 deletions apps/frontend/app/(main)/_components/Footer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import { IoIosLink } from 'react-icons/io'
import { RiGithubFill } from 'react-icons/ri'
import { RiKakaoTalkFill } from 'react-icons/ri'
import { TbMailFilled } from 'react-icons/tb'
import { TbMail } from 'react-icons/tb'
import { toast } from 'sonner'

export default function Footer() {
Expand Down Expand Up @@ -33,7 +33,7 @@ export default function Footer() {
size="27"
/>
</a>
<TbMailFilled
<TbMail
onClick={copyToClipboard}
className="cursor-pointer hover:text-gray-500"
size="27"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,8 @@ export default async function Contest({
contest.status.toLowerCase() === type.toLowerCase()
)

data.sort((a, b) => +new Date(a.startTime) - +new Date(b.startTime))

const contestChunks = []
for (let i = 0; i < data.length; i += 3)
contestChunks.push(data.slice(i, i + 3))
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/app/admin/problem/[id]/edit/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ const UPDATE_PROBLEM = gql(`

const schema = z.object({
id: z.number(),
title: z.string().min(1).max(25),
title: z.string().min(1).max(200),
isVisible: z.boolean(),
difficulty: z.enum(levels),
languages: z.array(z.enum(languages)),
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/app/admin/problem/create/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ const CREATE_PROBLEM = gql(`
`)

const schema = z.object({
title: z.string().min(1).max(25),
title: z.string().min(1).max(200),
isVisible: z.boolean(),
difficulty: z.enum(levels),
languages: z.array(z.enum(languages)),
Expand Down
2 changes: 1 addition & 1 deletion apps/frontend/codegen.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { CodegenConfig } from '@graphql-codegen/cli'

const config: CodegenConfig = {
schema:
process.env.NEXT_PUBLIC_GQL_BASEURL ?? 'https://dev.codedang.com/graphql',
process.env.NEXT_PUBLIC_GQL_BASEURL ?? 'https://stage.codedang.com/graphql',
// this assumes that all your source files are in a top-level `src/` directory - you might need to adjust this to your file structure
documents: ['./**/*.{ts,tsx}'],
generates: {
Expand Down
Loading

0 comments on commit dbc5dfc

Please sign in to comment.