feat(backend): 공유 다이어리 API — 초대 코드로 함께 쓰기

다이어리를 가족·지인과 함께 쓸 수 있게 한다.
- diary_members 로 함께 쓰는 사람을 두고(주인 포함 최대 4명), 알림 설정을 사람별로 옮긴다
- 초대 코드(RUP-6자) 미리보기·참여, 개인↔공유 전환, 내보내기·나가기 — 내보내거나 나가면 코드를 바꾼다
- 목록·쓰기는 멤버, 수정·삭제는 쓴 사람, 다이어리 정보·삭제는 주인만
- 응답에 멤버·대상 요약·작성자를 담는다
- 파일 열람 정책 — 함께 쓰는 다이어리의 표지·기록 사진·아이 사진·멤버 프로필 사진은 멤버도 받을 수 있다
- 에러 코드 DIARY_003(코드 없음)·004(가득 참)·005(이미 참여)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-11 20:34:18 +09:00
parent 7701be3795
commit 688e72bf04
25 changed files with 2043 additions and 150 deletions
+6 -35
View File
@@ -1,14 +1,9 @@
import { INestApplication, ValidationPipe } from '@nestjs/common';
import { Reflector } from '@nestjs/core';
import { Test, TestingModule } from '@nestjs/testing';
import { INestApplication } from '@nestjs/common';
import request from 'supertest';
import type { Response } from 'supertest';
import { App } from 'supertest/types';
import { AppModule } from '@/app.module';
import { HttpExceptionFilter } from '@/common/filters/http-exception.filter';
import { TransformInterceptor } from '@/common/interceptors/transform.interceptor';
import { RequestIdMiddleware } from '@/common/middleware/request-id.middleware';
import { createE2eApp, devLogin, uniqueDeviceKey } from './support/e2e-app';
/**
* 세 플랫폼이 공유하는 응답 계약을 실제 HTTP 요청으로 검증한다.
@@ -35,7 +30,7 @@ interface ContractBody {
const body = (res: Response): ContractBody => res.body as ContractBody;
/** 매 실행마다 새 회원으로 시작한다 */
const E2E_DEVICE_KEY = `e2e-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
const E2E_DEVICE_KEY = uniqueDeviceKey();
describe('응답 계약 (e2e)', () => {
let app: INestApplication<App>;
@@ -43,34 +38,10 @@ describe('응답 계약 (e2e)', () => {
const auth = () => ({ Authorization: `Bearer ${accessToken}` });
beforeAll(async () => {
const moduleFixture: TestingModule = await Test.createTestingModule({
imports: [AppModule],
}).compile();
app = moduleFixture.createNestApplication();
// main.ts 와 동일한 전역 설정을 적용해야 실제 응답과 같아진다
app.setGlobalPrefix('api');
app.use(new RequestIdMiddleware().use.bind(new RequestIdMiddleware()));
app.useGlobalPipes(
new ValidationPipe({
whitelist: true,
forbidNonWhitelisted: true,
transform: true,
}),
);
app.useGlobalFilters(new HttpExceptionFilter());
app.useGlobalInterceptors(new TransformInterceptor(app.get(Reflector)));
await app.init();
// main.ts 와 동일한 전역 설정을 적용한 앱 (support/e2e-app.ts)
app = await createE2eApp();
// 개발용 로그인으로 테스트 회원을 만든다 (NODE_ENV=test 에서는 열려 있다)
const login = await request(app.getHttpServer())
.post('/api/auth/dev-sessions')
.send({ provider: 'kakao', deviceKey: E2E_DEVICE_KEY })
.expect(201);
accessToken = (login.body as { data: { accessToken: string } }).data
.accessToken;
accessToken = await devLogin(app, E2E_DEVICE_KEY);
});
afterAll(async () => {