diff options
| author | Fuwn <[email protected]> | 2024-10-09 00:41:20 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2024-10-09 00:41:43 -0700 |
| commit | 998b63a35256ac985a5a2714dd1ca451af4dfd8a (patch) | |
| tree | 50796121a9d5ab0330fdc5d7e098bda2860d9726 /src/routes/api/birthdays/primary | |
| parent | feat(graphql): add badgeCount field (diff) | |
| download | due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.tar.xz due.moe-998b63a35256ac985a5a2714dd1ca451af4dfd8a.zip | |
chore(prettier): use spaces instead of tabs
Diffstat (limited to 'src/routes/api/birthdays/primary')
| -rw-r--r-- | src/routes/api/birthdays/primary/+server.ts | 60 |
1 files changed, 30 insertions, 30 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' + } + } + ); }; |