Compare commits
83 Commits
76fdee2cfc
...
monorepo-t
| Author | SHA1 | Date | |
|---|---|---|---|
| 51f418353d | |||
| 57ebf51a0a | |||
| 9bfd3bdc01 | |||
| 862cbd3af1 | |||
| 78fd1b5adf | |||
| 1af1048670 | |||
| 148a3693b9 | |||
| efb1cba216 | |||
| 755cb06276 | |||
| a40390a30e | |||
| 9d5d49c9f2 | |||
| fe1cf2f171 | |||
| d3cb737972 | |||
| 7a0480fa69 | |||
| a77fefc251 | |||
| ad10f35e19 | |||
| 0df5022493 | |||
| ccf1aaba9b | |||
| 5433c7a1d2 | |||
| 0863a73625 | |||
| ba28925d3c | |||
| b96feef044 | |||
| 9387994d6d | |||
| e13d6a7f4a | |||
| b956bb525d | |||
| 3c888dc7f1 | |||
| f7b78f6d0f | |||
| 04a3ea5a23 | |||
| 0b808328f4 | |||
| 55ecb3b12b | |||
| d366262636 | |||
| 714ef9c87f | |||
| 41116e6ef1 | |||
| b56f1b0b62 | |||
| 5aab4a955b | |||
| 3f60cba322 | |||
| f8e36fc519 | |||
| 9937a407de | |||
| 92395f9db1 | |||
| f649cc2c14 | |||
| 3f3e851590 | |||
| dc54effc83 | |||
| 6951ce5db7 | |||
| 10516d84e6 | |||
| 307dfc2433 | |||
| 42c66ac8da | |||
| 7d70bec13b | |||
| fcff4f50c1 | |||
| 72a395e813 | |||
| 3877a37e7e | |||
| cbffc25a78 | |||
| 131a0b23f5 | |||
| 4f54d08666 | |||
| 76bf04f8de | |||
| 12a482324c | |||
| e733ca9cc3 | |||
| 66212c9a7d | |||
| 34c1e577f4 | |||
| 3d3d145072 | |||
| 7e31449bd2 | |||
| 9d663510bc | |||
| 2c4cd8ca5d | |||
| 2198e134d6 | |||
| 2df13c117a | |||
| 789fb6f38d | |||
| 946a9afeac | |||
| beb5ff052f | |||
| 6ce512cac4 | |||
| 773797757c | |||
| 9d6735bd40 | |||
| 648af4f060 | |||
| 9e216f821f | |||
| ff2cc92b5f | |||
| 1e397af280 | |||
| dcb3c2102e | |||
| 1e6be9bfd9 | |||
| ff444d6de2 | |||
| 382ee2f39a | |||
| d56c127306 | |||
| fc01b7e7b9 | |||
| edb82fdcfa | |||
| b57e3e5cba | |||
| fd32ca704a |
71
.drone.yml
@@ -1,24 +1,65 @@
|
|||||||
kind: pipeline
|
kind: pipeline
|
||||||
type: ssh
|
type: ssh
|
||||||
name: default
|
name: install dependencies
|
||||||
|
|
||||||
server:
|
server:
|
||||||
host: 192.168.1.54
|
host: warframe.center
|
||||||
user: pi
|
user: webmaster
|
||||||
password:
|
ssh_key:
|
||||||
from_secret: password
|
from_secret: ssh_private_key
|
||||||
|
|
||||||
|
clone:
|
||||||
|
disable: true
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- name: pull
|
- name: fetch remote
|
||||||
commands:
|
commands:
|
||||||
- cd /home/pi/warframe-market-bot
|
- cd /home/webmaster/warframe-center && git fetch --all && git reset --hard origin/monorepo-ts
|
||||||
- git fetch --all
|
- name: install dependencies
|
||||||
- git reset --hard origin/master
|
|
||||||
- name: install
|
|
||||||
commands:
|
commands:
|
||||||
- cd /home/pi/warframe-market-bot
|
- export PATH=$PATH:/home/webmaster/.nvm/versions/node/v16.14.2/bin
|
||||||
- npm install
|
- cd /home/webmaster/warframe-center && yarn install --immutable
|
||||||
- name: restart
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- monorepo-ts
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
kind: pipeline
|
||||||
|
type: docker
|
||||||
|
name: build
|
||||||
|
|
||||||
|
clone:
|
||||||
|
disable: true
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: bulid frontend
|
||||||
|
image: node:16
|
||||||
|
environment:
|
||||||
|
SSH_PRIVATE_KEY:
|
||||||
|
from_secret: SSH_PRIVATE_KEY
|
||||||
|
MONGODB_URI:
|
||||||
|
from_secret: MONGODB_URI
|
||||||
commands:
|
commands:
|
||||||
- export PM2_HOME=/home/pi/.pm2
|
- git clone -b monorepo-ts https://git.radner.ru/anatolykopyl/warframe-center.git
|
||||||
- pm2 restart warframe-market-bot
|
- cd warframe-center
|
||||||
|
- yarn install --immutable
|
||||||
|
- yarn workspace frontend run build
|
||||||
|
- mkdir ~/.ssh
|
||||||
|
- echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa
|
||||||
|
- chmod 400 ~/.ssh/id_rsa
|
||||||
|
- scp -o StrictHostKeyChecking=no -r ./frontend/.next webmaster@warframe.center:~/warframe-center/frontend
|
||||||
|
- |
|
||||||
|
ssh -o StrictHostKeyChecking=no webmaster@warframe.center '
|
||||||
|
[ -s ~/.nvm/nvm.sh ] && source ~/.nvm/nvm.sh &&
|
||||||
|
nvm use default &&
|
||||||
|
pm2 restart warframe-center-app-3000
|
||||||
|
'
|
||||||
|
|
||||||
|
depends_on:
|
||||||
|
- install dependencies
|
||||||
|
|
||||||
|
trigger:
|
||||||
|
branch:
|
||||||
|
- monorepo-ts
|
||||||
|
|||||||
2
.gitignore
vendored
@@ -1,5 +1,5 @@
|
|||||||
node_modules
|
node_modules
|
||||||
|
.yarn
|
||||||
.DS_Store
|
.DS_Store
|
||||||
.vscode
|
.vscode
|
||||||
.env
|
.env
|
||||||
public/index.html
|
|
||||||
|
|||||||
3
.yarnrc.yml
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
nodeLinker: node-modules
|
||||||
|
|
||||||
|
yarnPath: .yarn/releases/yarn-3.2.1.cjs
|
||||||
@@ -3,3 +3,5 @@
|
|||||||
Список Прайм предметов: https://warframe.fandom.com/wiki/Prime
|
Список Прайм предметов: https://warframe.fandom.com/wiki/Prime
|
||||||
|
|
||||||
Маркет: https://warframe.market
|
Маркет: https://warframe.market
|
||||||
|
|
||||||
|
Документация API маркета: https://warframe.market/api_docs
|
||||||
|
|||||||
31
api.js
@@ -1,31 +0,0 @@
|
|||||||
const axios = require('axios')
|
|
||||||
const { RateLimiter } = require('limiter')
|
|
||||||
|
|
||||||
class Api {
|
|
||||||
constructor () {
|
|
||||||
this.baseUrl = 'https://api.warframe.market/v1/'
|
|
||||||
this.delay = process.env.API_DELAY ?? 3000
|
|
||||||
this.limiter = new RateLimiter({ tokensPerInterval: 1, interval: Number(this.delay) })
|
|
||||||
}
|
|
||||||
|
|
||||||
async _get (url) {
|
|
||||||
await this.limiter.removeTokens(1)
|
|
||||||
return axios.get(url)
|
|
||||||
}
|
|
||||||
|
|
||||||
async getOrders (url) {
|
|
||||||
const response = await this._get(this.baseUrl + 'items/' + url + '/orders')
|
|
||||||
return response.data.payload.orders.filter(function (order) {
|
|
||||||
return order.order_type === 'sell' && order.user.status !== 'offline'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
async getSortedOrders (url) {
|
|
||||||
const orders = await this.getOrders(url)
|
|
||||||
return orders.sort(function (a, b) {
|
|
||||||
return a.platinum - b.platinum
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = new Api()
|
|
||||||
1
frontend/.env.local.example
Normal file
@@ -0,0 +1 @@
|
|||||||
|
MONGODB_URI=
|
||||||
15
frontend/.eslintrc.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"extends": ["standard", "standard-jsx", "standard-react", "next/core-web-vitals"],
|
||||||
|
"rules": {
|
||||||
|
"import/order": [
|
||||||
|
"error",
|
||||||
|
{
|
||||||
|
"newlines-between": "always",
|
||||||
|
"alphabetize": {
|
||||||
|
"order": "asc",
|
||||||
|
"caseInsensitive": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
30
frontend/.gitignore
vendored
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.
|
||||||
|
|
||||||
|
# dependencies
|
||||||
|
/node_modules
|
||||||
|
/.pnp
|
||||||
|
.pnp.js
|
||||||
|
|
||||||
|
# testing
|
||||||
|
/coverage
|
||||||
|
|
||||||
|
# next.js
|
||||||
|
/.next/
|
||||||
|
/out/
|
||||||
|
|
||||||
|
# production
|
||||||
|
/build
|
||||||
|
|
||||||
|
# misc
|
||||||
|
.DS_Store
|
||||||
|
|
||||||
|
# debug
|
||||||
|
npm-debug.log*
|
||||||
|
yarn-debug.log*
|
||||||
|
yarn-error.log*
|
||||||
|
|
||||||
|
# local env files
|
||||||
|
.env.local
|
||||||
|
.env.development.local
|
||||||
|
.env.test.local
|
||||||
|
.env.production.local
|
||||||
33
frontend/components/Footer.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
import { Box, Typography, Link } from '@mui/material'
|
||||||
|
import { Component } from 'react'
|
||||||
|
|
||||||
|
export default class Footer extends Component {
|
||||||
|
render () {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
p: 12
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
All data is collected from the
|
||||||
|
<Link
|
||||||
|
href='https://warframe.market/api_docs'
|
||||||
|
target='_blank'
|
||||||
|
rel='noreferrer'
|
||||||
|
>
|
||||||
|
Warframe Market API
|
||||||
|
</Link>
|
||||||
|
|
||||||
|
<Typography variant='h6'>DISCLAIMER</Typography>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
fontSize: 12,
|
||||||
|
lineHeight: 'normal'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
Digital Extremes Ltd, Warframe and the logo Warframe are registered trademarks. All rights are reserved worldwide. This site has no official link with Digital Extremes Ltd or Warframe. All artwork, screenshots, characters or other recognizable features of the intellectual property relating to these trademarks are likewise the intellectual property of Digital Extremes Ltd.
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
37
frontend/components/WithYandexMetrika.js
Normal file
@@ -0,0 +1,37 @@
|
|||||||
|
import Router from 'next/router'
|
||||||
|
import React, { useCallback, useEffect } from 'react'
|
||||||
|
import ym, { YMInitializer } from 'react-yandex-metrika'
|
||||||
|
|
||||||
|
const WithYandexMetrika = (props) => {
|
||||||
|
const { children } = props
|
||||||
|
|
||||||
|
const enabled = process.env.NODE_ENV !== 'development'
|
||||||
|
|
||||||
|
const hit = useCallback((url) => {
|
||||||
|
if (enabled) {
|
||||||
|
ym('hit', url)
|
||||||
|
} else {
|
||||||
|
console.log('%c[YandexMetrika](HIT)', 'color: orange', url)
|
||||||
|
}
|
||||||
|
}, [enabled])
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
hit(window.location.pathname + window.location.search)
|
||||||
|
Router.events.on('routeChangeComplete', hit)
|
||||||
|
}, [hit])
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
{enabled && (
|
||||||
|
<YMInitializer
|
||||||
|
accounts={[87671663]}
|
||||||
|
options={{ webvisor: true, defer: true }}
|
||||||
|
version='2'
|
||||||
|
/>
|
||||||
|
)}
|
||||||
|
{children}
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default WithYandexMetrika
|
||||||
16
frontend/components/layout.js
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
import Head from 'next/head'
|
||||||
|
|
||||||
|
import Footer from './Footer'
|
||||||
|
|
||||||
|
export default function Layout ({ children }) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Head>
|
||||||
|
<title>Warframe Center</title>
|
||||||
|
<link rel='icon' href='/favicon.ico' />
|
||||||
|
</Head>
|
||||||
|
<main>{children}</main>
|
||||||
|
<Footer />
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
7
frontend/ecosystem.config.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
module.exports = {
|
||||||
|
apps: [{
|
||||||
|
name: 'warframe-center-app-3000',
|
||||||
|
script: 'npm run start',
|
||||||
|
watch: false
|
||||||
|
}]
|
||||||
|
}
|
||||||
43
frontend/lib/dbConnect.js
Normal file
@@ -0,0 +1,43 @@
|
|||||||
|
import mongoose from 'mongoose'
|
||||||
|
|
||||||
|
const MONGODB_URI = process.env.MONGODB_URI
|
||||||
|
|
||||||
|
if (!MONGODB_URI) {
|
||||||
|
throw new Error(
|
||||||
|
'Please define the MONGODB_URI environment variable inside .env.local'
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Global is used here to maintain a cached connection across hot reloads
|
||||||
|
* in development. This prevents connections growing exponentially
|
||||||
|
* during API Route usage.
|
||||||
|
*/
|
||||||
|
let cached = global.mongoose
|
||||||
|
|
||||||
|
if (!cached) {
|
||||||
|
cached = global.mongoose = { conn: null, promise: null }
|
||||||
|
}
|
||||||
|
|
||||||
|
async function dbConnect () {
|
||||||
|
if (cached.conn) {
|
||||||
|
return cached.conn
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!cached.promise) {
|
||||||
|
const opts = {
|
||||||
|
useNewUrlParser: true,
|
||||||
|
useUnifiedTopology: true,
|
||||||
|
bufferCommands: false
|
||||||
|
}
|
||||||
|
|
||||||
|
cached.promise = mongoose.connect(MONGODB_URI, opts)
|
||||||
|
.then(mongoose => {
|
||||||
|
return mongoose
|
||||||
|
})
|
||||||
|
}
|
||||||
|
cached.conn = await cached.promise
|
||||||
|
return cached.conn
|
||||||
|
}
|
||||||
|
|
||||||
|
export default dbConnect
|
||||||
6
frontend/next-i18next.config.js
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
module.exports = {
|
||||||
|
i18n: {
|
||||||
|
defaultLocale: 'en',
|
||||||
|
locales: ['en', 'ru']
|
||||||
|
}
|
||||||
|
}
|
||||||
31
frontend/next.config.js
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
const withPlugins = require('next-compose-plugins')
|
||||||
|
|
||||||
|
const { i18n } = require('./next-i18next.config')
|
||||||
|
|
||||||
|
/** @type {import('next').NextConfig} */
|
||||||
|
const nextConfig = {
|
||||||
|
reactStrictMode: true,
|
||||||
|
i18n
|
||||||
|
// webpack: (config, { webpack }) => {
|
||||||
|
// return config
|
||||||
|
// },
|
||||||
|
}
|
||||||
|
|
||||||
|
const redirects = {
|
||||||
|
async redirects () {
|
||||||
|
return [
|
||||||
|
{
|
||||||
|
source: '/',
|
||||||
|
destination: '/home',
|
||||||
|
permanent: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = withPlugins(
|
||||||
|
[
|
||||||
|
[redirects]
|
||||||
|
],
|
||||||
|
nextConfig
|
||||||
|
)
|
||||||
42
frontend/package.json
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
{
|
||||||
|
"name": "frontend",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"scripts": {
|
||||||
|
"dev": "next dev",
|
||||||
|
"build": "next build",
|
||||||
|
"start": "next start"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@emotion/react": "^11.8.2",
|
||||||
|
"@emotion/styled": "^11.8.1",
|
||||||
|
"@mui/icons-material": "^5.5.0",
|
||||||
|
"@mui/material": "^5.5.0",
|
||||||
|
"@mui/x-data-grid": "^5.6.1",
|
||||||
|
"moment": "^2.29.4",
|
||||||
|
"mongoose": "^6.4.3",
|
||||||
|
"next": "latest",
|
||||||
|
"next-compose-plugins": "^2.2.1",
|
||||||
|
"next-i18next": "^11.0.0",
|
||||||
|
"react": "^17.0.2",
|
||||||
|
"react-dom": "^17.0.2",
|
||||||
|
"react-moment": "^1.1.1",
|
||||||
|
"react-yandex-metrika": "^2.6.0",
|
||||||
|
"reset-css": "^5.0.1",
|
||||||
|
"sass": "^1.49.9",
|
||||||
|
"shared-stuff": "1.0.0",
|
||||||
|
"sharp": "^0.30.3"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"babel-eslint": "^10.1.0",
|
||||||
|
"eslint": "^8.11.0",
|
||||||
|
"eslint-config-next": "^12.1.0",
|
||||||
|
"eslint-config-standard": "^16.0.3",
|
||||||
|
"eslint-config-standard-jsx": "^10.0.0",
|
||||||
|
"eslint-config-standard-react": "^11.0.1",
|
||||||
|
"eslint-plugin-import": "^2.25.4",
|
||||||
|
"eslint-plugin-node": "^11.1.0",
|
||||||
|
"eslint-plugin-promise": "^6.0.0",
|
||||||
|
"eslint-plugin-react": "^7.29.3"
|
||||||
|
}
|
||||||
|
}
|
||||||
29
frontend/pages/_app.js
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { CssBaseline } from '@mui/material'
|
||||||
|
import { createTheme, ThemeProvider } from '@mui/material/styles'
|
||||||
|
import { appWithTranslation } from 'next-i18next'
|
||||||
|
|
||||||
|
import 'reset-css'
|
||||||
|
import '../styles/global.scss'
|
||||||
|
import Layout from '../components/layout'
|
||||||
|
import WithYandexMetrika from '../components/WithYandexMetrika'
|
||||||
|
|
||||||
|
function App ({ Component, pageProps }) {
|
||||||
|
const theme = createTheme({
|
||||||
|
palette: {
|
||||||
|
mode: 'light'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
return (
|
||||||
|
<WithYandexMetrika>
|
||||||
|
<ThemeProvider theme={theme}>
|
||||||
|
<CssBaseline />
|
||||||
|
<Layout>
|
||||||
|
<Component {...pageProps} />
|
||||||
|
</Layout>
|
||||||
|
</ThemeProvider>
|
||||||
|
</WithYandexMetrika>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default appWithTranslation(App)
|
||||||
32
frontend/pages/home/HelpModal.js
Normal file
@@ -0,0 +1,32 @@
|
|||||||
|
import { Dialog, DialogTitle, Box, Typography } from '@mui/material'
|
||||||
|
import { useTranslation } from 'next-i18next'
|
||||||
|
|
||||||
|
export default function HelpModal ({ open, onClose }) {
|
||||||
|
const { t } = useTranslation('home')
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Dialog
|
||||||
|
open={open}
|
||||||
|
onClose={onClose}
|
||||||
|
>
|
||||||
|
<DialogTitle>
|
||||||
|
{t('help_header')}
|
||||||
|
</DialogTitle>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
p: 3
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Typography gutterBottom>
|
||||||
|
{t('help_body_1')}
|
||||||
|
</Typography>
|
||||||
|
<Typography gutterBottom>
|
||||||
|
{t('help_body_2')}
|
||||||
|
</Typography>
|
||||||
|
<Typography gutterBottom>
|
||||||
|
{t('help_body_3')}
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
</Dialog>
|
||||||
|
)
|
||||||
|
}
|
||||||
73
frontend/pages/home/Hero.js
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
import { Box, Chip } from '@mui/material'
|
||||||
|
import { useTranslation } from 'next-i18next'
|
||||||
|
import Image from 'next/image'
|
||||||
|
import { useState } from 'react'
|
||||||
|
|
||||||
|
import logo from './assets/warframe_logo.png'
|
||||||
|
import HelpModal from './HelpModal'
|
||||||
|
|
||||||
|
const Hero = () => {
|
||||||
|
const { t } = useTranslation('home')
|
||||||
|
const [modalOpen, setModalOpen] = useState(false)
|
||||||
|
|
||||||
|
const openModal = () => {
|
||||||
|
setModalOpen(true)
|
||||||
|
}
|
||||||
|
|
||||||
|
const closeModal = () => {
|
||||||
|
setModalOpen(false)
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
py: 12,
|
||||||
|
textAlign: 'center'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Chip
|
||||||
|
label={t('help_header')}
|
||||||
|
variant='outlined'
|
||||||
|
onClick={openModal}
|
||||||
|
sx={{
|
||||||
|
position: 'absolute',
|
||||||
|
top: '10px',
|
||||||
|
right: '10px'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
width: 400,
|
||||||
|
m: 'auto'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Image
|
||||||
|
src={logo}
|
||||||
|
alt='logo'
|
||||||
|
layout='responsive'
|
||||||
|
width={500}
|
||||||
|
height={300}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
width: 400,
|
||||||
|
m: 'auto'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<h1>Market Gaps</h1>
|
||||||
|
<p>{t('description')}</p>
|
||||||
|
</Box>
|
||||||
|
</Box>
|
||||||
|
|
||||||
|
<HelpModal
|
||||||
|
open={modalOpen}
|
||||||
|
onClose={closeModal}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default Hero
|
||||||
98
frontend/pages/home/Table.js
Normal file
@@ -0,0 +1,98 @@
|
|||||||
|
import { Link, Typography, Box } from '@mui/material'
|
||||||
|
import { DataGrid } from '@mui/x-data-grid'
|
||||||
|
import { Component } from 'react'
|
||||||
|
import { withTranslation } from 'react-i18next'
|
||||||
|
import Moment from 'react-moment'
|
||||||
|
|
||||||
|
class Table extends Component {
|
||||||
|
constructor ({ scanResults, t }) {
|
||||||
|
super()
|
||||||
|
this.scanResults = scanResults
|
||||||
|
? scanResults.map(row => ({
|
||||||
|
...row,
|
||||||
|
id: row._id
|
||||||
|
}))
|
||||||
|
: []
|
||||||
|
this.columns = [
|
||||||
|
{
|
||||||
|
field: 'name',
|
||||||
|
headerName: t('name'),
|
||||||
|
flex: 2,
|
||||||
|
renderCell: (cellValues) => {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
component='span'
|
||||||
|
sx={{
|
||||||
|
display: 'block'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<Link
|
||||||
|
target='_blank'
|
||||||
|
href={cellValues.row.url}
|
||||||
|
rel='noreferrer'
|
||||||
|
>
|
||||||
|
{cellValues.row.fullName}
|
||||||
|
</Link>
|
||||||
|
<Typography variant='caption' display='block'>
|
||||||
|
<Moment
|
||||||
|
format='DD.MM HH:mm'
|
||||||
|
>
|
||||||
|
{cellValues.row.updatedAt}
|
||||||
|
</Moment>
|
||||||
|
</Typography>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'partsPrice',
|
||||||
|
headerName: t('parts_price'),
|
||||||
|
flex: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'setPrice',
|
||||||
|
headerName: t('set_price'),
|
||||||
|
flex: 1
|
||||||
|
},
|
||||||
|
{
|
||||||
|
field: 'difference',
|
||||||
|
headerName: t('difference'),
|
||||||
|
flex: 1
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
static getInitialProps () {
|
||||||
|
return {
|
||||||
|
props: { scanResults: [] }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
render () {
|
||||||
|
return (
|
||||||
|
<Box
|
||||||
|
sx={{
|
||||||
|
height: '90vh',
|
||||||
|
width: '100%'
|
||||||
|
}}
|
||||||
|
>
|
||||||
|
<DataGrid
|
||||||
|
rows={this.scanResults}
|
||||||
|
columns={this.columns}
|
||||||
|
autoPageSize
|
||||||
|
initialState={{
|
||||||
|
sorting: {
|
||||||
|
sortModel: [{ field: 'difference', sort: 'desc' }]
|
||||||
|
}
|
||||||
|
}}
|
||||||
|
sx={{
|
||||||
|
borderLeft: 'none',
|
||||||
|
borderRight: 'none'
|
||||||
|
}}
|
||||||
|
/>
|
||||||
|
</Box>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default withTranslation('home')(Table)
|
||||||
BIN
frontend/pages/home/assets/gunner1.png
Normal file
|
After Width: | Height: | Size: 1.7 MiB |
BIN
frontend/pages/home/assets/gunner2.png
Normal file
|
After Width: | Height: | Size: 1.1 MiB |
BIN
frontend/pages/home/assets/warframe_logo.png
Normal file
|
After Width: | Height: | Size: 234 KiB |
30
frontend/pages/home/index.js
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations'
|
||||||
|
import { models } from 'shared-stuff'
|
||||||
|
|
||||||
|
import dbConnect from '../../lib/dbConnect'
|
||||||
|
|
||||||
|
import Hero from './Hero'
|
||||||
|
import Table from './Table'
|
||||||
|
|
||||||
|
export default function Home ({ scanResults }) {
|
||||||
|
return (
|
||||||
|
<>
|
||||||
|
<Hero />
|
||||||
|
<Table
|
||||||
|
scanResults={scanResults}
|
||||||
|
/>
|
||||||
|
</>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getServerSideProps ({ locale }) {
|
||||||
|
await dbConnect()
|
||||||
|
const scanResults = await models.ScanResult.find({})
|
||||||
|
|
||||||
|
return {
|
||||||
|
props: {
|
||||||
|
scanResults: JSON.parse(JSON.stringify(scanResults)),
|
||||||
|
...(await serverSideTranslations(locale, ['common', 'home']))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
frontend/public/favicon.ico
Normal file
|
After Width: | Height: | Size: 15 KiB |
BIN
frontend/public/locale_icons/de.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
frontend/public/locale_icons/en.png
Normal file
|
After Width: | Height: | Size: 24 KiB |
BIN
frontend/public/locale_icons/fr.png
Normal file
|
After Width: | Height: | Size: 6.9 KiB |
BIN
frontend/public/locale_icons/ru.png
Normal file
|
After Width: | Height: | Size: 8.6 KiB |
BIN
frontend/public/locale_icons/ua.png
Normal file
|
After Width: | Height: | Size: 9.0 KiB |
0
frontend/public/locales/en/common.json
Normal file
11
frontend/public/locales/en/home.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"description": "Find a profitable difference between the price of the set and the price of the sum of it's parts.",
|
||||||
|
"help_header": "How to use this site",
|
||||||
|
"help_body_1": "The main page of the site has a table, that contains info about prime items, that is updated in real time. The column \"Name\" has a link to the item on warframe.market and the time of the last update.",
|
||||||
|
"help_body_2": "Knowing the difference between the price of the set and the price of the sum of it's parts lets you save platinum buying or even make a profit by purchasing the parts and selling them as a set.",
|
||||||
|
"help_body_3": "Have fun!",
|
||||||
|
"name": "Name",
|
||||||
|
"parts_price": "Parts Price",
|
||||||
|
"set_price": "Set Price",
|
||||||
|
"difference": "Difference"
|
||||||
|
}
|
||||||
0
frontend/public/locales/ru/common.json
Normal file
11
frontend/public/locales/ru/home.json
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"description": "Находи выгодную разницу между ценой набора и ценой его частей по отдельности.",
|
||||||
|
"help_header": "Как использовать этот сайт?",
|
||||||
|
"help_body_1": "На главной странице сайта находится таблица, которая содержит информацию о прайм предметах, обновляемую в реальном времени. Колонка \"Наименование\" содержит ссылку на страницу предмета на warframe.market и время последнего обновления информации.",
|
||||||
|
"help_body_2": "Зная разницу между ценой частей и ценой комплекта можно, например сэкономить на покупке или даже заработать, если купить части по отдельности, а продать как сет.",
|
||||||
|
"help_body_3": "Приятного использования!",
|
||||||
|
"name": "Наименование",
|
||||||
|
"parts_price": "Цена частей",
|
||||||
|
"set_price": "Цена набора",
|
||||||
|
"difference": "Разница"
|
||||||
|
}
|
||||||
22
frontend/styles/_fonts.scss
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
$text-font: -apple-system, BlinkMacSystemFont, Segoe UI, Roboto,
|
||||||
|
Oxygen, Ubuntu, Cantarell, Fira Sans, Droid Sans, Helvetica Neue,
|
||||||
|
sans-serif;
|
||||||
|
|
||||||
|
$font-h0: normal normal 300 56px/64px $text-font;
|
||||||
|
$font-h1: normal normal 300 48px/56px $text-font;
|
||||||
|
$font-h2: normal normal 300 40px/48px $text-font;
|
||||||
|
$font-h3: normal normal 300 36px/44px $text-font;
|
||||||
|
$font-h4: normal normal 300 32px/40px $text-font;
|
||||||
|
$font-h5: normal normal 300 28px/36px $text-font;
|
||||||
|
$font-h6: normal normal 300 24px/32px $text-font;
|
||||||
|
$font-h7: normal normal 300 20px/26px $text-font;
|
||||||
|
$font-h8: normal normal 300 18px/24px $text-font;
|
||||||
|
$font-h9: normal normal 300 16px/20px $text-font;
|
||||||
|
|
||||||
|
$font-r8: normal normal 300 24px/30px $text-font;
|
||||||
|
$font-r7: normal normal 300 22px/28px $text-font;
|
||||||
|
$font-r6: normal normal 300 20px/26px $text-font;
|
||||||
|
$font-r5: normal normal 300 18px/24px $text-font;
|
||||||
|
$font-r4: normal normal 300 16px/22px $text-font;
|
||||||
|
$font-r3: normal normal 300 14px/18px $text-font;
|
||||||
|
$font-r2: normal normal 300 12px/16px $text-font;
|
||||||
1
frontend/styles/_variables.scss
Normal file
@@ -0,0 +1 @@
|
|||||||
|
@import './fonts';
|
||||||
31
frontend/styles/global.scss
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
@import './variables';
|
||||||
|
|
||||||
|
html,
|
||||||
|
body {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
font: $font-r4;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
font: $font-h1;
|
||||||
|
}
|
||||||
|
h2 {
|
||||||
|
font: $font-h2;
|
||||||
|
}
|
||||||
|
h3 {
|
||||||
|
font: $font-h3;
|
||||||
|
}
|
||||||
|
h4 {
|
||||||
|
font: $font-h4;
|
||||||
|
}
|
||||||
|
h5 {
|
||||||
|
font: $font-h5;
|
||||||
|
}
|
||||||
|
h6 {
|
||||||
|
font: $font-h6;
|
||||||
|
}
|
||||||
15
gather/.eslintrc.js
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
export default {
|
||||||
|
parser: '@typescript-eslint/parser',
|
||||||
|
extends: 'standard-with-typescript',
|
||||||
|
parserOptions: {
|
||||||
|
project: './tsconfig.json'
|
||||||
|
},
|
||||||
|
rules: {
|
||||||
|
'@typescript-eslint/no-floating-promises': [
|
||||||
|
'error',
|
||||||
|
{
|
||||||
|
ignoreIIFE: true
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
1
gather/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
dist
|
||||||
9
gather/ecosystem.config.js
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
module.exports = {
|
||||||
|
apps: [{
|
||||||
|
name: 'warframe-center-gather',
|
||||||
|
script: './src/index.js',
|
||||||
|
watch: true,
|
||||||
|
ignore_watch: ['node_modules', 'public'],
|
||||||
|
restart_delay: 1 * 60 * 1000
|
||||||
|
}]
|
||||||
|
}
|
||||||
22
gather/package.json
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
{
|
||||||
|
"name": "gather",
|
||||||
|
"private": true,
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "The background job that collects data and stores it in a DB",
|
||||||
|
"scripts": {
|
||||||
|
"start": "node ./dist/src/index.js",
|
||||||
|
"build": "../node_modules/typescript/bin/tsc"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"axios": "^0.26.0",
|
||||||
|
"dotenv": "^16.0.0",
|
||||||
|
"limiter": "^2.1.0",
|
||||||
|
"mongoose": "^6.4.3",
|
||||||
|
"shared-stuff": "1.0.0",
|
||||||
|
"typescript": "^4.7.4"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"eslint-config-standard-with-typescript": "^22.0.0",
|
||||||
|
"pm2": "^5.2.0"
|
||||||
|
}
|
||||||
|
}
|
||||||
59
gather/src/api.ts
Normal file
@@ -0,0 +1,59 @@
|
|||||||
|
import axios from 'axios'
|
||||||
|
import type { AxiosError } from 'axios'
|
||||||
|
import { RateLimiter } from 'limiter'
|
||||||
|
|
||||||
|
type user = {
|
||||||
|
status: 'online' | 'offline'
|
||||||
|
}
|
||||||
|
|
||||||
|
type order = {
|
||||||
|
order_type: 'buy' | 'sell',
|
||||||
|
platinum: number,
|
||||||
|
user: user
|
||||||
|
}
|
||||||
|
|
||||||
|
class Api {
|
||||||
|
baseUrl: string
|
||||||
|
delay: number
|
||||||
|
limiter: RateLimiter
|
||||||
|
|
||||||
|
constructor () {
|
||||||
|
this.baseUrl = 'https://api.warframe.market/v1/'
|
||||||
|
this.delay = Number(process.env.API_DELAY) ?? 3000
|
||||||
|
this.limiter = new RateLimiter({ tokensPerInterval: 1, interval: Number(this.delay) })
|
||||||
|
}
|
||||||
|
|
||||||
|
async _get (url: string) {
|
||||||
|
await this.limiter.removeTokens(1)
|
||||||
|
return axios.get(url).catch((error: AxiosError) => {
|
||||||
|
console.error(error)
|
||||||
|
return {
|
||||||
|
data: {
|
||||||
|
payload: {
|
||||||
|
orders: []
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async getOrders (url: string): Promise<order[]> {
|
||||||
|
const response = await this._get(this.baseUrl + 'items/' + url + '/orders')
|
||||||
|
return response.data.payload.orders.filter(function (order: order) {
|
||||||
|
return order.order_type === 'sell' && order.user.status !== 'offline'
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
async getSortedOrders (url: string): Promise<order[]> {
|
||||||
|
const orders = await this.getOrders(url)
|
||||||
|
if (orders.length === 0) {
|
||||||
|
return []
|
||||||
|
}
|
||||||
|
|
||||||
|
return orders.sort(function (a: order, b: order) {
|
||||||
|
return a.platinum - b.platinum
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default new Api()
|
||||||
40
gather/src/index.ts
Normal file
@@ -0,0 +1,40 @@
|
|||||||
|
import mongoose from 'mongoose'
|
||||||
|
import items from './items'
|
||||||
|
import { models } from 'shared-stuff'
|
||||||
|
import 'dotenv/config'
|
||||||
|
|
||||||
|
async function initDB (): Promise<void> {
|
||||||
|
await mongoose.connect(String(process.env.MONGODB_URI))
|
||||||
|
}
|
||||||
|
|
||||||
|
(async () => {
|
||||||
|
await initDB()
|
||||||
|
|
||||||
|
for (const item of items) {
|
||||||
|
process.stdout.write(`Looking at ${item.name}: `)
|
||||||
|
|
||||||
|
let partsPrice = 0
|
||||||
|
for (const part of item.parts) {
|
||||||
|
process.stdout.write(`${part.part} `)
|
||||||
|
partsPrice += await part.getPrice()
|
||||||
|
}
|
||||||
|
|
||||||
|
const setPrice = await item.set.getPrice()
|
||||||
|
await models.ScanResult.findOneAndUpdate(
|
||||||
|
{ name: item.name },
|
||||||
|
{
|
||||||
|
fullName: item.fullName,
|
||||||
|
url: item.set.url,
|
||||||
|
timestamp: new Date(),
|
||||||
|
partsPrice,
|
||||||
|
setPrice,
|
||||||
|
difference: setPrice - partsPrice
|
||||||
|
},
|
||||||
|
{ upsert: true }
|
||||||
|
)
|
||||||
|
|
||||||
|
console.log('✅')
|
||||||
|
}
|
||||||
|
|
||||||
|
await mongoose.disconnect()
|
||||||
|
})()
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
const Item = require('./Item')
|
import Item from './Item'
|
||||||
|
|
||||||
module.exports = class Archwings extends Item {
|
export default class Archwings extends Item {
|
||||||
constructor (name) {
|
constructor (name: string) {
|
||||||
super(name)
|
super(name)
|
||||||
|
|
||||||
this.addPart('harness')
|
this.addPart('harness')
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
const Item = require('./Item')
|
import Item from './Item'
|
||||||
|
|
||||||
module.exports = class Companion extends Item {
|
export default class Companion extends Item {
|
||||||
constructor (name) {
|
constructor (name: string) {
|
||||||
super(name)
|
super(name)
|
||||||
|
|
||||||
this.addPart('carapace')
|
this.addPart('carapace')
|
||||||
25
gather/src/items/Item.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import Part from './Part'
|
||||||
|
|
||||||
|
function capitalize (string: string) {
|
||||||
|
return string.charAt(0).toUpperCase() + string.slice(1)
|
||||||
|
}
|
||||||
|
|
||||||
|
export default class Item {
|
||||||
|
name: string
|
||||||
|
fullName: string
|
||||||
|
set: Part
|
||||||
|
parts: Part[]
|
||||||
|
|
||||||
|
constructor (name: string) {
|
||||||
|
this.name = name
|
||||||
|
this.fullName = capitalize(name) + ' Prime'
|
||||||
|
this.set = new Part(name, 'set')
|
||||||
|
|
||||||
|
this.parts = []
|
||||||
|
this.addPart('blueprint')
|
||||||
|
}
|
||||||
|
|
||||||
|
addPart (part: string, amount: number = 1) {
|
||||||
|
this.parts.push(new Part(this.name, part, amount))
|
||||||
|
}
|
||||||
|
}
|
||||||
24
gather/src/items/Part.ts
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
import Api from '../api'
|
||||||
|
|
||||||
|
export default class Part {
|
||||||
|
part: string
|
||||||
|
urlPath: string
|
||||||
|
url: string
|
||||||
|
amount: number
|
||||||
|
|
||||||
|
constructor (set: string, part: string, amount: number = 1) {
|
||||||
|
this.part = part
|
||||||
|
this.urlPath = `${set}_prime_${part}`
|
||||||
|
this.url = `https://warframe.market/items/${set}_prime_${part}`
|
||||||
|
this.amount = amount ?? 1
|
||||||
|
}
|
||||||
|
|
||||||
|
async getPrice (): Promise<number> {
|
||||||
|
const orders = await Api.getSortedOrders(this.urlPath)
|
||||||
|
if (orders.length === 0) {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
return Number(orders[0].platinum) * this.amount
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
const Item = require('./Item')
|
import Item from './Item'
|
||||||
|
|
||||||
module.exports = class Primary extends Item {
|
export default class Primary extends Item {
|
||||||
constructor (name) {
|
constructor (name: string) {
|
||||||
super(name)
|
super(name)
|
||||||
|
|
||||||
this.addPart('barrel')
|
this.addPart('barrel')
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
const Item = require('./Item')
|
import Item from './Item'
|
||||||
|
|
||||||
module.exports = class Secondary extends Item {
|
export default class Secondary extends Item {
|
||||||
constructor (name) {
|
constructor (name: string) {
|
||||||
super(name)
|
super(name)
|
||||||
|
|
||||||
this.addPart('barrel', 2)
|
this.addPart('barrel', 2)
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
const Item = require('./Item')
|
import Item from './Item'
|
||||||
|
|
||||||
module.exports = class Warframe extends Item {
|
export default class Warframe extends Item {
|
||||||
constructor (name) {
|
constructor (name: string) {
|
||||||
super(name)
|
super(name)
|
||||||
|
|
||||||
this.addPart('systems')
|
this.addPart('systems')
|
||||||
@@ -1,11 +1,12 @@
|
|||||||
const items = require('./items.json')
|
import items from './items.json'
|
||||||
const Warframe = require('./Warframe')
|
import Warframe from './Warframe'
|
||||||
// const Primary = require('./Primary')
|
// const Primary = require('./Primary')
|
||||||
// const Secondary = require('./Secondary')
|
// const Secondary = require('./Secondary')
|
||||||
const Companion = require('./Companion')
|
import Companion from './Companion'
|
||||||
const Archwings = require('./Archwings')
|
import Archwings from './Archwings'
|
||||||
|
import type Item from './Item'
|
||||||
|
|
||||||
const result = []
|
const result: Item[] = []
|
||||||
|
|
||||||
items.warframes.forEach((name) => {
|
items.warframes.forEach((name) => {
|
||||||
result.push(new Warframe(name))
|
result.push(new Warframe(name))
|
||||||
@@ -23,4 +24,4 @@ items.archwings.forEach((name) => {
|
|||||||
result.push(new Archwings(name))
|
result.push(new Archwings(name))
|
||||||
})
|
})
|
||||||
|
|
||||||
module.exports = result
|
export default result
|
||||||
20
gather/tsconfig.json
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "esnext",
|
||||||
|
"module": "commonjs",
|
||||||
|
"allowJs": true,
|
||||||
|
"checkJs": false,
|
||||||
|
"outDir": "dist",
|
||||||
|
"rootDir": ".",
|
||||||
|
"strict": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
},
|
||||||
|
"exclude": ["node_modules", "dist"],
|
||||||
|
"include": [
|
||||||
|
"./src",
|
||||||
|
"./*",
|
||||||
|
]
|
||||||
|
}
|
||||||
1651
gather/yarn-error.log
Normal file
21
index.js
@@ -1,21 +0,0 @@
|
|||||||
require('dotenv').config()
|
|
||||||
const items = require('./items')
|
|
||||||
const output = require('./output');
|
|
||||||
|
|
||||||
(async () => {
|
|
||||||
for (const item of items) {
|
|
||||||
console.log(`Looking at ${item.name}`)
|
|
||||||
|
|
||||||
let partsPrice = 0
|
|
||||||
for (const part of item.parts) {
|
|
||||||
partsPrice += await part.getPrice()
|
|
||||||
}
|
|
||||||
|
|
||||||
const setPrice = await item.set.getPrice()
|
|
||||||
if (partsPrice < setPrice) {
|
|
||||||
output.addItem(item.name, partsPrice, setPrice)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
output.submit()
|
|
||||||
})()
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
const Part = require('./Part')
|
|
||||||
|
|
||||||
module.exports = class Item {
|
|
||||||
constructor (name) {
|
|
||||||
this.name = name
|
|
||||||
this.set = new Part(name, 'set')
|
|
||||||
|
|
||||||
this.parts = []
|
|
||||||
this.addPart('blueprint')
|
|
||||||
}
|
|
||||||
|
|
||||||
addPart (part, amount) {
|
|
||||||
this.parts.push(new Part(this.name, part, amount))
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,14 +0,0 @@
|
|||||||
const Api = require('../api')
|
|
||||||
|
|
||||||
module.exports = class Part {
|
|
||||||
constructor (set, part, amount) {
|
|
||||||
this.part = part
|
|
||||||
this.url = `${set}_prime_${part}`
|
|
||||||
this.amount = amount ?? 1
|
|
||||||
}
|
|
||||||
|
|
||||||
async getPrice () {
|
|
||||||
const orders = await Api.getSortedOrders(this.url)
|
|
||||||
return Number(orders[0].platinum) * this.amount
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,10 +0,0 @@
|
|||||||
module.exports = class OutputItem {
|
|
||||||
constructor (name, parts, set) {
|
|
||||||
this.name = name + ' prime'
|
|
||||||
this.parts = parts
|
|
||||||
this.set = set
|
|
||||||
this.link = `https://warframe.market/items/${name}_prime_set`
|
|
||||||
|
|
||||||
this.difference = set - parts
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,39 +0,0 @@
|
|||||||
const fs = require('fs')
|
|
||||||
const Handlebars = require('handlebars')
|
|
||||||
const OutputItem = require('./OutputItem')
|
|
||||||
|
|
||||||
class Output {
|
|
||||||
constructor () {
|
|
||||||
this.items = []
|
|
||||||
this.timestamp = null
|
|
||||||
}
|
|
||||||
|
|
||||||
addItem (...p) {
|
|
||||||
this.items.push(new OutputItem(...p))
|
|
||||||
}
|
|
||||||
|
|
||||||
async compileTemplate () {
|
|
||||||
const templateFile = await fs.readFileSync('./output/template.hbs', 'utf8')
|
|
||||||
const template = Handlebars.compile(templateFile)
|
|
||||||
return template(this)
|
|
||||||
}
|
|
||||||
|
|
||||||
async writeToFile (content) {
|
|
||||||
const filename = './public/index.html'
|
|
||||||
|
|
||||||
try {
|
|
||||||
await fs.unlinkSync(filename)
|
|
||||||
} catch {
|
|
||||||
console.log('File probably doesnt exist')
|
|
||||||
}
|
|
||||||
fs.writeFileSync(filename, content, 'utf-8')
|
|
||||||
}
|
|
||||||
|
|
||||||
async submit () {
|
|
||||||
this.timestamp = new Date()
|
|
||||||
const content = await this.compileTemplate()
|
|
||||||
await this.writeToFile(content)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
module.exports = new Output()
|
|
||||||
@@ -1,77 +0,0 @@
|
|||||||
<!DOCTYPE html>
|
|
||||||
<html lang="en">
|
|
||||||
<head>
|
|
||||||
<meta charset="UTF-8">
|
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
||||||
<link rel="stylesheet" href="style.css">
|
|
||||||
<title>Warframe Market Gaps</title>
|
|
||||||
|
|
||||||
<!-- Yandex.Metrika counter -->
|
|
||||||
<script type="text/javascript" >
|
|
||||||
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
|
|
||||||
m[i].l=1*new Date();k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
|
|
||||||
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
|
|
||||||
|
|
||||||
ym(87671663, "init", {
|
|
||||||
clickmap:true,
|
|
||||||
trackLinks:true,
|
|
||||||
accurateTrackBounce:true
|
|
||||||
});
|
|
||||||
</script>
|
|
||||||
<noscript><div><img src="https://mc.yandex.ru/watch/87671663" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
|
|
||||||
<!-- /Yandex.Metrika counter -->
|
|
||||||
</head>
|
|
||||||
<body>
|
|
||||||
<div class="hero">
|
|
||||||
<img id="gunner1" src="./assets/gunner1.png">
|
|
||||||
<div class="main">
|
|
||||||
<img class="logo" src="./assets/warframe_logo.png">
|
|
||||||
<div class="text">
|
|
||||||
<h1>Market Gaps</h1>
|
|
||||||
<p>Find a profitable difference between the price of the set and the price of the sum of it's parts.</p>
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<img id="gunner2" src="./assets/gunner2.png">
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="main-column">
|
|
||||||
<div class="controls">
|
|
||||||
<label for="min-difference">Filter by difference:</label>
|
|
||||||
<input type="range" min="1" max="60" value="1" id="min-difference">
|
|
||||||
<span id="filter-value">1</span>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<table>
|
|
||||||
<thead>
|
|
||||||
<tr>
|
|
||||||
<th>Name</th>
|
|
||||||
<th>Parts price</th>
|
|
||||||
<th>Set price</th>
|
|
||||||
<th>Difference</th>
|
|
||||||
</tr>
|
|
||||||
</thead>
|
|
||||||
<tbody id="items">
|
|
||||||
{{#each items}}
|
|
||||||
<tr data-difference="{{this.difference}}">
|
|
||||||
<td class="name">
|
|
||||||
<a href="{{this.link}}" target="_blank">
|
|
||||||
{{this.name}}
|
|
||||||
</a>
|
|
||||||
</td>
|
|
||||||
<td>{{this.parts}}</td>
|
|
||||||
<td>{{this.set}}</td>
|
|
||||||
<td>{{this.difference}}</td>
|
|
||||||
</tr>
|
|
||||||
{{/each}}
|
|
||||||
</tbody>
|
|
||||||
</table>
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<div class="timestamp">
|
|
||||||
Generated at {{timestamp}}
|
|
||||||
</div>
|
|
||||||
|
|
||||||
<script src="index.js"></script>
|
|
||||||
</body>
|
|
||||||
</html>
|
|
||||||
4123
package-lock.json
generated
27
package.json
@@ -1,20 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "warframe-market-bot",
|
"name": "warframe-center",
|
||||||
|
"private": true,
|
||||||
"version": "1.0.0",
|
"version": "1.0.0",
|
||||||
"description": "",
|
"description": "Список Прайм предметов: https://warframe.fandom.com/wiki/Prime",
|
||||||
"main": "index.js",
|
"repository": {
|
||||||
"scripts": {
|
"type": "git",
|
||||||
"test": "echo \"Error: no test specified\" && exit 1"
|
"url": "ssh://git@git.radner.ru:3036/anatolykopyl/warframe-center.git"
|
||||||
},
|
},
|
||||||
"author": "Anatoly Kopyl",
|
"author": "Anatoly Kopyl",
|
||||||
"license": "ISC",
|
"workspaces": [
|
||||||
"dependencies": {
|
"./frontend",
|
||||||
"axios": "^0.26.0",
|
"./gather",
|
||||||
"dotenv": "^16.0.0",
|
"./shared-stuff"
|
||||||
"handlebars": "^4.7.7",
|
],
|
||||||
"limiter": "^2.1.0"
|
"packageManager": "yarn@3.2.1"
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"eslint-config-standard": "^16.0.3"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 2.8 MiB |
|
Before Width: | Height: | Size: 1.8 MiB |
|
Before Width: | Height: | Size: 1.2 MiB |
|
Before Width: | Height: | Size: 265 KiB |
@@ -1,25 +0,0 @@
|
|||||||
const slider = document.getElementById('min-difference')
|
|
||||||
|
|
||||||
slider.addEventListener('input', function (event) {
|
|
||||||
const table = document.getElementById('items')
|
|
||||||
Array.from(table.children).forEach(row => {
|
|
||||||
if (row.dataset.difference < Number(event.target.value)) {
|
|
||||||
row.style.display = 'none'
|
|
||||||
} else {
|
|
||||||
row.style.display = 'table-row'
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
document.getElementById('filter-value').innerText = event.target.value
|
|
||||||
})
|
|
||||||
|
|
||||||
document.addEventListener('scroll', function () {
|
|
||||||
const gunner1 = document.getElementById('gunner1')
|
|
||||||
const gunner2 = document.getElementById('gunner2')
|
|
||||||
|
|
||||||
gunner1.style.transform = `translateX(${-window.scrollY}px)`
|
|
||||||
gunner2.style.transform = `translateX(${window.scrollY}px)`
|
|
||||||
|
|
||||||
gunner1.style.filter = `blur(${window.scrollY / 50}px)`
|
|
||||||
gunner2.style.filter = `blur(${window.scrollY / 50}px)`
|
|
||||||
})
|
|
||||||
160
public/style.css
@@ -1,160 +0,0 @@
|
|||||||
:root {
|
|
||||||
--bg-main: white;
|
|
||||||
--brand-clr: rgb(26, 34, 58);
|
|
||||||
--bg: rgb(16, 22, 25);
|
|
||||||
--text-clr: black;
|
|
||||||
--accent-clr: red;
|
|
||||||
}
|
|
||||||
|
|
||||||
* {
|
|
||||||
font-family: sans-serif;
|
|
||||||
font-weight: 100;
|
|
||||||
}
|
|
||||||
|
|
||||||
body {
|
|
||||||
position: relative;
|
|
||||||
margin: 0;
|
|
||||||
min-height: 100vh;
|
|
||||||
background: var(--bg);
|
|
||||||
color: var(--text-clr);
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
a {
|
|
||||||
text-decoration: none;
|
|
||||||
color: var(--accent-clr);
|
|
||||||
}
|
|
||||||
|
|
||||||
.main-column {
|
|
||||||
width: 800px;
|
|
||||||
background: var(--bg-main);
|
|
||||||
padding: 32px 128px;
|
|
||||||
box-sizing: border-box;
|
|
||||||
margin: 128px auto;
|
|
||||||
border: 2px solid var(--accent-clr);
|
|
||||||
}
|
|
||||||
|
|
||||||
.main-column::before {
|
|
||||||
position: absolute;
|
|
||||||
left: 0px;
|
|
||||||
width: 50%;
|
|
||||||
border-top: 2px solid var(--accent-clr);
|
|
||||||
z-index: -1;
|
|
||||||
content: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
.main-column::after {
|
|
||||||
position: absolute;
|
|
||||||
right: 0px;
|
|
||||||
width: 50%;
|
|
||||||
border-top: 2px solid var(--accent-clr);
|
|
||||||
z-index: -1;
|
|
||||||
content: '';
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero {
|
|
||||||
width: 100%;
|
|
||||||
padding: 128px 0;
|
|
||||||
position: relative;
|
|
||||||
box-sizing: border-box;
|
|
||||||
background: white;
|
|
||||||
color: black;
|
|
||||||
text-align: center;
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero > .main {
|
|
||||||
position: relative;
|
|
||||||
margin: auto;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: column;
|
|
||||||
z-index: 10;
|
|
||||||
color: var(--brand-clr);
|
|
||||||
}
|
|
||||||
|
|
||||||
.hero .logo, .hero .text {
|
|
||||||
margin: auto;
|
|
||||||
width: 400px;
|
|
||||||
}
|
|
||||||
|
|
||||||
#gunner1, #gunner2 {
|
|
||||||
position: absolute;
|
|
||||||
max-width: 500px;
|
|
||||||
height: 500px;
|
|
||||||
object-fit: contain;
|
|
||||||
transition: transform .1s;
|
|
||||||
top: calc(50% - 250px);
|
|
||||||
}
|
|
||||||
|
|
||||||
#gunner1 {
|
|
||||||
left: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
#gunner2 {
|
|
||||||
right: 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
.controls {
|
|
||||||
margin: 32px auto;
|
|
||||||
display: flex;
|
|
||||||
align-items: center;
|
|
||||||
justify-content: center;
|
|
||||||
background: var(--bg-main);
|
|
||||||
padding: 8px;
|
|
||||||
width: max-content;
|
|
||||||
}
|
|
||||||
|
|
||||||
.controls > * {
|
|
||||||
margin: 0 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
min-width: 500px;
|
|
||||||
margin: 32px auto;
|
|
||||||
border-spacing: 0;
|
|
||||||
background: var(--bg-main);
|
|
||||||
}
|
|
||||||
|
|
||||||
tr {
|
|
||||||
text-align: left;
|
|
||||||
}
|
|
||||||
|
|
||||||
td {
|
|
||||||
padding: 2px 16px;
|
|
||||||
}
|
|
||||||
|
|
||||||
th {
|
|
||||||
padding: 8px 16px;
|
|
||||||
font-weight: 400;
|
|
||||||
}
|
|
||||||
|
|
||||||
.name {
|
|
||||||
text-transform: capitalize;
|
|
||||||
}
|
|
||||||
|
|
||||||
.timestamp {
|
|
||||||
font-size: 14px;
|
|
||||||
padding-bottom: 16px;
|
|
||||||
position: sticky;
|
|
||||||
top: 100%;
|
|
||||||
color: white;
|
|
||||||
}
|
|
||||||
|
|
||||||
@media screen and (max-width: 500px) {
|
|
||||||
.hero .logo {
|
|
||||||
width: 100%;
|
|
||||||
}
|
|
||||||
|
|
||||||
#gunner1, #gunner2 {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.main-column {
|
|
||||||
width: 100%;
|
|
||||||
border: none;
|
|
||||||
padding: 72px 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
table {
|
|
||||||
min-width: 100%;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
1
shared-stuff/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
dist
|
||||||
7
shared-stuff/index.ts
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
import ScanResult from './models/ScanResult'
|
||||||
|
|
||||||
|
const models = {
|
||||||
|
ScanResult
|
||||||
|
}
|
||||||
|
|
||||||
|
export { models }
|
||||||
15
shared-stuff/models/ScanResult.ts
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
import mongoose from 'mongoose'
|
||||||
|
|
||||||
|
const scanResultSchema = new mongoose.Schema({
|
||||||
|
name: String,
|
||||||
|
fullName: String,
|
||||||
|
url: String,
|
||||||
|
partsPrice: Number,
|
||||||
|
setPrice: Number,
|
||||||
|
difference: Number
|
||||||
|
},
|
||||||
|
{
|
||||||
|
timestamps: true
|
||||||
|
})
|
||||||
|
|
||||||
|
export default mongoose.models.ScanResult || mongoose.model('ScanResult', scanResultSchema)
|
||||||
14
shared-stuff/package.json
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
{
|
||||||
|
"name": "shared-stuff",
|
||||||
|
"private": true,
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "The stuff that is shared between the background job and the Next app",
|
||||||
|
"main": "./dist/index.js",
|
||||||
|
"scripts": {
|
||||||
|
"build": "./node_modules/typescript/bin/tsc"
|
||||||
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"mongoose": "^6.4.3",
|
||||||
|
"typescript": "^4.7.4"
|
||||||
|
}
|
||||||
|
}
|
||||||
18
shared-stuff/tsconfig.json
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"target": "esnext",
|
||||||
|
"module": "commonjs",
|
||||||
|
"checkJs": false,
|
||||||
|
"outDir": "dist",
|
||||||
|
"rootDir": ".",
|
||||||
|
"strict": true,
|
||||||
|
"forceConsistentCasingInFileNames": true,
|
||||||
|
"strictNullChecks": true,
|
||||||
|
"resolveJsonModule": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
},
|
||||||
|
"exclude": ["node_modules", "dist"],
|
||||||
|
"include": [
|
||||||
|
"./*",
|
||||||
|
]
|
||||||
|
}
|
||||||