mirror of
https://github.com/KeyZox71/knl_meowscendence.git
synced 2025-12-31 21:56:41 +01:00
「🏗️」 wip: started fixing shit
This commit is contained in:
@ -2,7 +2,6 @@ import fastifyJWT from '@fastify/jwt';
|
||||
import fastifyCookie from '@fastify/cookie';
|
||||
import cors from '@fastify/cors'
|
||||
import Database from 'better-sqlite3';
|
||||
import cors from '@fastify/cors';
|
||||
|
||||
import { gUsers } from './gUsers.js';
|
||||
import { gUser } from './gUser.js';
|
||||
@ -163,12 +162,6 @@ export default async function(fastify, options) {
|
||||
},
|
||||
});
|
||||
fastify.register(fastifyCookie);
|
||||
fastify.register(cors, {
|
||||
origin: process.env.CORS_ORIGIN || 'http://localhost:5173',
|
||||
credentials: true,
|
||||
methods: [ "GET", "POST", "PATCH", "DELETE", "OPTIONS" ]
|
||||
});
|
||||
|
||||
fastify.addContentTypeParser(
|
||||
['image/jpeg', 'image/png', 'image/gif', 'image/webp'],
|
||||
{ parseAs: 'buffer' },
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
const score_url = process.env.SCORE_URL
|
||||
|
||||
export async function gMatchHistory(request, reply, fastify, getUserInfo, getMatchHistory) {
|
||||
try {
|
||||
const userId = request.params.userId;
|
||||
@ -19,7 +21,7 @@ export async function gMatchHistory(request, reply, fastify, getUserInfo, getMat
|
||||
return reply.code(404).send({ error: "No matches exist in the selected range" });
|
||||
}
|
||||
const promises = matchHistoryId.map(async (match) => {
|
||||
const res = await fetch(`http://localhost:3003/${match.matchId}`, { method: "GET" });
|
||||
const res = await fetch(`${score_url}/${match.matchId}`, { method: "GET" });
|
||||
if (!res.ok) {
|
||||
throw new Error('Failed to fetch item from blockchain API');
|
||||
}
|
||||
|
||||
@ -1,3 +1,5 @@
|
||||
const score_url = process.env.SCORE_URL || "http://localhost:3003";
|
||||
|
||||
async function fetchSave(request, reply, userId, addMatch) {
|
||||
let opponentName = '';
|
||||
let opponentScore = 0;
|
||||
@ -5,7 +7,7 @@ async function fetchSave(request, reply, userId, addMatch) {
|
||||
opponentName = request.body.opponent;
|
||||
opponentScore = request.body.opponentScore;
|
||||
}
|
||||
const res = await fetch('http://localhost:3003/', { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ p1: userId, p2: opponentName, p1Score: request.body.myScore, p2Score: opponentScore }) });
|
||||
const res = await fetch(score_url + "/", { method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify({ p1: userId, p2: opponentName, p1Score: request.body.myScore, p2Score: opponentScore }) });
|
||||
if (!res.ok) {
|
||||
throw new Error('Internal server error');
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user