-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Backend] Implement Uber Fx for dependency management and codebase mo…
…dularity - DI like Spring Boot
- Loading branch information
Showing
87 changed files
with
3,701 additions
and
3,701 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,131 @@ | ||
package config | ||
|
||
import "os" | ||
|
||
var ( | ||
IS_PRODUCTION = os.Getenv("DEPLOYMENT") | ||
import ( | ||
"encoding/base64" | ||
"os" | ||
"strconv" | ||
"time" | ||
) | ||
|
||
type AppConfig struct { | ||
AwsRegion string | ||
S3BucketName string | ||
LoginTokenCookie string | ||
TokenExpirationTime time.Duration | ||
IsProduction string | ||
IsWaterURL string | ||
IsWaterKEY string | ||
CkURL string // to fetch new ones from external | ||
NaverEmailVerifyURL string | ||
ClientURL string | ||
} | ||
|
||
func NewAppConfig() *AppConfig { | ||
expiration, _ := strconv.Atoi(os.Getenv("TOKEN_EXPIRATION_INTERVAL")) | ||
return &AppConfig{ | ||
AwsRegion: os.Getenv("AWS_REGION"), | ||
S3BucketName: os.Getenv("AWS_BUCKET_NAME"), | ||
LoginTokenCookie: os.Getenv("TOKEN_COOKIE"), | ||
TokenExpirationTime: time.Duration(expiration) * time.Hour, | ||
IsProduction: os.Getenv("DEPLOYMENT"), | ||
IsWaterURL: os.Getenv("IS_WATER_API"), | ||
IsWaterKEY: os.Getenv("IS_WATER_API_KEY"), | ||
CkURL: os.Getenv("CK_URL"), | ||
NaverEmailVerifyURL: os.Getenv("NAVER_EMAIL_VERIFY_URL"), | ||
ClientURL: os.Getenv("CLIENT_ADDR"), | ||
} | ||
} | ||
|
||
type KakaoConfig struct { | ||
KakaoAK string | ||
KakaoStaticMap string | ||
KakaoGeoCode string | ||
KakaoCoord2Addr string | ||
KakaoCoord2Region string | ||
KakaoWeather string | ||
KakaoAddressInfo string | ||
} | ||
|
||
func NewKakaoConfig() *KakaoConfig { | ||
return &KakaoConfig{ | ||
KakaoAK: os.Getenv("KAKAO_AK"), | ||
KakaoStaticMap: os.Getenv("KAKAO_STATIC_MAP"), | ||
KakaoGeoCode: "https://dapi.kakao.com/v2/local/geo/address.json", | ||
KakaoCoord2Addr: "https://dapi.kakao.com/v2/local/geo/coord2address.json", | ||
KakaoCoord2Region: "https://dapi.kakao.com/v2/local/geo/coord2regioncode.json", | ||
KakaoWeather: "https://map.kakao.com/api/dapi/point/weather?inputCoordSystem=WCONGNAMUL&outputCoordSystem=WCONGNAMUL&version=2&service=map.daum.net", | ||
KakaoAddressInfo: "https://map.kakao.com/etc/areaAddressInfo.json?output=JSON&inputCoordSystem=WCONGNAMUL&outputCoordSystem=WCONGNAMUL", | ||
} | ||
} | ||
|
||
type RedisConfig struct { | ||
AllMarkersKey string | ||
UserProfileKey string | ||
UserFavKey string | ||
} | ||
|
||
func NewRedisConfig() *RedisConfig { | ||
return &RedisConfig{ | ||
AllMarkersKey: "all_markers", | ||
UserProfileKey: "user_profile", | ||
UserFavKey: "user_fav", | ||
} | ||
} | ||
|
||
type ZincSearchConfig struct { | ||
ZincAPI string | ||
ZincUser string | ||
ZincPassword string | ||
} | ||
|
||
func NewZincSearchConfig() *ZincSearchConfig { | ||
return &ZincSearchConfig{ | ||
ZincAPI: os.Getenv("ZINCSEARCH_URL"), | ||
ZincUser: os.Getenv("ZINCSEARCH_USER"), | ||
ZincPassword: os.Getenv("ZINCSEARCH_PASSWORD"), | ||
} | ||
} | ||
|
||
type S3Config struct { | ||
AwsRegion string | ||
S3BucketName string | ||
} | ||
|
||
func NewS3Config() *S3Config { | ||
return &S3Config{ | ||
AwsRegion: os.Getenv("AWS_REGION"), | ||
S3BucketName: os.Getenv("AWS_BUCKET_NAME"), | ||
} | ||
} | ||
|
||
type SmtpConfig struct { | ||
SmtpServer string | ||
SmtpPort string | ||
SmtpUsername string | ||
SmtpPassword string | ||
FrontendResetRouter string | ||
} | ||
|
||
func NewSmtpConfig() *SmtpConfig { | ||
return &SmtpConfig{ | ||
SmtpServer: os.Getenv("SMTP_SERVER"), | ||
SmtpPort: os.Getenv("SMTP_PORT"), | ||
SmtpUsername: os.Getenv("SMTP_USERNAME"), | ||
SmtpPassword: os.Getenv("SMTP_PASSWORD"), | ||
FrontendResetRouter: os.Getenv("FRONTEND_RESET_ROUTER"), | ||
} | ||
} | ||
|
||
type TossPayConfig struct { | ||
SecretKey string | ||
ConfirmAPI string | ||
PaymentAPI string | ||
} | ||
|
||
func NewTossPayConfig() *TossPayConfig { | ||
return &TossPayConfig{ | ||
SecretKey: "Basic " + base64.StdEncoding.EncodeToString([]byte(os.Getenv("TOSS_SECRET_KEY_TEST")+":")), | ||
ConfirmAPI: "https://api.tosspayments.com/v1/payments/confirm", | ||
PaymentAPI: "https://api.tosspayments.com/v1/payments/", | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
package configfx | ||
|
||
import ( | ||
"github.com/Alfex4936/chulbong-kr/config" | ||
"go.uber.org/fx" | ||
) | ||
|
||
var ( | ||
FxConfigModule = fx.Module("config", | ||
fx.Provide( | ||
config.NewAppConfig, | ||
config.NewKakaoConfig, | ||
config.NewRedisConfig, | ||
config.NewZincSearchConfig, | ||
config.NewS3Config, | ||
config.NewSmtpConfig, | ||
config.NewTossPayConfig, | ||
), | ||
) | ||
) |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
package servicefx | ||
|
||
import ( | ||
"github.com/Alfex4936/chulbong-kr/facade" | ||
"github.com/Alfex4936/chulbong-kr/handler" | ||
"github.com/Alfex4936/chulbong-kr/service" | ||
"github.com/Alfex4936/chulbong-kr/util" | ||
"go.uber.org/fx" | ||
) | ||
|
||
var ( | ||
FxAPIModule = fx.Module("api", | ||
fx.Provide( | ||
handler.NewMarkerHandler, | ||
handler.NewUserHandler, | ||
handler.NewSearchHandler, | ||
handler.NewNotificationHandler, | ||
handler.NewCommentHandler, | ||
handler.NewChatHandler, | ||
handler.NewAuthHandler, | ||
handler.NewAdminHandler, | ||
), | ||
) | ||
|
||
FxFacadeModule = fx.Module("facade", | ||
fx.Provide( | ||
facade.NewMarkerFacadeService, | ||
facade.NewUserFacadeService, | ||
facade.NewAdminFacadeService, | ||
), | ||
) | ||
|
||
FxUserModule = fx.Module("user", | ||
fx.Provide( | ||
service.NewAuthService, | ||
service.NewUserService, | ||
), | ||
) | ||
FxMarkerModule = fx.Module("marker", | ||
fx.Provide( | ||
service.NewMarkerManageService, | ||
service.NewMarkerInteractService, | ||
service.NewMarkerRankService, | ||
service.NewMarkerLocationService, | ||
service.NewMarkerFacilityService, | ||
service.NewMarkerCommentService, | ||
service.NewNotificationService, | ||
service.NewReportService, | ||
), | ||
) | ||
|
||
FxExternalModle = fx.Module("external", | ||
fx.Provide( | ||
service.NewRedisService, | ||
service.NewS3Service, | ||
service.NewZincSearchService, | ||
service.NewSmtpService, | ||
), | ||
) | ||
|
||
FxChatModule = fx.Module("chat", | ||
fx.Provide( | ||
service.NewChatService, | ||
service.NewRoomConnectionManager, | ||
// service.NewMqService, | ||
// service.NewGeminiService, | ||
), | ||
) | ||
|
||
FxUtilModule = fx.Module("util", | ||
fx.Provide( | ||
service.NewTokenService, | ||
service.NewSchedulerService, | ||
util.NewTokenUtil, | ||
util.NewChatUtil, | ||
util.NewBadWordUtil, | ||
util.NewMapUtil, | ||
), | ||
) | ||
) |
Oops, something went wrong.