aboutsummaryrefslogtreecommitdiff
path: root/src/routes/api/birthdays
diff options
context:
space:
mode:
authorFuwn <[email protected]>2024-10-09 00:41:20 -0700
committerFuwn <[email protected]>2024-10-09 00:41:43 -0700
commit998b63a35256ac985a5a2714dd1ca451af4dfd8a (patch)
tree50796121a9d5ab0330fdc5d7e098bda2860d9726 /src/routes/api/birthdays
parentfeat(graphql): add badgeCount field (diff)
downloaddue.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.tar.xz
due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.zip
chore(prettier): use spaces instead of tabs
Diffstat (limited to 'src/routes/api/birthdays')
-rw-r--r--src/routes/api/birthdays/primary/+server.ts60
-rw-r--r--src/routes/api/birthdays/secondary/+server.ts46
2 files changed, 53 insertions, 53 deletions
diff --git a/src/routes/api/birthdays/primary/+server.ts b/src/routes/api/birthdays/primary/+server.ts
index 0b92a11e..1e480283 100644
--- a/src/routes/api/birthdays/primary/+server.ts
+++ b/src/routes/api/birthdays/primary/+server.ts
@@ -1,40 +1,40 @@
import { JSDOM } from 'jsdom';
export const GET = async ({ url }: { url: URL }) => {
- const document = new JSDOM(
- await (
- await fetch(
- `https://www.anisearch.com/character/birthdays?month=${url.searchParams.get('month')}`
- )
- ).text()
- ).window.document;
- const section = document.querySelector(`#day-${url.searchParams.get('day')}`);
+ const document = new JSDOM(
+ await (
+ await fetch(
+ `https://www.anisearch.com/character/birthdays?month=${url.searchParams.get('month')}`
+ )
+ ).text()
+ ).window.document;
+ const section = document.querySelector(`#day-${url.searchParams.get('day')}`);
- if (!section) return Response.json([]);
+ if (!section) return Response.json([]);
- const ul = section.querySelector('ul.covers.simple');
+ const ul = section.querySelector('ul.covers.simple');
- if (!ul) return Response.json([]);
+ if (!ul) return Response.json([]);
- return Response.json(
- Array.from(ul.querySelectorAll('li')).map((li) => {
- const anchor = li.querySelector('a');
- const title = li.querySelector('.title');
+ return Response.json(
+ Array.from(ul.querySelectorAll('li')).map((li) => {
+ const anchor = li.querySelector('a');
+ const title = li.querySelector('.title');
- if (!anchor || !title) return { image: '', title: '' };
+ if (!anchor || !title) return { image: '', title: '' };
- return {
- image: anchor.getAttribute('data-bg')
- ? `https://cdn.anisearch.com/images/${anchor.getAttribute('data-bg')}`
- : null,
- name: title.textContent?.trim()
- };
- }),
- {
- headers: {
- 'Cache-Control': 'max-age=10800, s-maxage=10800',
- 'Access-Control-Allow-Origin': 'https://due.moe'
- }
- }
- );
+ return {
+ image: anchor.getAttribute('data-bg')
+ ? `https://cdn.anisearch.com/images/${anchor.getAttribute('data-bg')}`
+ : null,
+ name: title.textContent?.trim()
+ };
+ }),
+ {
+ headers: {
+ 'Cache-Control': 'max-age=10800, s-maxage=10800',
+ 'Access-Control-Allow-Origin': 'https://due.moe'
+ }
+ }
+ );
};
diff --git a/src/routes/api/birthdays/secondary/+server.ts b/src/routes/api/birthdays/secondary/+server.ts
index ae9178a0..f28e2e71 100644
--- a/src/routes/api/birthdays/secondary/+server.ts
+++ b/src/routes/api/birthdays/secondary/+server.ts
@@ -1,25 +1,25 @@
export const GET = async ({ url }: { url: URL }) => {
- return Response.json(
- await (
- await fetch(
- `https://www.animecharactersdatabase.com/api_series_characters.php?month=${url.searchParams.get(
- 'month'
- )}&day=${url.searchParams.get('day')}`,
- {
- headers: {
- Accept: 'application/json',
- 'Content-Type': 'application/json',
- 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0',
- 'Cache-Control': 'max-age=10, s-maxage=10'
- }
- }
- )
- ).json(),
- {
- headers: {
- 'Cache-Control': 'max-age=10800, s-maxage=10800',
- 'Access-Control-Allow-Origin': 'https://due.moe'
- }
- }
- );
+ return Response.json(
+ await (
+ await fetch(
+ `https://www.animecharactersdatabase.com/api_series_characters.php?month=${url.searchParams.get(
+ 'month'
+ )}&day=${url.searchParams.get('day')}`,
+ {
+ headers: {
+ Accept: 'application/json',
+ 'Content-Type': 'application/json',
+ 'User-Agent': 'Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0',
+ 'Cache-Control': 'max-age=10, s-maxage=10'
+ }
+ }
+ )
+ ).json(),
+ {
+ headers: {
+ 'Cache-Control': 'max-age=10800, s-maxage=10800',
+ 'Access-Control-Allow-Origin': 'https://due.moe'
+ }
+ }
+ );
};