Skip to content

Commit

Permalink
[url-shorten 최소 구현] 전체 구현
Browse files Browse the repository at this point in the history
  • Loading branch information
Hyune-c committed Jan 16, 2025
1 parent d10b9fe commit 45d7124
Show file tree
Hide file tree
Showing 13 changed files with 651 additions and 1 deletion.
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/gradlew text eol=lf
*.bat text eol=crlf
*.jar binary
145 changes: 145 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# Created by https://www.toptal.com/developers/gitignore/api/intellij+all,java,gradle
# Edit at https://www.toptal.com/developers/gitignore?templates=intellij+all,java,gradle

### Intellij+all ###
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio, WebStorm and Rider
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# AWS User-specific
.idea/**/aws.xml

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/artifacts
# .idea/compiler.xml
# .idea/jarRepositories.xml
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

# IntelliJ
out/

# mpeltonen/sbt-idea plugin
.idea_modules/

# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# SonarLint plugin
.idea/sonarlint/

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser

### Intellij+all Patch ###
# Ignore everything but code style settings and run configurations
# that are supposed to be shared within teams.

.idea/*

!.idea/codeStyles
!.idea/runConfigurations

### Java ###
# Compiled class file
*.class

# Log file
*.log

# BlueJ files
*.ctxt

# Mobile Tools for Java (J2ME)
.mtj.tmp/

# Package Files #
*.jar
*.war
*.nar
*.ear
*.zip
*.tar.gz
*.rar

# virtual machine crash logs, see http://www.java.com/en/download/help/error_hotspot.xml
hs_err_pid*
replay_pid*

### Gradle ###
.gradle
**/build/
!src/**/build/

# Ignore Gradle GUI config
gradle-app.setting

# Avoid ignoring Gradle wrapper jar file (.jar files are usually ignored)
!gradle-wrapper.jar

# Avoid ignore Gradle wrappper properties
!gradle-wrapper.properties

# Cache of project
.gradletasknamecache

# Eclipse Gradle plugin generated files
# Eclipse Core
.project
# JDT-specific (Eclipse Java Development Tools)
.classpath

### Gradle Patch ###
# Java heap dump
*.hprof

# End of https://www.toptal.com/developers/gitignore/api/intellij+all,java,gradle
65 changes: 64 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,64 @@
# onem-backend-java
# onem-backend-kotlin

whatever 사의 internal-core 팀에 입사하신 것을 축하합니다!
internal-core 팀은 전사 공통 util 서비스를 제공하고 있으며, 당신에게 처음으로 맡겨진 서비스는 url-shortener 입니다.
해당 서비스는 정상 운영 중이긴 하지만 안타깝게도 전임자는 퇴사 했고, 알 수 없는 문제가 많이 있습니다.

하지만 당신은 이 서비스의 새로운 오너로서 지금의 문제를 개선하고 새로운 업무 요건을 개발할 수 있을 것 입니다!

url-shortener 는 다음과 같은 요건을 가지고 있습니다.

- 완전한 util 서비스로 긴 url 을 짧게 줄여주는 서비스입니다.
- internal vpc 에서 운영되고 있어 인증/인가 로직이 없습니다.
- 인프라 스펙은 1 core, 1GB memory, 1 pod 로 운영되고 있습니다.
- 기존 트래픽은 RPM 30 입니다.

### guideline

> 개발에 대한 생각은 개발자마다, 심지어 대가들 끼리도 미묘하게 다릅니다.
> 저의 멘토링 & 코드 리뷰는 당연하게도 저의 지극히 개인적인 관점과 경험에서 진행됩니다.
> 그렇기에 멘티는 다양한 의견을 듣고 본인에 적합한 피드백을 스스로 선택하기를 기대합니다.
>
> 이 멘토링에서는 버그를 고쳐주거나, 코드를 작성해주지 않습니다.
> 스스로 학습할 수 있는 키워드와 레퍼런스만을 제공합니다.
>
> 정답은 존재하지 않으며, 베스트 프렉티스는 상황에 따라 다릅니다.
- 업무 요건을 글자 그대로 받아들이지 마세요.
- 사용성 또한 보이지 않는 기술 요건 중 하나 입니다.
- 애플리케이션을 ide 안에서만 기동하려고 하지 마세요.
- 자동화된 테스트가 필요한 시점을 판단하세요.
- 구조화가 필요한 시점을 판단하세요.
- 구현되어 있는 것을 변경할 때 무엇을, 어떤 순서로 변경할지 판단하세요.
- record 를 제외하고 java 11 을 넘어가는 문법은 사용을 지양해주세요.
- redis 는 허용되지 않습니다.

### how to run

1. application build

```shell
./gradlew bootJar
```

2. application run

```shell
java -jar build/libs/onem-backend-kotlin-0.0.1-SNAPSHOT.jar
````

2. create shorten-url key

```shell
curl -X POST --location "http://localhost:8080/shorten-url/create" \
-H "Content-Type: application/json" \
-d 'https://www.google.com'
```

3. search shorten-url by created key

```shell
curl -X POST --location "http://localhost:8080/shorten-url/search" \
-H "Content-Type: application/json" \
-d '4888'
```
29 changes: 29 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
plugins {
java
id("org.springframework.boot") version "3.4.1"
id("io.spring.dependency-management") version "1.1.7"
}

group = "community.whatever"
version = "0.0.1-SNAPSHOT"

java {
toolchain {
languageVersion = JavaLanguageVersion.of(21)
}
}

repositories {
mavenCentral()
}

dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("org.springframework.boot:spring-boot-starter")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

tasks.withType<Test> {
useJUnitPlatform()
}
Binary file added gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
7 changes: 7 additions & 0 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.11.1-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Loading

0 comments on commit 45d7124

Please sign in to comment.