added backend to cache manga updates requests

This commit is contained in:
wea_ondara
2023-11-20 17:01:37 +01:00
parent 34b0135da7
commit 29e1d2e499
19 changed files with 699 additions and 20 deletions

View File

@@ -0,0 +1,24 @@
import {NextFunction, Request, Response, Router} from 'express';
export default function aniListRouter(): Router {
const router = Router();
router.post('/graphql', async (req: Request, res: Response, next: NextFunction) => {
try {
const fromApi = await fetch('https://graphql.anilist.co/graphql', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(req.body),
});
const fromApiText = await fromApi.text()
res.status(fromApi.status).send(fromApiText);
} catch (e) {
console.error(e);
}
next();
});
return router;
}