Skip to content
Merged

Dev #185

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
3 changes: 1 addition & 2 deletions package-lock.json

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

3 changes: 1 addition & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@
"reflect-metadata": "^0.2.2",
"rxjs": "^7.8.2",
"striptags": "^3.2.0",
"ua-parser-js": "^2.0.3",
"uuid": "^11.1.0"
"ua-parser-js": "^2.0.3"
},
"devDependencies": {
"@nestjs/cli": "^11.0.12",
Expand Down
10 changes: 4 additions & 6 deletions src/module/image/dto/image.request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,11 @@ export class GetImageUploadUrlRequest {
@IsIn(exts)
ext: (typeof exts)[number];

@ApiProperty({ description: '지금은 optional이지만 나중에 필수로 바뀝니다' })
@IsOptional()
@ApiProperty()
@IsInt()
width?: number;
width: number;

@ApiProperty({ description: '지금은 optional이지만 나중에 필수로 바뀝니다' })
@IsOptional()
@ApiProperty()
@IsInt()
height?: number;
height: number;
}
12 changes: 4 additions & 8 deletions src/module/image/image.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,11 @@ export class ImageService {
}: {
type: (typeof imageTypes)[number];
ext: (typeof exts)[number];
width?: number;
height?: number;
width: number;
height: number;
}) {
let key: string;
if (width && height) {
key = `v2/${type}/${crypto.randomUUID()}_${width}x${height}.${ext}`;
} else {
key = `${type}/${crypto.randomUUID()}.${ext}`;
}
const key = `v2/${type}/${crypto.randomUUID()}_${width}x${height}.${ext}`;

const presignedUrl = await this.s3Service.createImageUploadUrl(key);

return {
Expand Down
10 changes: 5 additions & 5 deletions test/e2e/album/create-album.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as request from 'supertest';
import { AppModule } from 'src/app.module';
import { PrismaService } from 'src/database/prisma/prisma.service';
import { AuthService } from 'src/module/auth/auth.service';
import { register } from '../helper/register';
import { createTestUser } from '../helper/create-test-user';

describe('POST /albums - 앨범 생성', () => {
let app: INestApplication;
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('POST /albums - 앨범 생성', () => {

it('앨범 이름은 1자 이상 15자 이하어야 한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken } = await createTestUser(app, {});

// when
const { status } = await request(app.getHttpServer())
Expand All @@ -62,7 +62,7 @@ describe('POST /albums - 앨범 생성', () => {

it('201과 함께 앨범을 생성한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken } = await createTestUser(app, {});

// when
const { status, body } = await request(app.getHttpServer())
Expand All @@ -79,7 +79,7 @@ describe('POST /albums - 앨범 생성', () => {

it('앨범 이름이 중복일 때 409를 반환한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken } = await createTestUser(app, {});

await request(app.getHttpServer())
.post('/albums')
Expand All @@ -98,7 +98,7 @@ describe('POST /albums - 앨범 생성', () => {

it('앨범 개수가 8개 이상일 때 400을 반환한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken } = await createTestUser(app, {});

const user = await prisma.user.findFirstOrThrow();
const albums = Array.from({ length: 8 }, (_, i) => ({
Expand Down
8 changes: 3 additions & 5 deletions test/e2e/album/delete-album.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as request from 'supertest';
import { AppModule } from 'src/app.module';
import { PrismaService } from 'src/database/prisma/prisma.service';
import { AuthService } from 'src/module/auth/auth.service';
import { register } from '../helper/register';
import { createTestUser } from '../helper/create-test-user';

describe('DELETE /albums/:id - 앨범 삭제', () => {
let app: INestApplication;
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('DELETE /albums/:id - 앨범 삭제', () => {

it('앨범ID가 UUID 형식이 아닐 때 400을 반환한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken } = await createTestUser(app, {});

// when
const { status } = await request(app.getHttpServer())
Expand All @@ -62,9 +62,7 @@ describe('DELETE /albums/:id - 앨범 삭제', () => {

it('204와 함께 앨범을 삭제한다', async () => {
// given
const accessToken = await register(app, 'test');

const user = await prisma.user.findFirstOrThrow();
const { accessToken, user } = await createTestUser(app, {});

const album = await prisma.album.create({
data: {
Expand Down
14 changes: 6 additions & 8 deletions test/e2e/album/insert-feeds.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as request from 'supertest';
import { AppModule } from 'src/app.module';
import { PrismaService } from 'src/database/prisma/prisma.service';
import { AuthService } from 'src/module/auth/auth.service';
import { register } from '../helper/register';
import { createTestUser } from '../helper/create-test-user';

describe('PUT /albums/:id - 앨범에 피드 넣기', () => {
let app: INestApplication;
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('PUT /albums/:id - 앨범에 피드 넣기', () => {

it('피드는 최소 1개 이상 있어야한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken } = await createTestUser(app, {});

// when
const { status } = await request(app.getHttpServer())
Expand All @@ -64,7 +64,7 @@ describe('PUT /albums/:id - 앨범에 피드 넣기', () => {

it('UUID 형식이 아닐 때 400을 반환한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken } = await createTestUser(app, {});

// when
const { status } = await request(app.getHttpServer())
Expand All @@ -80,7 +80,7 @@ describe('PUT /albums/:id - 앨범에 피드 넣기', () => {

it('요청자와 앨범소유자가 다르면 403를 반환한다', async () => {
// given
const accessToken = await register(app, 'test1');
const { accessToken } = await createTestUser(app, {});

const user2 = await prisma.user.create({
data: {
Expand Down Expand Up @@ -114,7 +114,7 @@ describe('PUT /albums/:id - 앨범에 피드 넣기', () => {

it('앨범이 없으면 404를 반환한다', async () => {
// given
const accessToken = await register(app, 'test1');
const { accessToken } = await createTestUser(app, {});

// when
const { status } = await request(app.getHttpServer())
Expand All @@ -130,9 +130,7 @@ describe('PUT /albums/:id - 앨범에 피드 넣기', () => {

it('204와 함께 피드를 앨범으로 이동시킨다', async () => {
// given
const accessToken = await register(app, 'test');

const user = await prisma.user.findFirstOrThrow();
const { accessToken, user } = await createTestUser(app, {});

const album = await prisma.album.create({
data: {
Expand Down
9 changes: 4 additions & 5 deletions test/e2e/album/remove-feeds-album.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as request from 'supertest';
import { AppModule } from 'src/app.module';
import { PrismaService } from 'src/database/prisma/prisma.service';
import { AuthService } from 'src/module/auth/auth.service';
import { register } from '../helper/register';
import { createTestUser } from '../helper/create-test-user';

describe('PUT /albums/null - 앨범에서 피드 빼기', () => {
let app: INestApplication;
Expand Down Expand Up @@ -46,7 +46,7 @@ describe('PUT /albums/null - 앨범에서 피드 빼기', () => {

it('피드는 최소 1개 이상 있어야한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken } = await createTestUser(app, {});

// when
const { status } = await request(app.getHttpServer())
Expand All @@ -62,7 +62,7 @@ describe('PUT /albums/null - 앨범에서 피드 빼기', () => {

it('UUID 형식이 아닐 때 400을 반환한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken } = await createTestUser(app, {});

// when
const { status } = await request(app.getHttpServer())
Expand All @@ -78,8 +78,7 @@ describe('PUT /albums/null - 앨범에서 피드 빼기', () => {

it('204와 함께 피드의 앨범ID를 null로 변경한다', async () => {
// given
const accessToken = await register(app, 'test');
const user = await prisma.user.findFirstOrThrow();
const { accessToken, user } = await createTestUser(app, {});

const album = await prisma.album.create({
data: {
Expand Down
10 changes: 4 additions & 6 deletions test/e2e/album/update-album-order.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as request from 'supertest';
import { AppModule } from 'src/app.module';
import { PrismaService } from 'src/database/prisma/prisma.service';
import { AuthService } from 'src/module/auth/auth.service';
import { register } from '../helper/register';
import { createTestUser } from '../helper/create-test-user';

describe('PUT /albums/order - 앨범 순서 변경', () => {
let app: INestApplication;
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('PUT /albums/order - 앨범 순서 변경', () => {

it('앨범ID가 UUID 형식이 아닐 때 400을 반환한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken } = await createTestUser(app, {});

// when
const { status } = await request(app.getHttpServer())
Expand All @@ -62,7 +62,7 @@ describe('PUT /albums/order - 앨범 순서 변경', () => {

it('앨범ID는 최소 2개 이상이어야 한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken } = await createTestUser(app, {});

// when
const { status, body } = await request(app.getHttpServer())
Expand All @@ -76,9 +76,7 @@ describe('PUT /albums/order - 앨범 순서 변경', () => {

it('204와 함께 앨범 순서를 변경한다', async () => {
// given
const accessToken = await register(app, 'test');

const user = await prisma.user.findFirstOrThrow();
const { accessToken, user } = await createTestUser(app, {});

const { id: albumId1 } = await prisma.album.create({
data: {
Expand Down
13 changes: 5 additions & 8 deletions test/e2e/album/update-album.e2e-spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as request from 'supertest';
import { AppModule } from 'src/app.module';
import { PrismaService } from 'src/database/prisma/prisma.service';
import { AuthService } from 'src/module/auth/auth.service';
import { register } from '../helper/register';
import { createTestUser } from '../helper/create-test-user';

describe('PATCH /albums/:id - 앨범 수정', () => {
let app: INestApplication;
Expand Down Expand Up @@ -48,7 +48,7 @@ describe('PATCH /albums/:id - 앨범 수정', () => {

it('앨범ID가 UUID 형식이 아닐 때 400을 반환한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken } = await createTestUser(app, {});

// when
const { status } = await request(app.getHttpServer())
Expand All @@ -62,7 +62,7 @@ describe('PATCH /albums/:id - 앨범 수정', () => {

it('앨범 이름은 1자 이상 15자 이하여야 한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken } = await createTestUser(app, {});

// when
const { status } = await request(app.getHttpServer())
Expand All @@ -76,9 +76,7 @@ describe('PATCH /albums/:id - 앨범 수정', () => {

it('앨범 이름이 중복될 때 409를 반환한다', async () => {
// given
const accessToken = await register(app, 'test');

const user = await prisma.user.findFirstOrThrow();
const { accessToken, user } = await createTestUser(app, {});

await prisma.album.create({
data: {
Expand All @@ -100,9 +98,8 @@ describe('PATCH /albums/:id - 앨범 수정', () => {

it('앨범을 수정하고 204를 반환한다', async () => {
// given
const accessToken = await register(app, 'test');
const { accessToken, user } = await createTestUser(app, {});

const user = await prisma.user.findFirstOrThrow();
const album = await prisma.album.create({
data: {
userId: user.id,
Expand Down
Loading
Loading