fuzzwork
This commit is contained in:
@@ -28,10 +28,18 @@ server {
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
}
|
||||
location /evepraisal/ {
|
||||
proxy_pass https://${EVEPRAISAL_URL}/;
|
||||
proxy_pass https://${FUZZWORK_URL}/;
|
||||
proxy_http_version 1.1;
|
||||
rewrite /evepraisal/(.*) /$1 break;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_set_header Host "${FUZZWORK_URL}";
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
}
|
||||
location /fuzzwork/ {
|
||||
proxy_pass https://${EVEPRAISAL_URL}/;
|
||||
proxy_http_version 1.1;
|
||||
rewrite /fuzzwork/(.*) /$1 break;
|
||||
proxy_ssl_server_name on;
|
||||
proxy_set_header Host "${EVEPRAISAL_URL}";
|
||||
proxy_set_header X-Forwarded-Proto https;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
"version": "0.0.0",
|
||||
"type": "module",
|
||||
"scripts": {
|
||||
"dev": "vite --host",
|
||||
"dev": "vite --host --debug",
|
||||
"build": "vue-tsc && vite build",
|
||||
"preview": "vite preview"
|
||||
},
|
||||
|
||||
@@ -3,6 +3,7 @@ import { ref } from 'vue';
|
||||
import { MarketType } from "../type";
|
||||
import { MarketTypePrice } from './MarketTypePrice';
|
||||
import { getEvepraisalPrices } from './evepraisal';
|
||||
import { getfuzzworkPrices } from './fuzzwork';
|
||||
|
||||
type MarketTypePriceCache = {
|
||||
price: MarketTypePrice,
|
||||
@@ -10,11 +11,15 @@ type MarketTypePriceCache = {
|
||||
}
|
||||
|
||||
const cacheDuration = 1000 * 60 * 5; // 5 minutes
|
||||
const priceGetters = {
|
||||
evepraisal: getEvepraisalPrices,
|
||||
fuzzwork: getfuzzworkPrices
|
||||
}
|
||||
|
||||
export const useApraisalStore = defineStore('appraisal', () => {
|
||||
const cache = ref<Record<number, MarketTypePriceCache>>({});
|
||||
|
||||
const getPricesUncached = getEvepraisalPrices;
|
||||
const getPricesUncached = priceGetters.fuzzwork;
|
||||
|
||||
const getPrice = async (type: MarketType): Promise<MarketTypePrice> => (await getPrices([type]))[0];
|
||||
const getPrices = async (types: MarketType[]): Promise<MarketTypePrice[]> => {
|
||||
|
||||
@@ -1,10 +1,20 @@
|
||||
import { evepraisalAxiosInstance } from '@/service';
|
||||
import { logResource } from '@/service';
|
||||
import axios from 'axios';
|
||||
import { MarketType } from "../type";
|
||||
import { MarketTypePrice, PriceGetter } from './MarketTypePrice';
|
||||
import { PriceGetter } from './MarketTypePrice';
|
||||
|
||||
export const evepraisalAxiosInstance = axios.create({
|
||||
baseURL: '/evepraisal/',
|
||||
headers: {
|
||||
'accept': 'application/json',
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
})
|
||||
logResource(evepraisalAxiosInstance)
|
||||
|
||||
const batchSize = 100;
|
||||
|
||||
export const getEvepraisalPrices: PriceGetter = async (types: MarketType[]): Promise<MarketTypePrice[]> => {
|
||||
export const getEvepraisalPrices: PriceGetter = async types => {
|
||||
const batches = [];
|
||||
|
||||
for (let i = 0; i < types.length; i += batchSize) {
|
||||
|
||||
36
src/market/appraisal/fuzzwork.ts
Normal file
36
src/market/appraisal/fuzzwork.ts
Normal file
@@ -0,0 +1,36 @@
|
||||
import { logResource } from '@/service';
|
||||
import axios from 'axios';
|
||||
import { MarketType } from "../type";
|
||||
import { PriceGetter } from './MarketTypePrice';
|
||||
|
||||
export const fuzzworkAxiosInstance = axios.create({
|
||||
baseURL: '/fuzzwork/',
|
||||
headers: {
|
||||
'accept': 'application/json',
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
})
|
||||
logResource(fuzzworkAxiosInstance)
|
||||
|
||||
const batchSize = 100;
|
||||
|
||||
export const getfuzzworkPrices: PriceGetter = async types => {
|
||||
const batches = [];
|
||||
|
||||
for (let i = 0; i < types.length; i += batchSize) {
|
||||
batches.push(fuzzworkAxiosInstance.post(`/aggregates/?station=60003760&types=${types.slice(i, i + batchSize).map(t => t.id).join(",")}`));
|
||||
}
|
||||
return (await Promise.all(batches))
|
||||
.flatMap(b => Object.entries(b.data))
|
||||
.map(entry => {
|
||||
const id = parseInt(entry[0]);
|
||||
const prices = entry[1] as any;
|
||||
|
||||
return {
|
||||
type: types.find(t => t.id === id) as MarketType,
|
||||
buy: parseFloat(prices.buy.max),
|
||||
sell: parseFloat(prices.sell.min),
|
||||
orderCount: parseInt(prices.buy.order_count) + parseInt(prices.sell.order_count)
|
||||
}
|
||||
});
|
||||
};
|
||||
@@ -1,5 +1,5 @@
|
||||
<script setup lang="ts">
|
||||
import { evepraisalAxiosInstance } from '@/service';
|
||||
import { evepraisalAxiosInstance } from '@/market/appraisal/evepraisal';
|
||||
import { useVModel } from '@vueuse/core';
|
||||
|
||||
interface Props {
|
||||
|
||||
@@ -2,7 +2,7 @@ import axios, { AxiosInstance } from 'axios';
|
||||
import log from 'loglevel';
|
||||
|
||||
|
||||
const logResource = (a: AxiosInstance) => {
|
||||
export const logResource = (a: AxiosInstance) => {
|
||||
a.interceptors.response.use(r => {
|
||||
log.debug(`[${r.config.method?.toUpperCase()}] ${r.config.url}`);
|
||||
return r;
|
||||
@@ -43,15 +43,6 @@ marbasAxiosInstance.interceptors.response.use(async r => {
|
||||
return r;
|
||||
})
|
||||
|
||||
export const evepraisalAxiosInstance = axios.create({
|
||||
baseURL: '/evepraisal/',
|
||||
headers: {
|
||||
'accept': 'application/json',
|
||||
"Content-Type": "application/json"
|
||||
},
|
||||
})
|
||||
logResource(evepraisalAxiosInstance)
|
||||
|
||||
export const esiAxiosInstance = axios.create({
|
||||
baseURL: '/esi/',
|
||||
headers: {
|
||||
|
||||
@@ -73,6 +73,12 @@ export default defineConfig(({ mode }) => {
|
||||
followRedirects: true,
|
||||
rewrite: path => path.replace(/^\/evepraisal/, ''),
|
||||
},
|
||||
'/fuzzwork/': {
|
||||
target: env.FUZZWORK_URL,
|
||||
changeOrigin: true,
|
||||
followRedirects: true,
|
||||
rewrite: path => path.replace(/^\/fuzzwork/, ''),
|
||||
},
|
||||
'/esi/': {
|
||||
target: env.ESI_URL,
|
||||
changeOrigin: true,
|
||||
|
||||
Reference in New Issue
Block a user