diff --git a/Dockerfile.dev b/Dockerfile.dev deleted file mode 100644 index f25be24..0000000 --- a/Dockerfile.dev +++ /dev/null @@ -1,31 +0,0 @@ -# This is making minimal changes from the guide at -# https://bun.sh/guides/ecosystem/docker (as of 2024-02-04) - -# use the official Bun image -# see all versions at https://hub.docker.com/r/oven/bun/tags -FROM oven/bun:1-alpine as base -WORKDIR /app - -# install dependencies into temp directory -# this will cache them and speed up future builds -FROM base as install -RUN mkdir -p /tmp/dev -COPY package.json bun.lockb /temp/dev/ -RUN cd /temp/dev && bun install --frozen-lockfile - -# install with --production (exclude devDependencies) -RUN mkdir -p /temp/prod -COPY package.json bun.lockb /temp/prod/ -RUN cd /temp/prod && bun install --frozen-lockfile --production -# ^ Is this necessary? Don't we either need prod or not prod? - -# copy node_modules from temp directory -# then copy all (non-ignored) project files into the image -FROM base AS prerelease -COPY --from=install /temp/dev/node_modules node_modules -COPY . . - -FROM nginx:stable-alpine as release - -COPY --from=build-stage /app/docker/nginx.conf /etc/nginx/nginx.conf -COPY --from=build-stage /app/dist /usr/share/nginx/html diff --git a/bun.lockb b/bun.lockb index 6e01c21..4a06b74 100755 Binary files a/bun.lockb and b/bun.lockb differ diff --git a/package.json b/package.json index b08cacf..5bc75ce 100644 --- a/package.json +++ b/package.json @@ -15,6 +15,7 @@ }, "dependencies": { "axios": "^1.6.5", + "axios-retry": "^4.0.0", "pinia": "^2.1.7", "sass": "^1.69.7", "vue": "^3.3.11", diff --git a/public/config.json b/public/config.json new file mode 100644 index 0000000..4d58f70 --- /dev/null +++ b/public/config.json @@ -0,0 +1,3 @@ +{ + "apiBaseUrl": "http://localhost:3000" +} \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 1ff243c..4dce636 100644 --- a/src/main.ts +++ b/src/main.ts @@ -12,12 +12,13 @@ import '@mdi/font/css/materialdesignicons.css' import { createVuetify } from 'vuetify' import * as components from 'vuetify/components' import * as directives from 'vuetify/directives' +import axios from 'axios' const vuetify = createVuetify({ components, directives, icons: { - defaultSet: 'mdi', + defaultSet: 'mdi' }, theme: { defaultTheme: 'dark' @@ -25,9 +26,19 @@ const vuetify = createVuetify({ }) const app = createApp(App) - -app.use(createPinia()) +const pinia = createPinia() +app.use(pinia) app.use(router) app.use(vuetify) -app.mount('#app') +// Fetch my config +axios + .get('/config.json?noCache=' + Date.now()) + .then((resp) => { + app.config.globalProperties.$apiBaseUrl = resp.data.apiBaseUrl + + app.mount('#app') + }) + .catch((err) => { + console.log(err) + }) diff --git a/src/stores/powerItems.ts b/src/stores/powerItems.ts index f979e49..35dd629 100644 --- a/src/stores/powerItems.ts +++ b/src/stores/powerItems.ts @@ -1,7 +1,22 @@ import type { PowerItem } from '@/types/PowerItem' -import axios from 'axios' +import axios, { type AxiosRequestConfig } from 'axios' import { defineStore } from 'pinia' import { computed, ref, toRaw } from 'vue' +import axiosRetry from 'axios-retry' +import { getCurrentInstance } from 'vue' + +const BLESSING = 1 +const INTIMACY = 2 +const FELLOW = 3 + +const noCacheConfig:AxiosRequestConfig = { + responseType: "json", + headers: { + 'Cache-Control': 'no-cache', + 'Pragma': 'no-cache', + 'Expires': '0', + } +} export const usePowerItems = defineStore('powerItems', () => { const BLESSING_POWER_ITEM_STORAGE = 'BLESSING_POWER_ITEM_STORAGE' @@ -11,16 +26,16 @@ export const usePowerItems = defineStore('powerItems', () => { const fellowPowerItems = ref(new Map()) const intimacyPowerItems = ref(new Map()) const isLoadComplete = ref(false) + const apiBaseUrl = getCurrentInstance()?.appContext.config.globalProperties.$apiBaseUrl + + axiosRetry(axios, { + retries: 3, + retryDelay: axiosRetry.exponentialDelay, + }) async function fetchPowerItems() { axios - .get('/items/blessingPowerItems.json', { - headers: { - 'Cache-Control': 'no-cache', - Pragma: 'no-cache', - Expires: '0' - } - }) + .get(apiBaseUrl + '/powerItem/byType/' + BLESSING + '/asMap', noCacheConfig) .then((resp) => { const plainMap = new Map( Object.entries(JSON.parse(localStorage.getItem(BLESSING_POWER_ITEM_STORAGE) || '{}')) @@ -36,13 +51,7 @@ export const usePowerItems = defineStore('powerItems', () => { console.log(err) }) axios - .get('/items/fellowPowerItems.json', { - headers: { - 'Cache-Control': 'no-cache', - Pragma: 'no-cache', - Expires: '0' - } - }) + .get(apiBaseUrl + '/powerItem/byType/' + FELLOW + '/asMap', noCacheConfig) .then((resp) => { const plainMap = new Map( Object.entries(JSON.parse(localStorage.getItem(FELLOW_POWER_ITEM_STORAGE) || '{}')) @@ -58,13 +67,7 @@ export const usePowerItems = defineStore('powerItems', () => { console.log(err) }) axios - .get('/items/intimacyPowerItems.json', { - headers: { - 'Cache-Control': 'no-cache', - Pragma: 'no-cache', - Expires: '0' - } - }) + .get(apiBaseUrl + '/powerItem/byType/' + INTIMACY + '/asMap', noCacheConfig) .then((resp) => { const plainMap = new Map( Object.entries(JSON.parse(localStorage.getItem(INTIMACY_POWER_ITEM_STORAGE) || '{}'))