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
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
.DS_Store
apps/backend/target/
65 changes: 65 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# AGENTS.md

Behavioral guidelines to reduce common LLM coding mistakes. Merge with project-specific instructions as needed.

**Tradeoff:** These guidelines bias toward caution over speed. For trivial tasks, use judgment.

## 1. Think Before Coding

**Don't assume. Don't hide confusion. Surface tradeoffs.**

Before implementing:
- State your assumptions explicitly. If uncertain, ask.
- If multiple interpretations exist, present them - don't pick silently.
- If a simpler approach exists, say so. Push back when warranted.
- If something is unclear, stop. Name what's confusing. Ask.

## 2. Simplicity First

**Minimum code that solves the problem. Nothing speculative.**

- No features beyond what was asked.
- No abstractions for single-use code.
- No "flexibility" or "configurability" that wasn't requested.
- No error handling for impossible scenarios.
- If you write 200 lines and it could be 50, rewrite it.

Ask yourself: "Would a senior engineer say this is overcomplicated?" If yes, simplify.

## 3. Surgical Changes

**Touch only what you must. Clean up only your own mess.**

When editing existing code:
- Don't "improve" adjacent code, comments, or formatting.
- Don't refactor things that aren't broken.
- Match existing style, even if you'd do it differently.
- If you notice unrelated dead code, mention it - don't delete it.

When your changes create orphans:
- Remove imports/variables/functions that YOUR changes made unused.
- Don't remove pre-existing dead code unless asked.

The test: Every changed line should trace directly to the user's request.

## 4. Goal-Driven Execution

**Define success criteria. Loop until verified.**

Transform tasks into verifiable goals:
- "Add validation" → "Write tests for invalid inputs, then make them pass"
- "Fix the bug" → "Write a test that reproduces it, then make it pass"
- "Refactor X" → "Ensure tests pass before and after"

For multi-step tasks, state a brief plan:
```
1. [Step] → verify: [check]
2. [Step] → verify: [check]
3. [Step] → verify: [check]
```

Strong success criteria let you loop independently. Weak criteria ("make it work") require constant clarification.

---

**These guidelines are working if:** fewer unnecessary changes in diffs, fewer rewrites due to overcomplication, and clarifying questions come before implementation rather than after mistakes.
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public OpenAPI customOpenAPI() {

// 보안 스키마 이름
String jwtSchemeName = "Bearer Authentication";
String sessionSchemeName = "Session ID";

return new OpenAPI()
.info(new Info()
Expand All @@ -52,10 +51,8 @@ public OpenAPI customOpenAPI() {

## 인증 방법
1. `/api/auth/register` 또는 `/api/auth/login`으로 회원가입/로그인
2. 응답으로 받은 `token`과 `sessionId`를 사용
3. 이후 모든 요청에 다음 헤더 포함:
- `Authorization: Bearer {token}`
- `x-session-id: {sessionId}`
2. 응답으로 받은 `token`을 사용
3. 이후 모든 요청에 `Authorization: Bearer {token}` 헤더 포함

## 주요 기능
- 사용자 인증 및 관리
Expand Down Expand Up @@ -88,12 +85,6 @@ public OpenAPI customOpenAPI() {
.scheme("bearer")
.bearerFormat("JWT")
.description("JWT 토큰을 입력하세요 (Bearer 접두사 제외)"))
// Session ID 헤더 보안 스키마
.addSecuritySchemes(sessionSchemeName, new SecurityScheme()
.type(SecurityScheme.Type.APIKEY)
.in(SecurityScheme.In.HEADER)
.name("x-session-id")
.description("세션 ID를 입력하세요"))
// 공통 에러 응답 스키마
.addSchemas("ApiErrorResponse", new Schema<>()
.type("object")
Expand Down Expand Up @@ -153,7 +144,6 @@ public OpenAPI customOpenAPI() {
.example("{ \"success\": false, \"code\": \"RATE_LIMIT_EXCEEDED\", \"message\": \"요청 한도를 초과했습니다.\" }")))))
// 글로벌 보안 요구사항 (일부 엔드포인트는 개별적으로 재정의)
.addSecurityItem(new SecurityRequirement()
.addList(jwtSchemeName)
.addList(sessionSchemeName));
.addList(jwtSchemeName));
}
}
38 changes: 38 additions & 0 deletions apps/backend/src/main/java/com/ktb/chatapp/config/S3Config.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package com.ktb.chatapp.config;

import java.net.URI;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import software.amazon.awssdk.regions.Region;
import software.amazon.awssdk.services.s3.S3Client;
import software.amazon.awssdk.services.s3.presigner.S3Presigner;

@Configuration
public class S3Config {

@Bean
S3Client s3Client(
@Value("${aws.s3.region}") String region,
@Value("${aws.s3.endpoint:}") String endpoint,
@Value("${aws.s3.path-style-access:false}") boolean pathStyleAccess) {
var builder = S3Client.builder()
.region(Region.of(region))
.forcePathStyle(pathStyleAccess);
if (!endpoint.isBlank()) {
builder.endpointOverride(URI.create(endpoint));
}
return builder.build();
}

@Bean
S3Presigner s3Presigner(
@Value("${aws.s3.region}") String region,
@Value("${aws.s3.endpoint:}") String endpoint) {
var builder = S3Presigner.builder().region(Region.of(region));
if (!endpoint.isBlank()) {
builder.endpointOverride(URI.create(endpoint));
}
return builder.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,11 @@ public class SecurityConfig {
"Content-Type",
"Authorization",
"x-auth-token",
"x-session-id",
"Cache-Control",
"Pragma"
);

private static final List<String> CORS_EXPOSED_HEADERS = List.of(
"x-auth-token",
"x-session-id"
);
private static final List<String> CORS_EXPOSED_HEADERS = List.of("Authorization");

private static final List<String> CORS_ALLOWED_METHODS = List.of("GET", "POST", "PUT", "DELETE", "OPTIONS");

Expand Down
Loading