diff --git a/docker-compose.yml b/docker-compose.yml index b5ffae7..6159d4e 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -4,11 +4,31 @@ services: container_name: hypixel-auc-notifier build: . restart: unless-stopped + depends_on: + - db env_file: - .env environment: NODE_ENV: "production" + DB_HOST: db + DB_USER: root + DB_PASSWORD: example volumes: - /etc/localtime:/etc/localtime:ro - /etc/timezone:/etc/timezone:ro - - ./config.json:/app/dist/src/config.json \ No newline at end of file + - ./config.json:/app/dist/src/config.json + + + db: + image: mariadb + restart: always + environment: + MARIADB_ROOT_PASSWORD: example + + adminer: + image: adminer + restart: always + depends_on: + - db + ports: + - 8080:8080 \ No newline at end of file diff --git a/index.ts b/index.ts index cccafda..67ab43d 100644 --- a/index.ts +++ b/index.ts @@ -24,7 +24,7 @@ const webhookRegex = /https:\/\/discord.com\/api\/webhooks\/(.+)\/(.+)/; const bazaarPrice = { RECOMBOBULATOR_3000: 0, HOT_POTATO_BOOK: 0, - FUMING_POTATO_BOOK: 0, + FUMING_POTATO_BOOK: 0 }; async function initialize() { @@ -43,16 +43,15 @@ async function initialize() { itemDatas: itemDatas, bazaarData: bazaarPrice, workerNumber: j, - maxPrice: maxPrice, - }, + maxPrice: maxPrice + } }); workers[j].on('message', async (result) => { if (result.itemData !== undefined) { let averagePrice: number | null = itemDatas[result.itemData.id]?.cleanPrice || null; if ( - result.auctionData.lbin - result.auctionData.price >= - config.data.minSnipeProfit && + result.auctionData.lbin - result.auctionData.price >= config.data.minSnipeProfit && (averagePrice || averagePrice! - result.auctionData.price >= config.data.minAvgProfit) ) { let mustBuyMessage = ''; @@ -63,16 +62,11 @@ async function initialize() { .setDescription( `${mustBuyMessage}\nAuction: \`\`\`/viewauction ${result.auctionData.auctionID}\`\`\` - \nProfit: \`${addNotation( - 'oneLetters', - result.auctionData.profit - )} (${result.auctionData.percentProfit}%)\` + \nProfit: \`${addNotation('oneLetters', result.auctionData.profit)} (${result.auctionData.percentProfit + }%)\` \nCost: \`${addNotation('oneLetters', result.auctionData.price)}\` \nLBIN: \`${addNotation('oneLetters', result.auctionData.lbin)}\` - \nSales/Day: \`${addNotation( - 'oneLetters', - result.auctionData.sales - )}\` + \nSales/Day: \`${addNotation('oneLetters', result.auctionData.sales)}\` \nType: \`${result.auctionData.ahType}\` \nAverage Price: \`${averagePrice ? addNotation('oneLetters', averagePrice) : 'N/A'}\`` ); @@ -80,16 +74,14 @@ async function initialize() { await webhook.send({ username: process.env.WEBHOOK_NAME, avatarURL: process.env.WEBHOOK_PROFILE_PICTURE, - embeds: [embed], + embeds: [embed] }); } } else if (result === 'finished') { doneWorkers++; if (doneWorkers === worker_count) { doneWorkers = 0; - console.log( - `Completed in ${(Date.now() - startingTime) / 1000} seconds` - ); + console.log(`Completed in ${(Date.now() - startingTime) / 1000} seconds`); startingTime = 0; workers[0].emit('done'); } @@ -122,9 +114,7 @@ async function initialize() { asyncInterval( async () => { return new Promise(async (resolve) => { - const ahFirstPage = await axios.get( - 'https://api.hypixel.net/skyblock/auctions?page=0' - ); + const ahFirstPage = await axios.get('https://api.hypixel.net/skyblock/auctions?page=0'); const totalPages = ahFirstPage.data.totalPages; if (ahFirstPage.data.lastUpdated === lastUpdated) { resolve(); @@ -156,14 +146,10 @@ async function getLBINs(): Promise { } async function getMoulberry(): Promise { - const moulberryAvgs = await axios.get( - 'https://moulberry.codes/auction_averages/3day.json' - ); + const moulberryAvgs = await axios.get('https://moulberry.codes/auction_averages/3day.json'); const avgData = moulberryAvgs.data; - const cleanPriceAvgs = await axios.get( - 'https://moulberry.codes/auction_averages_lbin/1day.json' - ); + const cleanPriceAvgs = await axios.get('https://moulberry.codes/auction_averages_lbin/1day.json'); const cleanPriceData = cleanPriceAvgs.data; for (const item of Object.keys(avgData)) { @@ -182,12 +168,9 @@ async function getMoulberry(): Promise { async function getBzData(): Promise { const bzData = await axios.get('https://api.hypixel.net/skyblock/bazaar'); - bazaarPrice['RECOMBOBULATOR_3000'] = - bzData.data.products.RECOMBOBULATOR_3000.quick_status.buyPrice; - bazaarPrice['HOT_POTATO_BOOK'] = - bzData.data.products.HOT_POTATO_BOOK.quick_status.buyPrice; - bazaarPrice['FUMING_POTATO_BOOK'] = - bzData.data.products.FUMING_POTATO_BOOK.quick_status.buyPrice; + bazaarPrice['RECOMBOBULATOR_3000'] = bzData.data.products.RECOMBOBULATOR_3000.quick_status.buyPrice; + bazaarPrice['HOT_POTATO_BOOK'] = bzData.data.products.HOT_POTATO_BOOK.quick_status.buyPrice; + bazaarPrice['FUMING_POTATO_BOOK'] = bzData.data.products.FUMING_POTATO_BOOK.quick_status.buyPrice; } initialize();