Skip to content

Commit

Permalink
Merge pull request #341 from boostcampwm2023/BE-develop
Browse files Browse the repository at this point in the history
merge
  • Loading branch information
Conut-1 authored Aug 28, 2024
2 parents f453bf8 + b163cc3 commit 2c6fdde
Show file tree
Hide file tree
Showing 74 changed files with 1,899 additions and 1,083 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/BE-deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ name: BE-deploy
on:
push:
branches:
- "BE-develop"
- "release"
paths:
- "nestjs-BE/**"
jobs:
build:
runs-on: ubuntu-latest
Expand All @@ -29,7 +31,6 @@ jobs:
echo "BASE_IMAGE_URL=$BASE_IMAGE_URL" >> ./nestjs-BE/server/.env
echo "BUCKET_NAME=$BUCKET_NAME" >> ./nestjs-BE/server/.env
echo "APP_ICON_URL=$APP_ICON_URL" >> ./nestjs-BE/server/.env
echo "CSV_FOLDER=$CSV_FOLDER" >> ./nestjs-BE/server/.env
docker build -t ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync ./nestjs-BE/server
docker push ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync:latest
env:
Expand All @@ -47,7 +48,6 @@ jobs:
BASE_IMAGE_URL: ${{ secrets.BASE_IMAGE_URL }}
BUCKET_NAME: ${{ secrets.BUCKET_NAME }}
APP_ICON_URL: ${{ secrets.APP_ICON_URL }}
CSV_FOLDER: ${{ secrets.CSV_FOLDER }}

deploy:
needs: build
Expand All @@ -61,12 +61,12 @@ jobs:
username: ${{ secrets.REMOTE_USER }}
key: ${{ secrets.REMOTE_SSH_KEY }}
script: |
echo ${{ secrets.PACKAGE_ACCESS_TOKEN }} | docker login ghcr.io -u ${{ secrets.PACKAGE_USERNAME }} --password-stdin
docker pull ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync
docker stop mindsync_server || true
docker rm mindsync_server || true
docker run -d \
echo ${{ secrets.PACKAGE_ACCESS_TOKEN }} | sudo docker login ghcr.io -u ${{ secrets.PACKAGE_USERNAME }} --password-stdin
sudo docker pull ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync
sudo docker stop mindsync_server || true
sudo docker rm mindsync_server || true
sudo docker run -d \
--name mindsync_server \
-p ${{ secrets.SERVER_PORT }}:${{ secrets.CONTAINER_PORT }} \
-v temporary-volume:${{ secrets.CSV_FOLDER }} \
--net mybridge \
ghcr.io/${{ secrets.PACKAGE_USERNAME }}/mindsync
3 changes: 1 addition & 2 deletions nestjs-BE/server/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ module.exports = {
'@typescript-eslint/no-explicit-any': 'off',
'max-depth': ['error', 3],
'no-magic-numbers': ['error', { ignore: [-1, 0, 1] }],
'curly': ['error', 'multi-line', 'consistent'],
'max-params': ['error', 3],
curly: ['error', 'multi-line', 'consistent'],
},
};
4 changes: 0 additions & 4 deletions nestjs-BE/server/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,3 @@ lerna-debug.log*

# Environment Variable File
.env

# csv, prisma
/operations
/prisma/generated
10 changes: 5 additions & 5 deletions nestjs-BE/server/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,16 @@ FROM node:20.4.0-alpine

WORKDIR /server

ENV NODE_OPTIONS="--max-old-space-size=2048"

COPY package.json package-lock.json ./

RUN npm ci

COPY ./ ./

RUN npx prisma generate --schema=./prisma/mysql.schema.prisma

RUN npx prisma generate --schema=./prisma/mongodb.schema.prisma

EXPOSE 3000

CMD ["npm", "start"]
RUN chmod +x ./entrypoint.sh

ENTRYPOINT ["./entrypoint.sh"]
3 changes: 3 additions & 0 deletions nestjs-BE/server/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/bin/sh
npx prisma migrate deploy
npm start
28 changes: 28 additions & 0 deletions nestjs-BE/server/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions nestjs-BE/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"eslint-config-prettier": "^9.0.0",
"eslint-plugin-prettier": "^5.0.0",
"jest": "^29.5.0",
"jest-mock-extended": "^3.0.7",
"prettier": "^3.0.0",
"prisma": "^5.6.0",
"source-map-support": "^0.5.21",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,9 @@ CREATE TABLE `USER_TB` (
-- CreateTable
CREATE TABLE `REFRESH_TOKEN_TB` (
`uuid` VARCHAR(32) NOT NULL,
`token` VARCHAR(191) NOT NULL,
`expiry_date` DATETIME(3) NOT NULL,
`user_id` VARCHAR(191) NOT NULL,

UNIQUE INDEX `REFRESH_TOKEN_TB_token_key`(`token`),
PRIMARY KEY (`uuid`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

Expand Down Expand Up @@ -44,7 +42,7 @@ CREATE TABLE `PROFILE_SPACE_TB` (
`space_uuid` VARCHAR(32) NOT NULL,
`profile_uuid` VARCHAR(32) NOT NULL,

PRIMARY KEY (`space_uuid`, `profile_uuid`)
UNIQUE INDEX `PROFILE_SPACE_TB_space_uuid_profile_uuid_key`(`space_uuid`, `profile_uuid`)
) DEFAULT CHARACTER SET utf8mb4 COLLATE utf8mb4_unicode_ci;

-- CreateTable
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
Warnings:
- You are about to alter the column `nickname` on the `PROFILE_TB` table. The data in that column could be lost. The data in that column will be cast from `VarChar(191)` to `VarChar(20)`.
- You are about to alter the column `name` on the `SPACE_TB` table. The data in that column could be lost. The data in that column will be cast from `VarChar(191)` to `VarChar(20)`.
*/
-- AlterTable
ALTER TABLE `PROFILE_TB` MODIFY `nickname` VARCHAR(20) NOT NULL;

-- AlterTable
ALTER TABLE `SPACE_TB` MODIFY `name` VARCHAR(20) NOT NULL;
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
-- RenameIndex
ALTER TABLE `USER_TB` RENAME INDEX `USER_TB_email_provider_key` TO `User_email_provider_key`;

-- RenameTable
ALTER TABLE `USER_TB` RENAME `User`;
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
-- DropForeignKey
ALTER TABLE `PROFILE_TB` DROP FOREIGN KEY `PROFILE_TB_user_id_fkey`;

-- RenameIndex
ALTER TABLE `PROFILE_TB` RENAME INDEX `PROFILE_TB_user_id_key` TO `Profile_user_id_key`;

-- RenameTable
ALTER TABLE `PROFILE_TB` RENAME `Profile`;

-- AddForeignKey
ALTER TABLE `Profile` ADD CONSTRAINT `Profile_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `User`(`uuid`) ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
-- DropForeignKey
ALTER TABLE `INVITE_CODE_TB` DROP FOREIGN KEY `INVITE_CODE_TB_space_uuid_fkey`;

-- DropForeignKey
ALTER TABLE `PROFILE_SPACE_TB` DROP FOREIGN KEY `PROFILE_SPACE_TB_profile_uuid_fkey`;

-- DropForeignKey
ALTER TABLE `PROFILE_SPACE_TB` DROP FOREIGN KEY `PROFILE_SPACE_TB_space_uuid_fkey`;

-- RenameIndex
ALTER TABLE `PROFILE_SPACE_TB` RENAME INDEX `PROFILE_SPACE_TB_space_uuid_profile_uuid_key` TO `Profile_space_space_uuid_profile_uuid_key`;

-- RenameTable
ALTER TABLE `PROFILE_SPACE_TB` RENAME `Profile_space`;

-- RenameTable
ALTER TABLE `SPACE_TB` RENAME `Space`;

-- AddForeignKey
ALTER TABLE `Profile_space` ADD CONSTRAINT `Profile_space_space_uuid_fkey` FOREIGN KEY (`space_uuid`) REFERENCES `Space`(`uuid`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `Profile_space` ADD CONSTRAINT `Profile_space_profile_uuid_fkey` FOREIGN KEY (`profile_uuid`) REFERENCES `Profile`(`uuid`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `INVITE_CODE_TB` ADD CONSTRAINT `INVITE_CODE_TB_space_uuid_fkey` FOREIGN KEY (`space_uuid`) REFERENCES `Space`(`uuid`) ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
-- DropForeignKey
ALTER TABLE `INVITE_CODE_TB` DROP FOREIGN KEY `INVITE_CODE_TB_space_uuid_fkey`;

-- DropForeignKey
ALTER TABLE `REFRESH_TOKEN_TB` DROP FOREIGN KEY `REFRESH_TOKEN_TB_user_id_fkey`;

-- RenameIndex
ALTER TABLE `INVITE_CODE_TB` RENAME INDEX `INVITE_CODE_TB_invite_code_key` TO `InviteCode_invite_code_key`;

-- RenameTable
ALTER TABLE `INVITE_CODE_TB` RENAME `InviteCode`;

-- RenameTable
ALTER TABLE `REFRESH_TOKEN_TB` RENAME `RefreshToken`;

-- AddForeignKey
ALTER TABLE `RefreshToken` ADD CONSTRAINT `RefreshToken_user_id_fkey` FOREIGN KEY (`user_id`) REFERENCES `User`(`uuid`) ON DELETE CASCADE ON UPDATE CASCADE;

-- AddForeignKey
ALTER TABLE `InviteCode` ADD CONSTRAINT `InviteCode_space_uuid_fkey` FOREIGN KEY (`space_uuid`) REFERENCES `Space`(`uuid`) ON DELETE CASCADE ON UPDATE CASCADE;
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/*
Warnings:
- The primary key for the `RefreshToken` table will be changed. If it partially fails, the table could be left without primary key constraint.
- Added the required column `id` to the `RefreshToken` table without a default value. This is not possible if the table is not empty.
*/
-- AlterTable
ALTER TABLE `RefreshToken` DROP PRIMARY KEY,
ADD COLUMN `id` INTEGER NOT NULL AUTO_INCREMENT,
RENAME COLUMN `uuid` TO `token`,
ADD PRIMARY KEY (`id`);

ALTER TABLE `RefreshToken` MODIFY `token` VARCHAR(210) NOT NULL;

-- CreateIndex
CREATE INDEX `RefreshToken_token_idx` ON `RefreshToken`(`token`);
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
Warnings:
- A unique constraint covering the columns `[token]` on the table `RefreshToken` will be added. If there are existing duplicate values, this will fail.
*/
-- DropIndex
DROP INDEX `RefreshToken_token_idx` ON `RefreshToken`;

-- CreateIndex
CREATE UNIQUE INDEX `RefreshToken_token_key` ON `RefreshToken`(`token`);
14 changes: 0 additions & 14 deletions nestjs-BE/server/prisma/mongodb.schema.prisma

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,60 +1,59 @@
generator client {
provider = "prisma-client-js"
output = "./generated/mysql"
}

datasource db {
provider = "mysql"
url = env("MYSQL_DATABASE_URL")
}

model USER_TB {
model User {
uuid String @id @db.VarChar(32)
email String
provider String
profiles PROFILE_TB[]
refresh_tokens REFRESH_TOKEN_TB[]
profiles Profile[]
refresh_tokens RefreshToken[]
@@unique([email, provider])
}

model REFRESH_TOKEN_TB {
uuid String @id @db.VarChar(32)
token String @unique
model RefreshToken {
id Int @id @default(autoincrement())
token String @db.VarChar(210)
expiry_date DateTime
user_id String
user USER_TB @relation(fields: [user_id], references: [uuid], onDelete: Cascade)
user User @relation(fields: [user_id], references: [uuid], onDelete: Cascade)
@@unique([token])
}

model PROFILE_TB {
model Profile {
uuid String @id @db.VarChar(32)
user_id String @unique @db.VarChar(32)
image String
nickname String
user USER_TB @relation(fields: [user_id], references: [uuid], onDelete: Cascade)
spaces PROFILE_SPACE_TB[]
nickname String @db.VarChar(20)
user User @relation(fields: [user_id], references: [uuid], onDelete: Cascade)
spaces Profile_space[]
}

model SPACE_TB {
model Space {
uuid String @id @db.VarChar(32)
name String
name String @db.VarChar(20)
icon String
profiles PROFILE_SPACE_TB[]
invite_codes INVITE_CODE_TB[]
profiles Profile_space[]
invite_codes InviteCode[]
}

model PROFILE_SPACE_TB {
model Profile_space {
space_uuid String @db.VarChar(32)
profile_uuid String @db.VarChar(32)
space SPACE_TB @relation(fields: [space_uuid], references: [uuid], onDelete: Cascade)
profile PROFILE_TB @relation(fields: [profile_uuid], references: [uuid], onDelete: Cascade)
space Space @relation(fields: [space_uuid], references: [uuid], onDelete: Cascade)
profile Profile @relation(fields: [profile_uuid], references: [uuid], onDelete: Cascade)
@@unique([space_uuid, profile_uuid])
}

model INVITE_CODE_TB {
model InviteCode {
uuid String @id @db.VarChar(32)
invite_code String @unique @db.VarChar(10)
space_uuid String @db.VarChar(32)
expiry_date DateTime
space SPACE_TB @relation(fields: [space_uuid], references: [uuid], onDelete: Cascade)
space Space @relation(fields: [space_uuid], references: [uuid], onDelete: Cascade)
}

2 changes: 0 additions & 2 deletions nestjs-BE/server/src/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import { AppService } from './app.service';
import { AuthModule } from './auth/auth.module';
import { UsersModule } from './users/users.module';
import { PrismaModule } from './prisma/prisma.module';
import { TemporaryDatabaseModule } from './temporary-database/temporary-database.module';
import { ProfilesModule } from './profiles/profiles.module';
import { SpacesModule } from './spaces/spaces.module';
import { BoardsModule } from './boards/boards.module';
Expand All @@ -21,7 +20,6 @@ import customEnv from './config/env';
AuthModule,
UsersModule,
PrismaModule,
TemporaryDatabaseModule,
ScheduleModule.forRoot(),
ProfilesModule,
SpacesModule,
Expand Down
Loading

0 comments on commit 2c6fdde

Please sign in to comment.