From 0ea65867a86e24e08dd0641a50a63c795ba01ec9 Mon Sep 17 00:00:00 2001 From: Sirttas Date: Sun, 29 Oct 2023 18:28:05 +0100 Subject: [PATCH] update to mabras rework --- nginx.conf.template | 1 + package.json | 2 +- src/market/type/MarketType.ts | 10 +++--- src/market/type/MarketTypeInput.vue | 3 +- src/service.ts | 14 ++++++++ src/style.css | 2 +- vite.config.ts | 53 ++++++++++++++++++++++++----- 7 files changed, 69 insertions(+), 16 deletions(-) diff --git a/nginx.conf.template b/nginx.conf.template index e0ab0a8..cfc360d 100644 --- a/nginx.conf.template +++ b/nginx.conf.template @@ -13,6 +13,7 @@ server { proxy_ssl_server_name on; proxy_set_header Host "${API_URL}"; proxy_set_header X-Forwarded-Proto https; + sub_filter 'https://${API_URL}/' '/appi/'; } location /pocketbase/ { proxy_pass https://${POCKET_BASE_URL}/; diff --git a/package.json b/package.json index a3d6d16..ea4cb67 100644 --- a/package.json +++ b/package.json @@ -4,7 +4,7 @@ "version": "0.0.0", "type": "module", "scripts": { - "dev": "vite", + "dev": "vite --host", "build": "vue-tsc && vite build", "preview": "vite preview" }, diff --git a/src/market/type/MarketType.ts b/src/market/type/MarketType.ts index 82764d3..e1b617f 100644 --- a/src/market/type/MarketType.ts +++ b/src/market/type/MarketType.ts @@ -20,7 +20,7 @@ export const getMarketTypes = async (types: (string | number)[]): Promise(`/sde/types/${types[0]}/`)).data]; } - return (await apiAxiosInstance.post("/sde/types/search", types.map(t => { + return (await apiAxiosInstance.post("/api/types/search", types.map(t => { if (typeof t === "number") { return { id: t }; } else { @@ -49,9 +49,9 @@ const blueprintMarketGrous = [ // TODO add all groups ] export const searchMarketTypes = async (search: string): Promise => { - return (await apiAxiosInstance.post("/sde/types/search", [{ - name__i: search, - marketgroup_id__not: null, - marketgroup_id__not__in: blueprintMarketGrous, + return (await apiAxiosInstance.post("/api/types/search", [{ + name__icontains: search, + marketgroup_id___not: null, + marketgroup_id__in___not: blueprintMarketGrous, }])).data; } \ No newline at end of file diff --git a/src/market/type/MarketTypeInput.vue b/src/market/type/MarketTypeInput.vue index 72f8e01..736e24b 100644 --- a/src/market/type/MarketTypeInput.vue +++ b/src/market/type/MarketTypeInput.vue @@ -82,6 +82,7 @@ watchEffect(async () => { suggestions.value = []; } else { suggestions.value = await searchMarketTypes(search); + scrollTo(0); } currentIndex.value = -1; }) @@ -94,7 +95,7 @@ watchEffect(async () => {
-
+
diff --git a/src/service.ts b/src/service.ts index cd84a80..ff71fc3 100644 --- a/src/service.ts +++ b/src/service.ts @@ -20,6 +20,20 @@ export const apiAxiosInstance = axios.create({ }, }) logResource(apiAxiosInstance) +apiAxiosInstance.interceptors.response.use(async r => { + const next = r.data?.next; + let results = r.data?.results; + + if (next) { + results = results.concat((await apiAxiosInstance.request({ + ...r.config, + url: next, + baseURL: '', + })).data); + } + r.data = results; + return r; +}) export const evepraisalAxiosInstance = axios.create({ baseURL: '/appraisal/', diff --git a/src/style.css b/src/style.css index 6c72298..377ac32 100644 --- a/src/style.css +++ b/src/style.css @@ -49,7 +49,7 @@ @apply w-3; } ::-webkit-scrollbar-track { - @apply bg-slate-500; + @apply bg-slate-500 rounded; } ::-webkit-scrollbar-thumb { @apply bg-slate-600 hover:bg-slate-700; diff --git a/vite.config.ts b/vite.config.ts index 6295177..0418ad9 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -1,6 +1,7 @@ import vue from '@vitejs/plugin-vue'; import * as path from "path"; import { defineConfig, loadEnv } from 'vite'; +import zlib from 'zlib'; export default defineConfig(({ mode }) => { const env = loadEnv(mode, process.cwd(), ''); @@ -17,30 +18,66 @@ export default defineConfig(({ mode }) => { server: { port: 3000, strictPort: true, + watch: { + usePolling: true + }, proxy: { '/api/': { - target: `https://${env.API_URL}/`, + target: env.API_URL, changeOrigin: true, followRedirects: true, - rewrite: (path) => path.replace(/^\/api/, ''), + rewrite: path => path.replace(/^\/api/, ''), + selfHandleResponse: true, + configure: proxy => { + proxy.on('proxyRes', (proxyRes, req, res) => { + const chunks = []; + + proxyRes.on("data", (chunk) => chunks.push(chunk)); + proxyRes.on("end", () => { + const buffer = Buffer.concat(chunks); + const encoding = proxyRes.headers["content-encoding"]; + const relace = (b: Buffer) => { + let remoteBody = b.toString(); + const modifiedBody = remoteBody.replace(env.API_URL, '/api/'); + + res.write(modifiedBody); + res.end(); + } + + if (!encoding) { + relace(buffer); + } else if (encoding === "gzip" || encoding === "deflate") { + zlib.unzip(buffer, (err, b) => { + if (!err) { + relace(b); + } else { + console.error(err); + } + }); + } else { + console.error(`Unsupported encoding: ${encoding}`); + } + }); + }); + } }, '/pocketbase/': { - target: `https://${env.POCKET_BASE_URL}/`, + target: env.POCKET_BASE_URL, changeOrigin: true, followRedirects: true, - rewrite: (path) => path.replace(/^\/pocketbase/, ''), + rewrite: path => path.replace(/^\/pocketbase/, ''), }, '/appraisal/': { - target: `https://${env.EVEPRAISAL_URL}/`, + target: env.EVEPRAISAL_URL, changeOrigin: true, followRedirects: true, - rewrite: (path) => path.replace(/^\/appraisal/, ''), + rewrite: path => path.replace(/^\/appraisal/, ''), }, '/esi/': { - target: `https://${env.ESI_URL}/latest/`, + target: env.ESI_URL, changeOrigin: true, followRedirects: true, - rewrite: (path) => path.replace(/^\/esi/, ''), + rewrite: path => path.replace(/^\/esi/, ''), headers: { 'User-Agent': env.ESI_USER_AGENT },