Skip to content

Commit

Permalink
Merge pull request #5 from mujik-tigers/feature/create-room
Browse files Browse the repository at this point in the history
feature: 방 만들기 기능 구현 완료
  • Loading branch information
yeonise authored Mar 20, 2024
2 parents 16c677c + a8b230d commit 1218ae2
Show file tree
Hide file tree
Showing 36 changed files with 1,134 additions and 31 deletions.
20 changes: 18 additions & 2 deletions .github/workflows/test-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,12 @@ jobs:
test:
runs-on: ubuntu-latest

services:
redis:
image: redis:latest
ports:
- 6380:6379

steps:
- name: Check out
uses: actions/checkout@v3
Expand All @@ -26,6 +32,16 @@ jobs:
distribution: 'temurin'
java-version: '17'

- name: Copy application.yml
run: |
mkdir ./src/main/resources
touch ./src/main/resources/application.yml
echo "${{ secrets.APPLICATION }}" > ./src/main/resources/application.yml
touch ./src/main/resources/application-test.yml
echo "${{ secrets.APPLICATION_TEST }}" > ./src/main/resources/application-test.yml
touch ./src/main/resources/application-release.yml
echo "${{ secrets.APPLICATION_RELEASE }}" > ./src/main/resources/application-release.yml
- name: Cache Gradle packages
uses: actions/cache@v3
with:
Expand Down Expand Up @@ -55,5 +71,5 @@ jobs:
title: Test Coverage Report
paths: ${{ github.workspace }}/build/reports/jacoco/test/jacocoTestReport.xml
token: ${{ secrets.ACCESS_TOKEN }}
min-coverage-overall: 80
min-coverage-changed-files: 50
min-coverage-overall: 70
min-coverage-changed-files: 40
78 changes: 63 additions & 15 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,38 +1,86 @@
plugins {
id 'java'
id 'org.springframework.boot' version '3.2.3'
id 'io.spring.dependency-management' version '1.1.4'
id 'java'
id 'org.springframework.boot' version '3.2.3'
id 'io.spring.dependency-management' version '1.1.4'
id 'org.asciidoctor.jvm.convert' version '3.3.2'
id 'jacoco'
}

group = 'site'
version = '0.0.1-SNAPSHOT'

java {
sourceCompatibility = '17'
sourceCompatibility = '17'
}

configurations {
compileOnly {
extendsFrom annotationProcessor
}
compileOnly {
extendsFrom annotationProcessor
}

asciidoctorExt
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-data-redis'
compileOnly 'org.projectlombok:lombok'
annotationProcessor 'org.projectlombok:lombok'
asciidoctorExt 'org.springframework.restdocs:spring-restdocs-asciidoctor'
testImplementation 'org.springframework.restdocs:spring-restdocs-mockmvc'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
}

tasks.named('test') {
useJUnitPlatform()
useJUnitPlatform()

finalizedBy jacocoTestReport
}

ext {
snippetsDir = file('build/generated-snippets')
}

asciidoctor {
inputs.dir snippetsDir
configurations 'asciidoctorExt'

sources {
include("**/index.adoc")
}

baseDirFollowsSourceFile()
dependsOn test
}

bootJar {
dependsOn asciidoctor

from("${asciidoctor.outputDir}") {
into 'static/docs'
}
}

jacoco {
toolVersion = "0.8.8"
}

jacocoTestReport {
dependsOn test

reports {
xml.required = true
html.required = true
}

finalizedBy 'jacocoTestCoverageVerification'
}

jar {
enabled = false
enabled = false
}
45 changes: 45 additions & 0 deletions src/docs/asciidoc/api/room.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
[[Room-API]]
== Room API

[[create-room-success]]
=== 방 생성 성공

==== HTTP Request

include::{snippets}/create-room-success/http-request.adoc[]
include::{snippets}/create-room-success/request-fields.adoc[]

==== HTTP Response

include::{snippets}/create-room-success/http-response.adoc[]
include::{snippets}/create-room-success/response-fields.adoc[]

{nbsp}

[[create-room-fail-room-setting-error]]
=== 방 생성 실패: 요청 데이터 오류가 발생했습니다

==== HTTP Request

include::{snippets}/create-room-fail-room-setting-error/http-request.adoc[]
include::{snippets}/create-room-fail-room-setting-error/request-fields.adoc[]

==== HTTP Response

include::{snippets}/create-room-fail-room-setting-error/http-response.adoc[]
include::{snippets}/create-room-fail-room-setting-error/response-fields.adoc[]

{nbsp}

[[create-room-fail-single-room-participant-violation]]
=== 방 생성 실패: 다수의 방에 참가할 수 없습니다

==== HTTP Request

include::{snippets}/create-room-fail-single-room-participant-violation/http-request.adoc[]
include::{snippets}/create-room-fail-single-room-participant-violation/request-fields.adoc[]

==== HTTP Response

include::{snippets}/create-room-fail-single-room-participant-violation/http-response.adoc[]
include::{snippets}/create-room-fail-single-room-participant-violation/response-fields.adoc[]
79 changes: 79 additions & 0 deletions src/docs/asciidoc/docinfo.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
<script src="https://code.jquery.com/jquery-1.11.3.min.js"></script>
<script src="https://code.jquery.com/ui/1.11.4/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery.tocify/1.9.0/javascripts/jquery.tocify.min.js"></script>

<link rel="stylesheet" as="style" crossorigin href="https://cdn.jsdelivr.net/gh/orioncactus/[email protected]/dist/web/static/pretendard.min.css"/>

<style>
.tocify-subheader {
font-style: normal;
font-size: 92%;
}

.tocify ul {
margin: 0;
}

.tocify-focus {
color: #7a2518;
background-color: rgba(0, 0, 0, 0.05);
}

.tocify-focus > a {
color: #7a2518;
}

thead > tr {
font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
}

tbody tr td:nth-child(4) {
font-family: "Pretendard Variable", Pretendard, -apple-system, BlinkMacSystemFont, system-ui, Roboto, "Helvetica Neue", "Segoe UI", "Apple SD Gothic Neo", "Noto Sans KR", "Malgun Gothic", "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", sans-serif;
}
</style>

<script type="text/javascript">
$(function () {
// Add a new container for the tocify toc into the existing toc so we can re-use its
// styling
$("#toc").append("<div id='generated-toc'></div>");
$("#generated-toc").tocify({
extendPage: true,
context: "#content",
highlightOnScroll: true,
hideEffect: "slideUp",
// Use the IDs that asciidoc already provides so that TOC links and intra-document
// links are the same. Anything else might confuse users when they create bookmarks.
hashGenerator: function(text, element) {
return $(element).attr("id");
},
// Smooth scrolling doesn't work properly if we use the asciidoc IDs
smoothScroll: false,
// Set to 'none' to use the tocify classes
theme: "none",
// Handle book (may contain h1) and article (only h2 deeper)
selectors: $( "#content" ).has( "h1" ).size() > 0 ? "h1,h2,h3,h4,h5" : "h2,h3,h4,h5",
ignoreSelector: ".discrete"
});

// Switch between static asciidoc toc and dynamic tocify toc based on browser size
// This is set to match the media selectors in the asciidoc CSS
// Without this, we keep the dynamic toc even if it is moved from the side to preamble
// position which will cause odd scrolling behavior
var handleTocOnResize = function() {
if ($(document).width() < 768) {
$("#generated-toc").hide();
$(".sectlevel0").show();
$(".sectlevel1").show();
}
else {
$("#generated-toc").show();
$(".sectlevel0").hide();
$(".sectlevel1").hide();
}
}

$(window).resize(handleTocOnResize);
handleTocOnResize();
});
</script>
14 changes: 14 additions & 0 deletions src/docs/asciidoc/index.adoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
ifndef::snippets[]
:snippets: ../../build/generated-snippets
endif::[]

= YouTogether API Document
:doctype: book
:icons: font
:source-highlighter: highlightjs
:toc: left
:toclevels: 2
:sectlinks:
:docinfo: shared

include::api/room.adoc[]
14 changes: 14 additions & 0 deletions src/main/java/site/youtogether/config/PropertiesConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package site.youtogether.config;

import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Configuration;

import site.youtogether.config.property.CookieProperties;

@Configuration
@EnableConfigurationProperties(value = {
CookieProperties.class
})
public class PropertiesConfig {

}
38 changes: 38 additions & 0 deletions src/main/java/site/youtogether/config/RedisConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
package site.youtogether.config;

import org.springframework.boot.autoconfigure.data.redis.RedisProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.redis.connection.RedisConnectionFactory;
import org.springframework.data.redis.connection.RedisStandaloneConfiguration;
import org.springframework.data.redis.connection.lettuce.LettuceConnectionFactory;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.data.redis.serializer.StringRedisSerializer;

import lombok.RequiredArgsConstructor;

@Configuration
@RequiredArgsConstructor
public class RedisConfig {

private final RedisProperties redisProperties;

@Bean
public RedisConnectionFactory redisConnectionFactory() {
RedisStandaloneConfiguration redisStandaloneConfiguration = new RedisStandaloneConfiguration(redisProperties.getHost(), redisProperties.getPort());
redisStandaloneConfiguration.setPassword(redisProperties.getPassword());

return new LettuceConnectionFactory(redisStandaloneConfiguration);
}

@Bean
public RedisTemplate<String, String> redisStringTemplate() {
RedisTemplate<String, String> redisTemplate = new RedisTemplate<>();
redisTemplate.setConnectionFactory(redisConnectionFactory());
redisTemplate.setKeySerializer(new StringRedisSerializer());
redisTemplate.setValueSerializer(new StringRedisSerializer());

return redisTemplate;
}

}
23 changes: 23 additions & 0 deletions src/main/java/site/youtogether/config/WebConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
package site.youtogether.config;

import java.util.List;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import lombok.RequiredArgsConstructor;
import site.youtogether.resolver.AddressArgumentResolver;

@Configuration
@RequiredArgsConstructor
public class WebConfig implements WebMvcConfigurer {

private final AddressArgumentResolver addressArgumentResolver;

@Override
public void addArgumentResolvers(List<HandlerMethodArgumentResolver> resolvers) {
resolvers.add(addressArgumentResolver);
}

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package site.youtogether.config.property;

import org.springframework.boot.context.properties.ConfigurationProperties;

import lombok.Getter;
import lombok.RequiredArgsConstructor;

@ConfigurationProperties("cookie")
@RequiredArgsConstructor
@Getter
public class CookieProperties {

private final String name;
private final String domain;
private final String path;
private final String sameSite;
private final int expiry;

}
17 changes: 17 additions & 0 deletions src/main/java/site/youtogether/exception/CustomException.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package site.youtogether.exception;

import org.springframework.http.HttpStatus;

import lombok.Getter;

@Getter
public class CustomException extends RuntimeException {

private final HttpStatus status;

public CustomException(ErrorType errorType) {
super(errorType.getMessage());
this.status = errorType.getStatus();
}

}
Loading

0 comments on commit 1218ae2

Please sign in to comment.