aboutsummaryrefslogtreecommitdiff
path: root/src/routes/api/mangadex/feed/+server.ts
blob: 458d39144df578fbb3a302f8d4f5940157ee29ab (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { checkRateLimit } from '$lib/rateLimit.js';

export const GET = async (event) => {
	const limit = await checkRateLimit(event);

	if (limit) return limit;

	try {
		return Response.json(
			await (
				await fetch(
					`https://api.mangadex.org/manga/${event.url.searchParams.get(
						'id'
					)}/feed?order[chapter]=desc&translatedLanguage[]=en&limit=1&contentRating[]=safe&contentRating[]=suggestive&contentRating[]=erotica&contentRating[]=pornographic`
				)
			).json(),
			{
				headers: {
					'Cache-Control': 'max-age=300'
				}
			}
		);
	} catch {
		return new Response('rate-limited');
	}
};