diff --git "a/\btemp/gameData.get.ts" "b/\btemp/gameData.get.ts" index b04bf94..952da44 100644 --- "a/\btemp/gameData.get.ts" +++ "b/\btemp/gameData.get.ts" @@ -1,63 +1,64 @@ -import { getHeader } from "h3"; +import { getHeader, defineEventHandler } from 'h3' +import { useRuntimeConfig } from 'nuxt/app' import type { GameDataResponse, GameDataValue, -} from "#layers/types/api/gameData"; +} from '../layers/types/api/gameData' -export default defineEventHandler(async (event) => { - const config = useRuntimeConfig(); - const baseDomain = (config.public.baseDomain || ".onstove.com") as string; - const stoveApiBaseUrl = config.public.stoveApiUrl; - const apiUrl = `${stoveApiBaseUrl}/pub-comm/v1.0/template/game`; - let gameAlias = ""; +export default defineEventHandler(async event => { + const config = useRuntimeConfig() + const baseDomain = (config.public.baseDomain || '.onstove.com') as string + const stoveApiBaseUrl = config.public.stoveApiUrl + const apiUrl = `${stoveApiBaseUrl}/pub-comm/v1.0/template/game` + let gameAlias = '' try { // 미들웨어에서 설정한 gameAlias가 있다면 우선 사용 if (event.context.gameAlias) { - gameAlias = event.context.gameAlias; + gameAlias = event.context.gameAlias } else { - const host = getHeader(event, "host") || ""; - const isGameAliasExtractable = host.includes(baseDomain); + const host = getHeader(event, 'host') || '' + const isGameAliasExtractable = host.includes(baseDomain) if (isGameAliasExtractable) { - const subdomain = host.split(".")[0]; - if (subdomain && subdomain !== "www") { - gameAlias = subdomain; + const subdomain = host.split('.')[0] + if (subdomain && subdomain !== 'www') { + gameAlias = subdomain } } } } catch (error) { - console.error("gameAlias extraction error: ", error); + console.error('gameAlias extraction error: ', error) } try { const queryParams: Record = { game_alias: gameAlias, - }; + } const response = await $fetch(apiUrl, { query: queryParams, - }); + }) - if (response?.code === 0 && "value" in response) { - event.context.gameData = response.value; + if (response?.code === 0 && 'value' in response) { + event.context.gameData = response.value // lang_codes를 사용해서 동적으로 i18n 설정 업데이트 if ( response.value.lang_codes && Array.isArray(response.value.lang_codes) ) { - event.context.availableLocales = response.value.lang_codes; + event.context.availableLocales = response.value.lang_codes event.context.defaultLocale = response.value.default_lang_code || response.value.lang_codes[0] || - "ko"; + 'ko' } - return response.value as GameDataValue; + return response.value as GameDataValue } } catch (error) { - console.error(error); - return {}; + console.error(error) + return {} } -}); +}) diff --git a/.eslintignore b/.eslintignore new file mode 100644 index 0000000..d9d262c --- /dev/null +++ b/.eslintignore @@ -0,0 +1,14 @@ +temp/ +**/temp/** +node_modules/ +.nuxt/ +.output/ +dist/ +build/ +coverage/ +.nyc_output/ +*.log +*.tsbuildinfo +.env +.env.* +.DS_Store \ No newline at end of file diff --git a/.nvmrc b/.nvmrc index 89b93fd..91d5f6f 100644 --- a/.nvmrc +++ b/.nvmrc @@ -1 +1 @@ -22.18.0 \ No newline at end of file +22.18.0 diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..76b7488 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,22 @@ +# Ignore artifacts +.nuxt +.output +dist +build +coverage +.nyc_output + +# Ignore dependencies +node_modules + +# Ignore logs +*.log +*.tsbuildinfo + +# Ignore environment files +.env +.env.* + +# Ignore OS files +.DS_Store + diff --git a/.prettierrc b/.prettierrc new file mode 100644 index 0000000..6f37c6d --- /dev/null +++ b/.prettierrc @@ -0,0 +1,14 @@ +{ + "semi": false, + "singleQuote": true, + "trailingComma": "es5", + "printWidth": 80, + "tabWidth": 2, + "useTabs": false, + "bracketSpacing": true, + "bracketSameLine": false, + "arrowParens": "avoid", + "endOfLine": "lf", + "vueIndentScriptAndStyle": false, + "htmlWhitespaceSensitivity": "ignore" +} diff --git a/app/app.vue b/app/app.vue index 9467ba2..390e010 100644 --- a/app/app.vue +++ b/app/app.vue @@ -8,39 +8,33 @@ - - + + diff --git a/app/pages/[d1]/[d2]/[d3].vue b/app/pages/[d1]/[d2]/[d3].vue index 2509936..28fede4 100644 --- a/app/pages/[d1]/[d2]/[d3].vue +++ b/app/pages/[d1]/[d2]/[d3].vue @@ -1,34 +1,34 @@