Skip to content

Commit

Permalink
Merge pull request #2 from MrLivixx/1.1
Browse files Browse the repository at this point in the history
Version 1.1
  • Loading branch information
EveryDayRains authored Jul 10, 2021
2 parents f6238e1 + e6dfd42 commit ad3b9bd
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1 +1 @@
custom: ['https://qiwi.com/n/LIVIXX']
custom: ['https://donate.mrlivixx.me']
2 changes: 1 addition & 1 deletion .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 1 addition & 1 deletion .github/workflows/frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
7 changes: 4 additions & 3 deletions backend/src/Servies/da.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@ import axios, {AxiosResponse} from "axios";
const hashes = new Map()
class DonationAlertsWatcher {
private io: Socket;
private db: Model<Donations>;
private tokens: Model<Tokens>
private db: Model<Donations | unknown>;
private tokens: Model<Tokens | unknown>

constructor(db: Model<Donations>, tokens: Model<Tokens>) {
constructor(db: Model<Donations | unknown>, tokens: Model<Tokens | unknown>) {
this.db = db;
this.tokens = tokens;
//@ts-ignore
Expand Down Expand Up @@ -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(() => {
Expand Down
5 changes: 3 additions & 2 deletions backend/src/Servies/oauth2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import axios, {AxiosResponse} from "axios";
import { URLSearchParams } from "url";

class Oauth2 {
private db: Model<Tokens>;
constructor(db: Model<Tokens>) {
private db: Model<Tokens | unknown>;
constructor(db: Model<Tokens | unknown>) {
this.db = db;
}
async Discordlogin(req: FastifyRequest,res: FastifyReply) : Promise<void> {
Expand Down Expand Up @@ -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}`
}
})
Expand Down
9 changes: 5 additions & 4 deletions backend/src/Servies/qiwi.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
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
import jwt from "jsonwebtoken";

class Qiwi {
private qiwi: QiwiBillPaymentsAPI;
private db: Model<Donations>;
private tokens: Model<Tokens>;
constructor(db: Model<Donations>, tokens: Model<Tokens>) {
private db: Model<Donations | unknown>;
private tokens: Model<Tokens | unknown>;
constructor(db: Model<Donations | unknown>, tokens: Model<Tokens | unknown>) {
this.qiwi = new QiwiBillPaymentsAPI(process.env.QIWI_SECRET_KEY!);
this.db = db;
this.tokens = tokens;
Expand Down Expand Up @@ -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'})});
Expand Down
5 changes: 4 additions & 1 deletion backend/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<Donations>) => x));
});
});
Expand Down

0 comments on commit ad3b9bd

Please sign in to comment.