From 68801bd56e9aa34a25e1a4cbb2731651eb6d8f20 Mon Sep 17 00:00:00 2001 From: Nikita Date: Thu, 24 Jun 2021 14:25:27 +0300 Subject: [PATCH 01/15] Create FUNDING.yml --- .github/FUNDING.yml | 1 + 1 file changed, 1 insertion(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000..69f1b2c --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +custom: ['https://qiwi.com/n/LIVIXX'] From 0f69fa021b13c9c16171747bb87354961e698d41 Mon Sep 17 00:00:00 2001 From: Nikita Date: Thu, 24 Jun 2021 14:43:22 +0300 Subject: [PATCH 02/15] Update Home.vue --- frontend/src/views/Home.vue | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue index eedf10c..d09b0a3 100644 --- a/frontend/src/views/Home.vue +++ b/frontend/src/views/Home.vue @@ -184,9 +184,10 @@ export default { }, async CreateBill() { if (!this.sum) return alert('Вы не указали сумму!'); - if (!this.comment) return alert('Вы не указали комментарий!') - if (this.sum < 10) return alert('Минимальная сумма пополнения 10 руб.') - if (this.sum >= 15000) return alert('Максимальная сумма пополнения 10 руб.') + if (!this.comment) return alert('Вы не указали комментарий!'); + if (this.sum < 10) return alert('Минимальная сумма пополнения 10 руб.'); + if (this.sum >= 15000) return alert('Максимальная сумма пополнения 10 руб.'); + if (this.comment.length >= 150) return alert('Максимальная длина коментария 150 символов.'); const data = await (await fetch(`https://${url}/qiwi/create`, { method: 'POST', headers: { @@ -271,4 +272,4 @@ export default { } } } - \ No newline at end of file + From fc55658cc4142c0ee48afeabb89569c49d8ffedc Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 28 Jun 2021 01:22:13 +0300 Subject: [PATCH 03/15] Update Footer.vue --- frontend/src/components/Footer.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/src/components/Footer.vue b/frontend/src/components/Footer.vue index f2c0d02..e130236 100644 --- a/frontend/src/components/Footer.vue +++ b/frontend/src/components/Footer.vue @@ -6,7 +6,7 @@ Telegram
Designed by
@@ -95,4 +95,4 @@ \ No newline at end of file + From 8cfdaaf18998f987b6c6cb0276888ece6dcb1337 Mon Sep 17 00:00:00 2001 From: Nikita Date: Sat, 10 Jul 2021 14:56:07 +0300 Subject: [PATCH 04/15] Create backend.yml --- .github/workflows/backend.yml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 .github/workflows/backend.yml diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml new file mode 100644 index 0000000..81e6e6e --- /dev/null +++ b/.github/workflows/backend.yml @@ -0,0 +1,25 @@ +name: Backend tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + run-tests: + name: tests + runs-on: ubuntu-latest + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 13 + - name: Install dependencies for backend + run: cd backend && npm i + - name: Run test + run: npm run build From 4c4a99b670ba32e5ccb79955b394710b670fdf9f Mon Sep 17 00:00:00 2001 From: Nikita Date: Sat, 10 Jul 2021 14:57:27 +0300 Subject: [PATCH 05/15] Update backend.yml --- .github/workflows/backend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index 81e6e6e..d2ffb09 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -22,4 +22,4 @@ jobs: - name: Install dependencies for backend run: cd backend && npm i - name: Run test - run: npm run build + run: cd backend && npm run build From f6238e11ffebb34993bf5282d3d37f2ac27d2e64 Mon Sep 17 00:00:00 2001 From: Nikita Date: Sat, 10 Jul 2021 14:59:51 +0300 Subject: [PATCH 06/15] Create frontend.yml --- .github/workflows/frontend.yml | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 .github/workflows/frontend.yml diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml new file mode 100644 index 0000000..68563fc --- /dev/null +++ b/.github/workflows/frontend.yml @@ -0,0 +1,27 @@ +name: Frontend tests + +on: + push: + branches: + - main + pull_request: + branches: + - main + +jobs: + run-tests: + name: tests + runs-on: ubuntu-latest + steps: + - name: Check out Git repository + uses: actions/checkout@v2 + - name: Set up Node.js + uses: actions/setup-node@v1 + with: + node-version: 13 + - name: Install dependencies for frontend + run: cd frontend && npm i + - name: Run list + run: cd frontend && npm run lint + - name: Run build + run: cd frontend && npm run build From e6dfd42231119d3b4e4db449fb66f4ba9515a451 Mon Sep 17 00:00:00 2001 From: Nikita Date: Sat, 10 Jul 2021 15:25:04 +0300 Subject: [PATCH 07/15] init --- .github/FUNDING.yml | 2 +- .github/workflows/backend.yml | 2 +- .github/workflows/frontend.yml | 2 +- backend/src/Servies/da.ts | 7 ++++--- backend/src/Servies/oauth2.ts | 5 +++-- backend/src/Servies/qiwi.ts | 9 +++++---- backend/src/index.ts | 5 ++++- 7 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 69f1b2c..ee8590a 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1 +1 @@ -custom: ['https://qiwi.com/n/LIVIXX'] +custom: ['https://donate.mrlivixx.me'] diff --git a/.github/workflows/backend.yml b/.github/workflows/backend.yml index d2ffb09..c359270 100644 --- a/.github/workflows/backend.yml +++ b/.github/workflows/backend.yml @@ -22,4 +22,4 @@ jobs: - name: Install dependencies for backend run: cd backend && npm i - name: Run test - run: cd backend && npm run build + run: cd backend && npm run build \ No newline at end of file diff --git a/.github/workflows/frontend.yml b/.github/workflows/frontend.yml index 68563fc..a6e7752 100644 --- a/.github/workflows/frontend.yml +++ b/.github/workflows/frontend.yml @@ -24,4 +24,4 @@ jobs: - name: Run list run: cd frontend && npm run lint - name: Run build - run: cd frontend && npm run build + run: cd frontend && npm run build \ No newline at end of file diff --git a/backend/src/Servies/da.ts b/backend/src/Servies/da.ts index ca3848a..c5c37d0 100644 --- a/backend/src/Servies/da.ts +++ b/backend/src/Servies/da.ts @@ -10,10 +10,10 @@ import axios, {AxiosResponse} from "axios"; const hashes = new Map() class DonationAlertsWatcher { private io: Socket; - private db: Model; - private tokens: Model + private db: Model; + private tokens: Model - constructor(db: Model, tokens: Model) { + constructor(db: Model, tokens: Model) { this.db = db; this.tokens = tokens; //@ts-ignore @@ -47,6 +47,7 @@ class DonationAlertsWatcher { }).then(x => x) const response: AxiosResponse | null = await axios.get('https://discord.com/api/users/@me', { headers: { + // @ts-ignore authorization: `Bearer ${tokendata?.accessToken}` } }).catch(() => { diff --git a/backend/src/Servies/oauth2.ts b/backend/src/Servies/oauth2.ts index bfd3e6b..a73ac43 100644 --- a/backend/src/Servies/oauth2.ts +++ b/backend/src/Servies/oauth2.ts @@ -7,8 +7,8 @@ import axios, {AxiosResponse} from "axios"; import { URLSearchParams } from "url"; class Oauth2 { - private db: Model; - constructor(db: Model) { + private db: Model; + constructor(db: Model) { this.db = db; } async Discordlogin(req: FastifyRequest,res: FastifyReply) : Promise { @@ -89,6 +89,7 @@ class Oauth2 { const tokendata = await this.db.findOne({userid: data?.id.toString(),exp: data?.exp}) const response: AxiosResponse = await axios.get('https://discord.com/api/users/@me', { headers: { + //@ts-ignore authorization: `Bearer ${tokendata?.accessToken}` } }) diff --git a/backend/src/Servies/qiwi.ts b/backend/src/Servies/qiwi.ts index d57e6a6..dabd1de 100644 --- a/backend/src/Servies/qiwi.ts +++ b/backend/src/Servies/qiwi.ts @@ -1,6 +1,6 @@ import QiwiBillPaymentsAPI from "@qiwi/bill-payments-node-js-sdk"; import { FastifyRequest, FastifyReply } from "fastify"; -import axios, {AxiosError, AxiosResponse} from "axios"; +import axios, { AxiosResponse } from "axios"; import { Model } from "mongoose"; // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore @@ -8,9 +8,9 @@ import jwt from "jsonwebtoken"; class Qiwi { private qiwi: QiwiBillPaymentsAPI; - private db: Model; - private tokens: Model; - constructor(db: Model, tokens: Model) { + private db: Model; + private tokens: Model; + constructor(db: Model, tokens: Model) { this.qiwi = new QiwiBillPaymentsAPI(process.env.QIWI_SECRET_KEY!); this.db = db; this.tokens = tokens; @@ -70,6 +70,7 @@ class Qiwi { const tokendata = await this.tokens.findOne({userid: data?.id.toString(), exp: data?.exp}) const response: AxiosResponse = await axios.get('https://discord.com/api/users/@me',{ headers: { + //@ts-ignore authorization: `Bearer ${tokendata?.accessToken}` } }).catch(() => {return res.status(403).send({code: 403, message: 'Forbidden'})}); diff --git a/backend/src/index.ts b/backend/src/index.ts index 951e5d4..906b477 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -51,12 +51,15 @@ class ApiWorker { }); //DONATIONALERTS - if(process.env.DA_SECRET) await new DonationAlertsWatcher(donations, tokens).init() + if(process.env.DA_SECRET) { // @ts-ignore + await new DonationAlertsWatcher(donations, tokens).init() + } //SOCKET.IO this.io.on('connection', async (socket: Socket) => { socket.send('Connected!'); console.log('Site connected!'); socket.on('donations',async () => { + //@ts-ignore socket.emit('donations', await donations.find().sort({'time': 'desc'}).then((x: Model) => x)); }); }); From 23a31a2907d85e0b58fb8118b49ca6c588eed60a Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 12 Jul 2021 14:26:02 +0300 Subject: [PATCH 08/15] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d688288..0f620b1 100644 --- a/README.md +++ b/README.md @@ -13,6 +13,6 @@
`socket.io` - Обмен данными между Front-end и Back-end частями сайта.
`fastify` - Используется в качестве веб-сервера в Back-end части.
`mongoose` - Для использования базы данных MongoBD, хранения донатов и сессий -
`jsonwebtoken` - Используется для подписания токенов, [подробнее](https://jwt.io) +
`jsonwebtoken` - Используется для подписи токенов, [подробнее](https://jwt.io) # Contributing Мы приветствуем всех желающих которые хотят внести вклад в данный проект. From 9232a0fda56fb1233bc20cd4348cd6cfd99d7f58 Mon Sep 17 00:00:00 2001 From: Nikita Date: Mon, 12 Jul 2021 16:57:27 +0300 Subject: [PATCH 09/15] Update aem_logo.svg --- frontend/public/aem_logo.svg | 44 ++++++++++++++++++++++++------------ 1 file changed, 30 insertions(+), 14 deletions(-) diff --git a/frontend/public/aem_logo.svg b/frontend/public/aem_logo.svg index e18b7e7..994f7f2 100644 --- a/frontend/public/aem_logo.svg +++ b/frontend/public/aem_logo.svg @@ -1,15 +1,31 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + From e6d10d5d254708bf0af68a622a13ea0e41c63ac9 Mon Sep 17 00:00:00 2001 From: Nikita Date: Tue, 13 Jul 2021 19:48:21 +0300 Subject: [PATCH 10/15] Update README.md --- backend/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/backend/README.md b/backend/README.md index f5b2233..2dd19c6 100644 --- a/backend/README.md +++ b/backend/README.md @@ -38,7 +38,7 @@ QIWI_SECRET_KEY=****** #QIWI THEME QIWI_THEME=Nykyta-S0FqLeU_kv ``` -###Коротко о том что за значения надо внести в .env +### Коротко о том что за значения надо внести в .env - `DB_URL` - Ссылка на базу данных mongodb. Как создать базу данных можете прочитать в моём другом гайде [здесь](https://github.com/sqdsh/simple-discord-bot/blob/gh-pages/index.md#прочее) - `PORT` - Порт веб сервера, для работы на своей VPS/VDS машине, использовать прокси как nginx и apache2. Если heroku/glitch оставить пустым From 88f066e03b26d9085f47878ef3bd685288a8565e Mon Sep 17 00:00:00 2001 From: Nikita Date: Sun, 15 Aug 2021 12:46:36 +0300 Subject: [PATCH 11/15] Update oauth2.ts --- backend/src/Servies/oauth2.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/backend/src/Servies/oauth2.ts b/backend/src/Servies/oauth2.ts index a73ac43..6dbcc55 100644 --- a/backend/src/Servies/oauth2.ts +++ b/backend/src/Servies/oauth2.ts @@ -14,7 +14,10 @@ class Oauth2 { async Discordlogin(req: FastifyRequest,res: FastifyReply) : Promise { // eslint-disable-next-line @typescript-eslint/ban-ts-comment //@ts-ignore - const code = req.query?.code; + const { code, error } = req.query; + if(error == "access_denied") return res.view('index.ejs', { + token: null + }); if(!code) return res.redirect('/oauth2/discord/authorize'); const response: AxiosResponse = await axios.post('https://discord.com/api/oauth2/token', new URLSearchParams({ @@ -102,4 +105,4 @@ class Oauth2 { }); } } -export default Oauth2; \ No newline at end of file +export default Oauth2; From 6804d88ce44518385587f8ef37b0376b17bcc233 Mon Sep 17 00:00:00 2001 From: Nikita Date: Sun, 15 Aug 2021 12:50:54 +0300 Subject: [PATCH 12/15] Update Home.vue --- frontend/src/views/Home.vue | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue index d09b0a3..f94afe1 100644 --- a/frontend/src/views/Home.vue +++ b/frontend/src/views/Home.vue @@ -246,7 +246,8 @@ export default { if (typeof message !== 'object') return; if (!message['data']) return; if (!message.data['token']) return; - localStorage.setItem('token', JSON.parse(message.data.token)); + if (JSON.parse(message.data.token)) localStorage.setItem('token', JSON.parse(message.data.token)); + else return; }, async getUserData() { const info = await fetch('https://'+ url + '/oauth2/user', { From 2a712918fdf44654207c0a9a84af6f5b7c19ebd9 Mon Sep 17 00:00:00 2001 From: Nikita Date: Sun, 15 Aug 2021 13:08:47 +0300 Subject: [PATCH 13/15] Update oauth2.ts --- backend/src/Servies/oauth2.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/backend/src/Servies/oauth2.ts b/backend/src/Servies/oauth2.ts index 6dbcc55..157c6d4 100644 --- a/backend/src/Servies/oauth2.ts +++ b/backend/src/Servies/oauth2.ts @@ -96,7 +96,8 @@ class Oauth2 { authorization: `Bearer ${tokendata?.accessToken}` } }) - if(!response.data.id) return res.send({code:404, message: "Not found"}) + if(!response.data.id) return res.send({code:404, message: "Not found"}); + if(response.data.code === 0) return res.send({code:404, message: "Not found"}); res.status(200).send({type: 'discord', data: response.data}) } From c759d53ca2a0f1877c414508eec936441b63fd84 Mon Sep 17 00:00:00 2001 From: Nikita Date: Sun, 15 Aug 2021 13:45:54 +0300 Subject: [PATCH 14/15] Update oauth2.ts --- backend/src/Servies/oauth2.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/backend/src/Servies/oauth2.ts b/backend/src/Servies/oauth2.ts index 157c6d4..34d6300 100644 --- a/backend/src/Servies/oauth2.ts +++ b/backend/src/Servies/oauth2.ts @@ -95,9 +95,8 @@ class Oauth2 { //@ts-ignore authorization: `Bearer ${tokendata?.accessToken}` } - }) - if(!response.data.id) return res.send({code:404, message: "Not found"}); - if(response.data.code === 0) return res.send({code:404, message: "Not found"}); + }).catch(() => {return res.status(500).send({code: 500, message: 'Internal server error'})}); + if(!response.data?.id) return res.send({code:404, message: "Not found"}) res.status(200).send({type: 'discord', data: response.data}) } From 67940110090b0c7ccdfdeaa722cd8476e020759b Mon Sep 17 00:00:00 2001 From: Nikita Date: Sun, 15 Aug 2021 13:47:15 +0300 Subject: [PATCH 15/15] Update Home.vue --- frontend/src/views/Home.vue | 1 + 1 file changed, 1 insertion(+) diff --git a/frontend/src/views/Home.vue b/frontend/src/views/Home.vue index f94afe1..72638ec 100644 --- a/frontend/src/views/Home.vue +++ b/frontend/src/views/Home.vue @@ -256,6 +256,7 @@ export default { 'Authorization': localStorage.getItem('token') } }); + if(info.status !== 200) return this.logout(); const { data, type } = await info?.json(); if (!type) return; this.user = data;