Compare commits

..

6 Commits

Author SHA1 Message Date
80a6f67ead refactor: decouple Anilist watch status updates from API endpoint to an asynchronous queue worker. 2025-12-16 08:28:33 -05:00
1501aff3b6 fix: adjust task delay threshold to 9 hours
Updates the maximum delay for direct task queuing to 9 hours. This change ensures that tasks with delays exceeding this threshold are stored in KV for later processing.

The update also reflects the new delay threshold in the unit tests.
2025-12-16 08:28:14 -05:00
9b17f5bcfe refactor: rename mockData.ts to mocks.ts and update import paths. 2025-12-16 08:04:26 -05:00
45bf96e764 refactor: Remove Anify and Consumet integrations, their dependencies, and the ipCheck script. 2025-12-16 08:03:05 -05:00
e8c7c7801f chore: Update Vitest async test expectations and remove unused dependencies. 2025-12-16 07:50:39 -05:00
1140ffa8b8 refactor!: migrate away from bun
- migrate package management to pnpm
- migrate test suite to vitest
- also remove Anify integration
2025-12-16 07:50:38 -05:00
20 changed files with 63 additions and 762 deletions

View File

@@ -1 +1 @@
bunx lint-staged nlx lint-staged

View File

@@ -1,7 +0,0 @@
[test]
preload = [
"./testSetup.ts",
"./src/mocks/consumet.ts",
"./src/mocks/getGoogleAuthToken.ts",
"./src/mocks/cloudflare.ts",
]

View File

@@ -17,7 +17,6 @@
"tsx": "tsx" "tsx": "tsx"
}, },
"dependencies": { "dependencies": {
"@consumet/extensions": "github:consumet/consumet.ts#3dd0ccb",
"@hono/swagger-ui": "^0.5.1", "@hono/swagger-ui": "^0.5.1",
"@hono/zod-openapi": "^0.19.5", "@hono/zod-openapi": "^0.19.5",
"@hono/zod-validator": "^0.2.2", "@hono/zod-validator": "^0.2.2",
@@ -27,7 +26,6 @@
"graphql-request": "^7.4.0", "graphql-request": "^7.4.0",
"hono": "^4.7.7", "hono": "^4.7.7",
"jose": "^5.10.0", "jose": "^5.10.0",
"lodash.isequal": "^4.5.0",
"lodash.mapkeys": "^4.6.0", "lodash.mapkeys": "^4.6.0",
"luxon": "^3.6.1", "luxon": "^3.6.1",
"zod": "^3.24.3" "zod": "^3.24.3"
@@ -35,7 +33,6 @@
"devDependencies": { "devDependencies": {
"@cloudflare/vitest-pool-workers": "^0.10.15", "@cloudflare/vitest-pool-workers": "^0.10.15",
"@trivago/prettier-plugin-sort-imports": "^4.3.0", "@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@types/lodash.isequal": "^4.5.8",
"@types/lodash.mapkeys": "^4.6.9", "@types/lodash.mapkeys": "^4.6.9",
"@types/luxon": "^3.6.2", "@types/luxon": "^3.6.2",
"@types/node": "^25.0.1", "@types/node": "^25.0.1",
@@ -54,7 +51,6 @@
"ts-morph": "^22.0.0", "ts-morph": "^22.0.0",
"tsx": "^4.20.6", "tsx": "^4.20.6",
"typescript": "^5.8.3", "typescript": "^5.8.3",
"util": "^0.12.5",
"vitest": "~3.2.4", "vitest": "~3.2.4",
"wrangler": "^4.51.0", "wrangler": "^4.51.0",
"zx": "8.1.5" "zx": "8.1.5"

551
pnpm-lock.yaml generated
View File

@@ -7,9 +7,6 @@ settings:
importers: importers:
.: .:
dependencies: dependencies:
"@consumet/extensions":
specifier: github:consumet/consumet.ts#3dd0ccb
version: https://codeload.github.com/consumet/consumet.ts/tar.gz/3dd0ccb
"@hono/swagger-ui": "@hono/swagger-ui":
specifier: ^0.5.1 specifier: ^0.5.1
version: 0.5.2(hono@4.10.8) version: 0.5.2(hono@4.10.8)
@@ -37,9 +34,6 @@ importers:
jose: jose:
specifier: ^5.10.0 specifier: ^5.10.0
version: 5.10.0 version: 5.10.0
lodash.isequal:
specifier: ^4.5.0
version: 4.5.0
lodash.mapkeys: lodash.mapkeys:
specifier: ^4.6.0 specifier: ^4.6.0
version: 4.6.0 version: 4.6.0
@@ -56,9 +50,6 @@ importers:
"@trivago/prettier-plugin-sort-imports": "@trivago/prettier-plugin-sort-imports":
specifier: ^4.3.0 specifier: ^4.3.0
version: 4.3.0(prettier@3.7.4) version: 4.3.0(prettier@3.7.4)
"@types/lodash.isequal":
specifier: ^4.5.8
version: 4.5.8
"@types/lodash.mapkeys": "@types/lodash.mapkeys":
specifier: ^4.6.9 specifier: ^4.6.9
version: 4.6.9 version: 4.6.9
@@ -113,9 +104,6 @@ importers:
typescript: typescript:
specifier: ^5.8.3 specifier: ^5.8.3
version: 5.9.3 version: 5.9.3
util:
specifier: ^0.12.5
version: 0.12.5
vitest: vitest:
specifier: ~3.2.4 specifier: ~3.2.4
version: 3.2.4(@types/node@25.0.1)(@vitest/ui@3.2.4)(tsx@4.21.0)(yaml@2.8.2) version: 3.2.4(@types/node@25.0.1)(@vitest/ui@3.2.4)(tsx@4.21.0)(yaml@2.8.2)
@@ -438,13 +426,6 @@ packages:
cpu: [x64] cpu: [x64]
os: [win32] os: [win32]
"@consumet/extensions@https://codeload.github.com/consumet/consumet.ts/tar.gz/3dd0ccb":
resolution:
{
tarball: https://codeload.github.com/consumet/consumet.ts/tar.gz/3dd0ccb,
}
version: 1.7.0
"@cspotcode/source-map-support@0.8.1": "@cspotcode/source-map-support@0.8.1":
resolution: resolution:
{ {
@@ -1969,12 +1950,6 @@ packages:
integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==, integrity: sha512-D5qGUYwjvnNNextdU59/+fI+spnwtTFmyQP0h+PfIOSkNfpU6AOICUOkm4i0OnSk+NyjdPJrxCDro0sJsWlRpQ==,
} }
"@types/lodash.isequal@4.5.8":
resolution:
{
integrity: sha512-uput6pg4E/tj2LGxCZo9+y27JNyB2OZuuI/T5F+ylVDYuqICLG2/ktjxx0v6GvVntAf8TvEzeQLcV0ffRirXuA==,
}
"@types/lodash.mapkeys@4.6.9": "@types/lodash.mapkeys@4.6.9":
resolution: resolution:
{ {
@@ -2154,12 +2129,6 @@ packages:
integrity: sha512-xvsWESUJn0JN421Xb9MQw6AsMHRCUknCe0Wjlxvjud80mU4E6hQf1A6NzQKcYNmYw62MfzEtXc+badstZP3JpQ==, integrity: sha512-xvsWESUJn0JN421Xb9MQw6AsMHRCUknCe0Wjlxvjud80mU4E6hQf1A6NzQKcYNmYw62MfzEtXc+badstZP3JpQ==,
} }
ascii-url-encoder@1.2.0:
resolution:
{
integrity: sha512-jRQMrz1ZqL7gnK60Xbu1S8kDi01UN+lHBnhvXZZqjd7nms7t4jOv4o9nE8bbfDh1Ts/KEtW2nXGR5CmydDBmlw==,
}
assertion-error@2.0.1: assertion-error@2.0.1:
resolution: resolution:
{ {
@@ -2173,19 +2142,6 @@ packages:
integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==, integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==,
} }
available-typed-arrays@1.0.7:
resolution:
{
integrity: sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==,
}
engines: { node: ">= 0.4" }
axios@0.27.2:
resolution:
{
integrity: sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ==,
}
balanced-match@1.0.2: balanced-match@1.0.2:
resolution: resolution:
{ {
@@ -2211,12 +2167,6 @@ packages:
integrity: sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==, integrity: sha512-F1+K8EbfOZE49dtoPtmxUQrpXaBIl3ICvasLh+nJta0xkz+9kF/7uet9fLnwKqhDrmj6g+6K3Tw9yQPUg2ka5g==,
} }
boolbase@1.0.0:
resolution:
{
integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==,
}
brace-expansion@2.0.2: brace-expansion@2.0.2:
resolution: resolution:
{ {
@@ -2264,20 +2214,6 @@ packages:
} }
engines: { node: ">= 0.4" } engines: { node: ">= 0.4" }
call-bind@1.0.8:
resolution:
{
integrity: sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==,
}
engines: { node: ">= 0.4" }
call-bound@1.0.4:
resolution:
{
integrity: sha512-+ys997U96po4Kx/ABpBCqhA9EuxJaQWDQg7295H4hBphv3IZg0boBKuwYpt4YXp6MZ5AmZQnU/tyMTlRpaSejg==,
}
engines: { node: ">= 0.4" }
caniuse-lite@1.0.30001760: caniuse-lite@1.0.30001760:
resolution: resolution:
{ {
@@ -2305,19 +2241,6 @@ packages:
} }
engines: { node: ">= 16" } engines: { node: ">= 16" }
cheerio-select@2.1.0:
resolution:
{
integrity: sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g==,
}
cheerio@1.1.2:
resolution:
{
integrity: sha512-IkxPpb5rS/d1IiLbHMgfPuS0FgiWTtFIm/Nj+2woXDLTZ7fOT2eqzgYbdMlLweqlHbsZjxEChoVK+7iph7jyQg==,
}
engines: { node: ">=20.18.1" }
cjs-module-lexer@1.4.3: cjs-module-lexer@1.4.3:
resolution: resolution:
{ {
@@ -2423,25 +2346,6 @@ packages:
} }
engines: { node: ">= 8" } engines: { node: ">= 8" }
crypto-js@4.2.0:
resolution:
{
integrity: sha512-KALDyEYgpY+Rlob/iriUtjV6d5Eq+Y191A5g4UqLAi8CyGP9N1+FdVbkc1SxKc2r4YAYqG8JzO2KGL+AizD70Q==,
}
css-select@5.2.2:
resolution:
{
integrity: sha512-TizTzUddG/xYLA3NXodFM0fSbNizXjOKhqiQQwvhlspadZokn1KDy0NZFS0wuEubIYAV5/c1/lAr0TaaFXEXzw==,
}
css-what@6.2.2:
resolution:
{
integrity: sha512-u/O3vwbptzhMs3L1fQE82ZSLHQQfto5gyZzwteVIEyeaY5Fc7R4dapF/BvRoSYFeqfBk4m0V1Vafq5Pjv25wvA==,
}
engines: { node: ">= 6" }
data-uri-to-buffer@2.0.2: data-uri-to-buffer@2.0.2:
resolution: resolution:
{ {
@@ -2467,13 +2371,6 @@ packages:
} }
engines: { node: ">=6" } engines: { node: ">=6" }
define-data-property@1.1.4:
resolution:
{
integrity: sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==,
}
engines: { node: ">= 0.4" }
delayed-stream@1.0.0: delayed-stream@1.0.0:
resolution: resolution:
{ {
@@ -2494,31 +2391,6 @@ packages:
integrity: sha512-jDwizj+IlEZBunHcOuuFVBnIMPAEHvTsJj0BcIp94xYguLRVBcXO853px/MyIJvbVzWdsGvrRweIUWJw8hBP7A==, integrity: sha512-jDwizj+IlEZBunHcOuuFVBnIMPAEHvTsJj0BcIp94xYguLRVBcXO853px/MyIJvbVzWdsGvrRweIUWJw8hBP7A==,
} }
dom-serializer@2.0.0:
resolution:
{
integrity: sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg==,
}
domelementtype@2.3.0:
resolution:
{
integrity: sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==,
}
domhandler@5.0.3:
resolution:
{
integrity: sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w==,
}
engines: { node: ">= 4" }
domutils@3.2.2:
resolution:
{
integrity: sha512-6kZKyUajlDuqlHKVX1w7gyslj9MPIXzIFiz/rGu35uC1wMi+kMhQwGhl4lt9unC9Vb9INnY9Z3/ZA3+FhASLaw==,
}
dotenv@17.2.3: dotenv@17.2.3:
resolution: resolution:
{ {
@@ -2671,26 +2543,6 @@ packages:
integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==, integrity: sha512-L18DaJsXSUk2+42pv8mLs5jJT2hqFkFE4j21wOmgbUqsZ2hL72NsUU785g9RXgo3s0ZNgVl42TiHp3ZtOv/Vyg==,
} }
encoding-sniffer@0.2.1:
resolution:
{
integrity: sha512-5gvq20T6vfpekVtqrYQsSCFZ1wEg5+wW0/QaZMWkFr6BqD3NfKs0rLCx4rrVlSWJeZb5NBJgVLswK/w2MWU+Gw==,
}
entities@4.5.0:
resolution:
{
integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==,
}
engines: { node: ">=0.12" }
entities@6.0.1:
resolution:
{
integrity: sha512-aN97NXWF6AWBTahfVOIrB/NShkzi5H7F9r1s9mD3cDj4Ko5f2qhhVoYMibXF7GlLveb/D2ioWay8lxI97Ven3g==,
}
engines: { node: ">=0.12" }
environment@1.1.0: environment@1.1.0:
resolution: resolution:
{ {
@@ -2875,25 +2727,6 @@ packages:
integrity: sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==, integrity: sha512-GX+ysw4PBCz0PzosHDepZGANEuFCMLrnRTiEy9McGjmkCQYwRq4A/X786G/fjM/+OjsWSU1ZrY5qyARZmO/uwg==,
} }
follow-redirects@1.15.11:
resolution:
{
integrity: sha512-deG2P0JfjrTxl50XGCDyfI97ZGVCxIpfKYmfyrQ54n5FO/0gfIES8C/Psl6kWVDolizcaaxZJnTS0QSMxvnsBQ==,
}
engines: { node: ">=4.0" }
peerDependencies:
debug: "*"
peerDependenciesMeta:
debug:
optional: true
for-each@0.3.5:
resolution:
{
integrity: sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==,
}
engines: { node: ">= 0.4" }
foreground-child@3.3.1: foreground-child@3.3.1:
resolution: resolution:
{ {
@@ -2942,13 +2775,6 @@ packages:
} }
engines: { node: ">=14" } engines: { node: ">=14" }
generator-function@2.0.1:
resolution:
{
integrity: sha512-SFdFmIJi+ybC0vjlHN0ZGVGHc3lgE0DxPAT0djjVg+kjOnSqclqmj0KQ7ykTOLP6YxoqOvuAODGdcHJn+43q3g==,
}
engines: { node: ">= 0.4" }
gensync@1.0.0-beta.2: gensync@1.0.0-beta.2:
resolution: resolution:
{ {
@@ -3068,12 +2894,6 @@ packages:
} }
engines: { node: ">=8" } engines: { node: ">=8" }
has-property-descriptors@1.0.2:
resolution:
{
integrity: sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==,
}
has-symbols@1.1.0: has-symbols@1.1.0:
resolution: resolution:
{ {
@@ -3108,12 +2928,6 @@ packages:
integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==, integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==,
} }
htmlparser2@10.0.0:
resolution:
{
integrity: sha512-TwAZM+zE5Tq3lrEHvOlvwgj1XLWQCtaaibSN11Q+gGBAS7Y1uZSWwXXRe4iF6OXnaq1riyQAPFOBtYc77Mxq0g==,
}
https-proxy-agent@7.0.6: https-proxy-agent@7.0.6:
resolution: resolution:
{ {
@@ -3142,39 +2956,12 @@ packages:
engines: { node: ">=18" } engines: { node: ">=18" }
hasBin: true hasBin: true
iconv-lite@0.6.3:
resolution:
{
integrity: sha512-4fCk79wshMdzMp2rH06qWrJE4iolqLhCUH+OiuIgU++RB0+94NlDL81atO7GX55uUKueo0txHNtvEyI6D7WdMw==,
}
engines: { node: ">=0.10.0" }
inherits@2.0.4:
resolution:
{
integrity: sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==,
}
is-arguments@1.2.0:
resolution:
{
integrity: sha512-7bVbi0huj/wrIAOzb8U1aszg9kdi3KN/CyU19CTI7tAoZYEZoL9yCDXpbXN+uPsuWnP02cyug1gleqq+TU+YCA==,
}
engines: { node: ">= 0.4" }
is-arrayish@0.3.4: is-arrayish@0.3.4:
resolution: resolution:
{ {
integrity: sha512-m6UrgzFVUYawGBh1dUsWR5M2Clqic9RVXC/9f8ceNlv2IcO9j9J/z8UoCLPqtsPBFNzEpfR3xftohbfqDx8EQA==, integrity: sha512-m6UrgzFVUYawGBh1dUsWR5M2Clqic9RVXC/9f8ceNlv2IcO9j9J/z8UoCLPqtsPBFNzEpfR3xftohbfqDx8EQA==,
} }
is-callable@1.2.7:
resolution:
{
integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==,
}
engines: { node: ">= 0.4" }
is-extglob@2.1.1: is-extglob@2.1.1:
resolution: resolution:
{ {
@@ -3203,13 +2990,6 @@ packages:
} }
engines: { node: ">=18" } engines: { node: ">=18" }
is-generator-function@1.1.2:
resolution:
{
integrity: sha512-upqt1SkGkODW9tsGNG5mtXTXtECizwtS2kA161M+gJPc1xdb/Ax629af6YrTwcOeQHbewrPNlE5Dx7kzvXTizA==,
}
engines: { node: ">= 0.4" }
is-glob@4.0.3: is-glob@4.0.3:
resolution: resolution:
{ {
@@ -3224,13 +3004,6 @@ packages:
} }
engines: { node: ">=0.12.0" } engines: { node: ">=0.12.0" }
is-regex@1.2.1:
resolution:
{
integrity: sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==,
}
engines: { node: ">= 0.4" }
is-stream@2.0.1: is-stream@2.0.1:
resolution: resolution:
{ {
@@ -3245,13 +3018,6 @@ packages:
} }
engines: { node: ^12.20.0 || ^14.13.1 || >=16.0.0 } engines: { node: ^12.20.0 || ^14.13.1 || >=16.0.0 }
is-typed-array@1.1.15:
resolution:
{
integrity: sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==,
}
engines: { node: ">= 0.4" }
isexe@2.0.0: isexe@2.0.0:
resolution: resolution:
{ {
@@ -3388,13 +3154,6 @@ packages:
} }
engines: { node: ">=18.0.0" } engines: { node: ">=18.0.0" }
lodash.isequal@4.5.0:
resolution:
{
integrity: sha512-pDo3lu8Jhfjqls6GkMgpahsF9kCyayhgykjyLMNFTKWrpVdAQtYyB4muAMWozBB4ig/dtWAmsMxLEI8wuz+DYQ==,
}
deprecated: This package is deprecated. Use require('node:util').isDeepStrictEqual instead.
lodash.mapkeys@4.6.0: lodash.mapkeys@4.6.0:
resolution: resolution:
{ {
@@ -3620,12 +3379,6 @@ packages:
} }
engines: { node: ^12.20.0 || ^14.13.1 || >=16.0.0 } engines: { node: ^12.20.0 || ^14.13.1 || >=16.0.0 }
nth-check@2.1.1:
resolution:
{
integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==,
}
onetime@6.0.0: onetime@6.0.0:
resolution: resolution:
{ {
@@ -3652,24 +3405,6 @@ packages:
integrity: sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==, integrity: sha512-UEZIS3/by4OC8vL3P2dTXRETpebLI2NiI5vIrjaD/5UtrkFX/tNbwjTSRAGC/+7CAo2pIcBaRgWmcBBHcsaCIw==,
} }
parse5-htmlparser2-tree-adapter@7.1.0:
resolution:
{
integrity: sha512-ruw5xyKs6lrpo9x9rCZqZZnIUntICjQAd0Wsmp396Ul9lN/h+ifgVV1x1gZHi8euej6wTfpqX8j+BFQxF0NS/g==,
}
parse5-parser-stream@7.1.2:
resolution:
{
integrity: sha512-JyeQc9iwFLn5TbvvqACIF/VXG6abODeB3Fwmv/TGdLk2LfbWkaySGY72at4+Ty7EkPZj854u4CrICqNk2qIbow==,
}
parse5@7.3.0:
resolution:
{
integrity: sha512-IInvU7fabl34qmi9gY8XOVxhYyMyuH2xUNpb2q8/Y+7552KlejkRvqvD19nMoUW/uQGGbqNpA6Tufu5FL5BZgw==,
}
path-browserify@1.0.1: path-browserify@1.0.1:
resolution: resolution:
{ {
@@ -3744,13 +3479,6 @@ packages:
engines: { node: ">=0.10" } engines: { node: ">=0.10" }
hasBin: true hasBin: true
possible-typed-array-names@1.1.0:
resolution:
{
integrity: sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==,
}
engines: { node: ">= 0.4" }
postcss@8.5.6: postcss@8.5.6:
resolution: resolution:
{ {
@@ -3833,19 +3561,6 @@ packages:
integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==, integrity: sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==,
} }
safe-regex-test@1.1.0:
resolution:
{
integrity: sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==,
}
engines: { node: ">= 0.4" }
safer-buffer@2.1.2:
resolution:
{
integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==,
}
semver@6.3.1: semver@6.3.1:
resolution: resolution:
{ {
@@ -3861,13 +3576,6 @@ packages:
engines: { node: ">=10" } engines: { node: ">=10" }
hasBin: true hasBin: true
set-function-length@1.2.2:
resolution:
{
integrity: sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==,
}
engines: { node: ">= 0.4" }
sharp@0.33.5: sharp@0.33.5:
resolution: resolution:
{ {
@@ -4178,13 +3886,6 @@ packages:
} }
engines: { node: ">=20.18.1" } engines: { node: ">=20.18.1" }
undici@7.16.0:
resolution:
{
integrity: sha512-QEg3HPMll0o3t2ourKwOeUAZ159Kn9mx5pnzHRQO8+Wixmh88YdZRiIwat0iNzNNXn0yoEtXJqFpyW7eM8BV7g==,
}
engines: { node: ">=20.18.1" }
unenv@2.0.0-rc.24: unenv@2.0.0-rc.24:
resolution: resolution:
{ {
@@ -4200,12 +3901,6 @@ packages:
peerDependencies: peerDependencies:
browserslist: ">= 4.21.0" browserslist: ">= 4.21.0"
util@0.12.5:
resolution:
{
integrity: sha512-kZf/K6hEIrWHI6XqOFUiiMa+79wE/D8Q+NCNAWclkyg3b4d2k7s0QGepNjiABc+aR3N1PAyHL7p6UcLY6LmrnA==,
}
uuid@9.0.1: uuid@9.0.1:
resolution: resolution:
{ {
@@ -4308,33 +4003,12 @@ packages:
integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==, integrity: sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==,
} }
whatwg-encoding@3.1.1:
resolution:
{
integrity: sha512-6qN4hJdMwfYBtE3YBTTHhoeuUrDBPZmbQaxWAqSALV/MeEnR5z1xd8UKud2RAkFoPkmB+hli1TZSnyi84xz1vQ==,
}
engines: { node: ">=18" }
whatwg-mimetype@4.0.0:
resolution:
{
integrity: sha512-QaKxh0eNIi2mE9p2vEdzfagOKHCcj1pJ56EEHGQOVxp8r9/iszLUUV7v89x9O1p/T+NlTM5W7jW6+cz4Fq1YVg==,
}
engines: { node: ">=18" }
whatwg-url@5.0.0: whatwg-url@5.0.0:
resolution: resolution:
{ {
integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==, integrity: sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==,
} }
which-typed-array@1.1.19:
resolution:
{
integrity: sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw==,
}
engines: { node: ">= 0.4" }
which@2.0.2: which@2.0.2:
resolution: resolution:
{ {
@@ -4684,17 +4358,6 @@ snapshots:
"@cloudflare/workerd-windows-64@1.20251210.0": "@cloudflare/workerd-windows-64@1.20251210.0":
optional: true optional: true
"@consumet/extensions@https://codeload.github.com/consumet/consumet.ts/tar.gz/3dd0ccb":
dependencies:
ascii-url-encoder: 1.2.0
axios: 0.27.2
cheerio: 1.1.2
crypto-js: 4.2.0
form-data: 4.0.5
husky: 9.1.7
transitivePeerDependencies:
- debug
"@cspotcode/source-map-support@0.8.1": "@cspotcode/source-map-support@0.8.1":
dependencies: dependencies:
"@jridgewell/trace-mapping": 0.3.9 "@jridgewell/trace-mapping": 0.3.9
@@ -5311,10 +4974,6 @@ snapshots:
"@types/node": 25.0.1 "@types/node": 25.0.1
optional: true optional: true
"@types/lodash.isequal@4.5.8":
dependencies:
"@types/lodash": 4.17.21
"@types/lodash.mapkeys@4.6.9": "@types/lodash.mapkeys@4.6.9":
dependencies: dependencies:
"@types/lodash": 4.17.21 "@types/lodash": 4.17.21
@@ -5437,23 +5096,10 @@ snapshots:
dependencies: dependencies:
printable-characters: 1.0.42 printable-characters: 1.0.42
ascii-url-encoder@1.2.0: {}
assertion-error@2.0.1: {} assertion-error@2.0.1: {}
asynckit@0.4.0: {} asynckit@0.4.0: {}
available-typed-arrays@1.0.7:
dependencies:
possible-typed-array-names: 1.1.0
axios@0.27.2:
dependencies:
follow-redirects: 1.15.11
form-data: 4.0.5
transitivePeerDependencies:
- debug
balanced-match@1.0.2: {} balanced-match@1.0.2: {}
baseline-browser-mapping@2.9.7: {} baseline-browser-mapping@2.9.7: {}
@@ -5462,8 +5108,6 @@ snapshots:
blake3-wasm@2.1.5: {} blake3-wasm@2.1.5: {}
boolbase@1.0.0: {}
brace-expansion@2.0.2: brace-expansion@2.0.2:
dependencies: dependencies:
balanced-match: 1.0.2 balanced-match: 1.0.2
@@ -5491,18 +5135,6 @@ snapshots:
es-errors: 1.3.0 es-errors: 1.3.0
function-bind: 1.1.2 function-bind: 1.1.2
call-bind@1.0.8:
dependencies:
call-bind-apply-helpers: 1.0.2
es-define-property: 1.0.1
get-intrinsic: 1.3.0
set-function-length: 1.2.2
call-bound@1.0.4:
dependencies:
call-bind-apply-helpers: 1.0.2
get-intrinsic: 1.3.0
caniuse-lite@1.0.30001760: {} caniuse-lite@1.0.30001760: {}
chai@5.3.3: chai@5.3.3:
@@ -5517,29 +5149,6 @@ snapshots:
check-error@2.1.1: {} check-error@2.1.1: {}
cheerio-select@2.1.0:
dependencies:
boolbase: 1.0.0
css-select: 5.2.2
css-what: 6.2.2
domelementtype: 2.3.0
domhandler: 5.0.3
domutils: 3.2.2
cheerio@1.1.2:
dependencies:
cheerio-select: 2.1.0
dom-serializer: 2.0.0
domhandler: 5.0.3
domutils: 3.2.2
encoding-sniffer: 0.2.1
htmlparser2: 10.0.0
parse5: 7.3.0
parse5-htmlparser2-tree-adapter: 7.1.0
parse5-parser-stream: 7.1.2
undici: 7.16.0
whatwg-mimetype: 4.0.0
cjs-module-lexer@1.4.3: {} cjs-module-lexer@1.4.3: {}
cli-cursor@5.0.0: cli-cursor@5.0.0:
@@ -5601,18 +5210,6 @@ snapshots:
shebang-command: 2.0.0 shebang-command: 2.0.0
which: 2.0.2 which: 2.0.2
crypto-js@4.2.0: {}
css-select@5.2.2:
dependencies:
boolbase: 1.0.0
css-what: 6.2.2
domhandler: 5.0.3
domutils: 3.2.2
nth-check: 2.1.1
css-what@6.2.2: {}
data-uri-to-buffer@2.0.2: {} data-uri-to-buffer@2.0.2: {}
debug@4.4.3: debug@4.4.3:
@@ -5621,36 +5218,12 @@ snapshots:
deep-eql@5.0.2: {} deep-eql@5.0.2: {}
define-data-property@1.1.4:
dependencies:
es-define-property: 1.0.1
es-errors: 1.3.0
gopd: 1.2.0
delayed-stream@1.0.0: {} delayed-stream@1.0.0: {}
detect-libc@2.1.2: {} detect-libc@2.1.2: {}
devalue@5.6.1: {} devalue@5.6.1: {}
dom-serializer@2.0.0:
dependencies:
domelementtype: 2.3.0
domhandler: 5.0.3
entities: 4.5.0
domelementtype@2.3.0: {}
domhandler@5.0.3:
dependencies:
domelementtype: 2.3.0
domutils@3.2.2:
dependencies:
dom-serializer: 2.0.0
domelementtype: 2.3.0
domhandler: 5.0.3
dotenv@17.2.3: {} dotenv@17.2.3: {}
drizzle-kit@0.31.8: drizzle-kit@0.31.8:
@@ -5684,15 +5257,6 @@ snapshots:
emoji-regex@9.2.2: {} emoji-regex@9.2.2: {}
encoding-sniffer@0.2.1:
dependencies:
iconv-lite: 0.6.3
whatwg-encoding: 3.1.1
entities@4.5.0: {}
entities@6.0.1: {}
environment@1.1.0: {} environment@1.1.0: {}
error-stack-parser-es@1.0.5: {} error-stack-parser-es@1.0.5: {}
@@ -5885,12 +5449,6 @@ snapshots:
flatted@3.3.3: {} flatted@3.3.3: {}
follow-redirects@1.15.11: {}
for-each@0.3.5:
dependencies:
is-callable: 1.2.7
foreground-child@3.3.1: foreground-child@3.3.1:
dependencies: dependencies:
cross-spawn: 7.0.6 cross-spawn: 7.0.6
@@ -5927,8 +5485,6 @@ snapshots:
- encoding - encoding
- supports-color - supports-color
generator-function@2.0.1: {}
gensync@1.0.0-beta.2: {} gensync@1.0.0-beta.2: {}
get-east-asian-width@1.4.0: {} get-east-asian-width@1.4.0: {}
@@ -6010,10 +5566,6 @@ snapshots:
has-flag@4.0.0: {} has-flag@4.0.0: {}
has-property-descriptors@1.0.2:
dependencies:
es-define-property: 1.0.1
has-symbols@1.1.0: {} has-symbols@1.1.0: {}
has-tostringtag@1.0.2: has-tostringtag@1.0.2:
@@ -6028,13 +5580,6 @@ snapshots:
html-escaper@2.0.2: {} html-escaper@2.0.2: {}
htmlparser2@10.0.0:
dependencies:
domelementtype: 2.3.0
domhandler: 5.0.3
domutils: 3.2.2
entities: 6.0.1
https-proxy-agent@7.0.6: https-proxy-agent@7.0.6:
dependencies: dependencies:
agent-base: 7.1.4 agent-base: 7.1.4
@@ -6050,21 +5595,8 @@ snapshots:
husky@9.1.7: {} husky@9.1.7: {}
iconv-lite@0.6.3:
dependencies:
safer-buffer: 2.1.2
inherits@2.0.4: {}
is-arguments@1.2.0:
dependencies:
call-bound: 1.0.4
has-tostringtag: 1.0.2
is-arrayish@0.3.4: {} is-arrayish@0.3.4: {}
is-callable@1.2.7: {}
is-extglob@2.1.1: {} is-extglob@2.1.1: {}
is-fullwidth-code-point@3.0.0: {} is-fullwidth-code-point@3.0.0: {}
@@ -6075,35 +5607,16 @@ snapshots:
dependencies: dependencies:
get-east-asian-width: 1.4.0 get-east-asian-width: 1.4.0
is-generator-function@1.1.2:
dependencies:
call-bound: 1.0.4
generator-function: 2.0.1
get-proto: 1.0.1
has-tostringtag: 1.0.2
safe-regex-test: 1.1.0
is-glob@4.0.3: is-glob@4.0.3:
dependencies: dependencies:
is-extglob: 2.1.1 is-extglob: 2.1.1
is-number@7.0.0: {} is-number@7.0.0: {}
is-regex@1.2.1:
dependencies:
call-bound: 1.0.4
gopd: 1.2.0
has-tostringtag: 1.0.2
hasown: 2.0.2
is-stream@2.0.1: {} is-stream@2.0.1: {}
is-stream@3.0.0: {} is-stream@3.0.0: {}
is-typed-array@1.1.15:
dependencies:
which-typed-array: 1.1.19
isexe@2.0.0: {} isexe@2.0.0: {}
istanbul-lib-coverage@3.2.2: {} istanbul-lib-coverage@3.2.2: {}
@@ -6196,8 +5709,6 @@ snapshots:
rfdc: 1.4.1 rfdc: 1.4.1
wrap-ansi: 9.0.2 wrap-ansi: 9.0.2
lodash.isequal@4.5.0: {}
lodash.mapkeys@4.6.0: {} lodash.mapkeys@4.6.0: {}
lodash@4.17.21: {} lodash@4.17.21: {}
@@ -6320,10 +5831,6 @@ snapshots:
dependencies: dependencies:
path-key: 4.0.0 path-key: 4.0.0
nth-check@2.1.1:
dependencies:
boolbase: 1.0.0
onetime@6.0.0: onetime@6.0.0:
dependencies: dependencies:
mimic-fn: 4.0.0 mimic-fn: 4.0.0
@@ -6338,19 +5845,6 @@ snapshots:
package-json-from-dist@1.0.1: {} package-json-from-dist@1.0.1: {}
parse5-htmlparser2-tree-adapter@7.1.0:
dependencies:
domhandler: 5.0.3
parse5: 7.3.0
parse5-parser-stream@7.1.2:
dependencies:
parse5: 7.3.0
parse5@7.3.0:
dependencies:
entities: 6.0.1
path-browserify@1.0.1: {} path-browserify@1.0.1: {}
path-key@3.1.1: {} path-key@3.1.1: {}
@@ -6376,8 +5870,6 @@ snapshots:
pidtree@0.6.0: {} pidtree@0.6.0: {}
possible-typed-array-names@1.1.0: {}
postcss@8.5.6: postcss@8.5.6:
dependencies: dependencies:
nanoid: 3.3.11 nanoid: 3.3.11
@@ -6440,27 +5932,10 @@ snapshots:
safe-buffer@5.2.1: {} safe-buffer@5.2.1: {}
safe-regex-test@1.1.0:
dependencies:
call-bound: 1.0.4
es-errors: 1.3.0
is-regex: 1.2.1
safer-buffer@2.1.2: {}
semver@6.3.1: {} semver@6.3.1: {}
semver@7.7.3: {} semver@7.7.3: {}
set-function-length@1.2.2:
dependencies:
define-data-property: 1.1.4
es-errors: 1.3.0
function-bind: 1.1.2
get-intrinsic: 1.3.0
gopd: 1.2.0
has-property-descriptors: 1.0.2
sharp@0.33.5: sharp@0.33.5:
dependencies: dependencies:
color: 4.2.3 color: 4.2.3
@@ -6637,8 +6112,6 @@ snapshots:
undici@7.14.0: {} undici@7.14.0: {}
undici@7.16.0: {}
unenv@2.0.0-rc.24: unenv@2.0.0-rc.24:
dependencies: dependencies:
pathe: 2.0.3 pathe: 2.0.3
@@ -6649,14 +6122,6 @@ snapshots:
escalade: 3.2.0 escalade: 3.2.0
picocolors: 1.1.1 picocolors: 1.1.1
util@0.12.5:
dependencies:
inherits: 2.0.4
is-arguments: 1.2.0
is-generator-function: 1.1.2
is-typed-array: 1.1.15
which-typed-array: 1.1.19
uuid@9.0.1: {} uuid@9.0.1: {}
vite-node@3.2.4(@types/node@25.0.1)(tsx@4.21.0)(yaml@2.8.2): vite-node@3.2.4(@types/node@25.0.1)(tsx@4.21.0)(yaml@2.8.2):
@@ -6740,27 +6205,11 @@ snapshots:
webidl-conversions@3.0.1: {} webidl-conversions@3.0.1: {}
whatwg-encoding@3.1.1:
dependencies:
iconv-lite: 0.6.3
whatwg-mimetype@4.0.0: {}
whatwg-url@5.0.0: whatwg-url@5.0.0:
dependencies: dependencies:
tr46: 0.0.3 tr46: 0.0.3
webidl-conversions: 3.0.1 webidl-conversions: 3.0.1
which-typed-array@1.1.19:
dependencies:
available-typed-arrays: 1.0.7
call-bind: 1.0.8
call-bound: 1.0.4
for-each: 0.3.5
get-proto: 1.0.1
gopd: 1.2.0
has-tostringtag: 1.0.2
which@2.0.2: which@2.0.2:
dependencies: dependencies:
isexe: 2.0.0 isexe: 2.0.0

View File

@@ -1,5 +0,0 @@
import { ANIME, META } from "@consumet/extensions";
import fetchAdapter from "@haverstack/axios-fetch-adapter";
const gogoAnime = new ANIME.Gogoanime(undefined, undefined, fetchAdapter);
export const aniList = new META.Anilist(gogoAnime, undefined, fetchAdapter);

View File

@@ -52,7 +52,7 @@ app.openapi(route, async (c) => {
// Check if we should use mock data // Check if we should use mock data
const { useMockData } = await import("~/libs/useMockData"); const { useMockData } = await import("~/libs/useMockData");
if (useMockData()) { if (useMockData()) {
const { mockEpisodes } = await import("~/mocks/mockData"); const { mockEpisodes } = await import("~/mocks");
return c.json({ return c.json({
success: true, success: true,

View File

@@ -1,64 +0,0 @@
import { sortByProperty } from "~/libs/sortByProperty";
import type { FetchUrlResponse } from "~/types/episode/fetch-url-response";
import { type SkipTime, convertSkipTime } from "./convertSkipTime";
import {
audioPriority,
qualityPriority,
subtitlesPriority,
} from "./priorities";
export async function getSourcesFromAnify(
provider: string,
watchId: string,
aniListId: number,
): Promise<FetchUrlResponse | null> {
const response = await fetch("https://anify.eltik.cc/sources", {
body: JSON.stringify({
watchId,
providerId: provider,
episodeNumber: "1",
id: aniListId.toString(),
subType: "sub",
}),
method: "POST",
}).then((res) => res.json() as Promise<AnifySourcesResponse>);
const { sources, subtitles, audio, intro, outro, headers } = response;
if (!sources || sources.length === 0) {
return null;
}
const source = sources.sort(sortByProperty(qualityPriority, "quality"))[0]
?.url;
subtitles?.sort(sortByProperty(subtitlesPriority, "lang"));
audio?.sort(sortByProperty(audioPriority, "lang"));
return {
source,
audio,
subtitles,
intro: convertSkipTime(intro),
outro: convertSkipTime(outro),
headers: Object.keys(headers ?? {}).length > 0 ? headers : undefined,
};
}
interface AnifySourcesResponse {
sources: VideoSource[];
subtitles: LanguageSource[];
audio: LanguageSource[];
intro: SkipTime;
outro: SkipTime;
headers?: Record<string, string>;
}
interface VideoSource {
url: string;
quality: string;
}
interface LanguageSource {
url: string;
lang: string;
}

View File

@@ -123,7 +123,7 @@ app.openapi(route, async (c) => {
// Check if we should use mock data // Check if we should use mock data
const { useMockData } = await import("~/libs/useMockData"); const { useMockData } = await import("~/libs/useMockData");
if (useMockData()) { if (useMockData()) {
const { mockEpisodeUrl } = await import("~/mocks/mockData"); const { mockEpisodeUrl } = await import("~/mocks");
return c.json({ success: true, result: mockEpisodeUrl }); return c.json({ success: true, result: mockEpisodeUrl });
} }

View File

@@ -41,7 +41,7 @@ app.openapi(route, async (c) => {
// Check if we should use mock data // Check if we should use mock data
const { useMockData } = await import("~/libs/useMockData"); const { useMockData } = await import("~/libs/useMockData");
if (useMockData()) { if (useMockData()) {
const { mockSearchResults } = await import("~/mocks/mockData"); const { mockSearchResults } = await import("~/mocks");
// Paginate mock results // Paginate mock results
const startIndex = (page - 1) * limit; const startIndex = (page - 1) * limit;

View File

@@ -49,7 +49,7 @@ app.openapi(route, async (c) => {
// Check if we should use mock data // Check if we should use mock data
const { useMockData } = await import("~/libs/useMockData"); const { useMockData } = await import("~/libs/useMockData");
if (useMockData()) { if (useMockData()) {
const { mockTitleDetails } = await import("~/mocks/mockData"); const { mockTitleDetails } = await import("~/mocks");
return c.json({ success: true, result: mockTitleDetails() }, 200); return c.json({ success: true, result: mockTitleDetails() }, 200);
} }

View File

@@ -30,19 +30,11 @@ const DeleteMediaListEntryMutation = graphql(`
} }
`); `);
/** Updates the watch status for a title on Anilist. If the token is null, the watch status will not be updated. export async function updateWatchStatusOnAnilist(
*
* @returns true if the watch status was updated or if the token was null, false if it was not
*/
export async function maybeUpdateWatchStatusOnAnilist(
titleId: number, titleId: number,
watchStatus: WatchStatus | null, watchStatus: WatchStatus | null,
aniListToken: string | undefined, aniListToken: string,
) { ) {
if (!aniListToken) {
return true;
}
const client = new GraphQLClient("https://graphql.anilist.co/"); const client = new GraphQLClient("https://graphql.anilist.co/");
const headers = new Headers({ Authorization: `Bearer ${aniListToken}` }); const headers = new Headers({ Authorization: `Bearer ${aniListToken}` });

View File

@@ -22,8 +22,6 @@ vi.mock("~/mocks", () => ({
describe("requests the /watch-status route", () => { describe("requests the /watch-status route", () => {
const db = getTestDb(env); const db = getTestDb(env);
let app: typeof import("../../../src/index").app; let app: typeof import("../../../src/index").app;
let maybeUpdateWatchStatusOnAnilist: any;
let queueTask: any;
let maybeScheduleNextAiringEpisode: any; let maybeScheduleNextAiringEpisode: any;
let removeTask: any; let removeTask: any;
@@ -31,10 +29,6 @@ describe("requests the /watch-status route", () => {
await resetTestDb(db); await resetTestDb(db);
vi.resetModules(); vi.resetModules();
vi.doMock("./anilist", () => ({
maybeUpdateWatchStatusOnAnilist: vi.fn().mockResolvedValue(undefined),
}));
vi.doMock("~/libs/tasks/queueTask", () => ({ vi.doMock("~/libs/tasks/queueTask", () => ({
queueTask: vi.fn().mockResolvedValue(undefined), queueTask: vi.fn().mockResolvedValue(undefined),
})); }));
@@ -52,10 +46,6 @@ describe("requests the /watch-status route", () => {
})); }));
app = (await import("~/index")).app; app = (await import("~/index")).app;
maybeUpdateWatchStatusOnAnilist = (
await import("~/controllers/watch-status/anilist")
).maybeUpdateWatchStatusOnAnilist;
queueTask = (await import("~/libs/tasks/queueTask")).queueTask;
removeTask = (await import("~/libs/tasks/removeTask")).removeTask; removeTask = (await import("~/libs/tasks/removeTask")).removeTask;
maybeScheduleNextAiringEpisode = ( maybeScheduleNextAiringEpisode = (
await import("~/libs/maybeScheduleNextAiringEpisode") await import("~/libs/maybeScheduleNextAiringEpisode")
@@ -119,34 +109,6 @@ describe("requests the /watch-status route", () => {
expect(res.status).toBe(500); expect(res.status).toBe(500);
}); });
it("saving title, Anilist request fails, should succeed", async () => {
vi.mocked(maybeUpdateWatchStatusOnAnilist).mockRejectedValue(
new Error("Anilist failed"),
);
const res = await app.request(
"/watch-status",
{
method: "POST",
headers: new Headers({
"x-anilist-token": "asd",
"Content-Type": "application/json",
}),
body: JSON.stringify({
deviceId: "123",
watchStatus: "CURRENT",
titleId: -1,
}),
},
env,
);
await expect(res.json()).resolves.toEqual({ success: true });
expect(res.status).toBe(200);
// Should queue task if direct update fails
expect(queueTask).toHaveBeenCalled();
});
it("watch status is null, should succeed", async () => { it("watch status is null, should succeed", async () => {
const res = await app.request( const res = await app.request(
"/watch-status", "/watch-status",

View File

@@ -16,8 +16,6 @@ import {
} from "~/types/schema"; } from "~/types/schema";
import { WatchStatus } from "~/types/title/watchStatus"; import { WatchStatus } from "~/types/title/watchStatus";
import { maybeUpdateWatchStatusOnAnilist } from "./anilist";
const app = new OpenAPIHono<Cloudflare.Env>(); const app = new OpenAPIHono<Cloudflare.Env>();
const UpdateWatchStatusRequest = z.object({ const UpdateWatchStatusRequest = z.object({
@@ -109,19 +107,6 @@ app.openapi(route, async (c) => {
} }
} }
try {
await maybeUpdateWatchStatusOnAnilist(
Number(titleId),
watchStatus,
aniListToken,
);
} catch (error) {
console.error("Failed to update watch status on Anilist");
console.error(error);
if (isRetrying) {
return c.json(ErrorResponse, { status: 500 });
}
await queueTask( await queueTask(
"ANILIST_UPDATES", "ANILIST_UPDATES",
{ {
@@ -132,7 +117,6 @@ app.openapi(route, async (c) => {
}, },
{ req: c.req, scheduleConfig: { delay: { minute: 1 } } }, { req: c.req, scheduleConfig: { delay: { minute: 1 } } },
); );
}
return c.json(SuccessResponse, { status: 200 }); return c.json(SuccessResponse, { status: 200 });
}); });

View File

@@ -5,6 +5,7 @@ import { maybeUpdateLastConnectedAt } from "~/controllers/maybeUpdateLastConnect
import type { QueueName } from "~/libs/tasks/queueName.ts"; import type { QueueName } from "~/libs/tasks/queueName.ts";
import { onNewEpisode } from "./controllers/internal/new-episode"; import { onNewEpisode } from "./controllers/internal/new-episode";
import { AnilistUpdateType } from "./libs/anilist/updateType";
import type { QueueBody } from "./libs/tasks/queueTask"; import type { QueueBody } from "./libs/tasks/queueTask";
export const app = new OpenAPIHono<{ Bindings: Env }>(); export const app = new OpenAPIHono<{ Bindings: Env }>();
@@ -74,7 +75,30 @@ export default {
async queue(batch) { async queue(batch) {
switch (batch.queue as QueueName) { switch (batch.queue as QueueName) {
case "ANILIST_UPDATES": case "ANILIST_UPDATES":
batch.retryAll(); for (const message of (
batch as MessageBatch<QueueBody["ANILIST_UPDATES"]>
).messages) {
switch (message.body.updateType) {
case AnilistUpdateType.UpdateWatchStatus:
if (!message.body[AnilistUpdateType.UpdateWatchStatus]) {
throw new Error(
`Discarding update, unknown body ${JSON.stringify(message.body)}`,
);
}
const { updateWatchStatusOnAnilist } =
await import("~/controllers/watch-status/anilist");
const payload = message.body[AnilistUpdateType.UpdateWatchStatus];
await updateWatchStatusOnAnilist(
payload.titleId,
payload.watchStatus,
payload.aniListToken,
);
break;
}
message.ack();
}
break; break;
case "NEW_EPISODE": case "NEW_EPISODE":
for (const message of (batch as MessageBatch<QueueBody["NEW_EPISODE"]>) for (const message of (batch as MessageBatch<QueueBody["NEW_EPISODE"]>)
@@ -89,9 +113,8 @@ export default {
} }
}, },
async scheduled(event, env, ctx) { async scheduled(event, env, ctx) {
const { processDelayedTasks } = await import( const { processDelayedTasks } =
"~/libs/tasks/processDelayedTasks" await import("~/libs/tasks/processDelayedTasks");
);
await processDelayedTasks(env, ctx); await processDelayedTasks(env, ctx);
}, },
} satisfies ExportedHandler<Env>; } satisfies ExportedHandler<Env>;

View File

@@ -1,4 +1,3 @@
import type { TypedDocumentNode } from "@graphql-typed-document-node/core";
import { DurableObject } from "cloudflare:workers"; import { DurableObject } from "cloudflare:workers";
import { print } from "graphql"; import { print } from "graphql";
import { z } from "zod"; import { z } from "zod";

View File

@@ -8,7 +8,7 @@ export async function fetchTitleFromAnilist(
token?: string | undefined, token?: string | undefined,
): Promise<Title | undefined> { ): Promise<Title | undefined> {
if (useMockData()) { if (useMockData()) {
const { mockTitleDetails } = await import("~/mocks/mockData"); const { mockTitleDetails } = await import("~/mocks");
return mockTitleDetails(); return mockTitleDetails();
} }

View File

@@ -35,8 +35,8 @@ describe("queueTask - delayed task handling", () => {
(globalThis as any).crypto = { randomUUID: vi.fn(() => "test-uuid-123") }; (globalThis as any).crypto = { randomUUID: vi.fn(() => "test-uuid-123") };
}); });
describe("tasks with delay <= 12 hours", () => { describe("tasks with delay <= 9 hours", () => {
it("queues task directly when delay is less than 12 hours", async () => { it("queues task directly when delay is less than 9 hours", async () => {
await queueTask( await queueTask(
"NEW_EPISODE", "NEW_EPISODE",
{ aniListId: 123, episodeNumber: 1 }, { aniListId: 123, episodeNumber: 1 },
@@ -52,12 +52,12 @@ describe("queueTask - delayed task handling", () => {
expect(kvPutSpy).not.toHaveBeenCalled(); expect(kvPutSpy).not.toHaveBeenCalled();
}); });
it("queues task directly when delay is exactly 12 hours", async () => { it("queues task directly when delay is exactly 9 hours", async () => {
await queueTask( await queueTask(
"NEW_EPISODE", "NEW_EPISODE",
{ aniListId: 456, episodeNumber: 2 }, { aniListId: 456, episodeNumber: 2 },
{ {
scheduleConfig: { delay: { hours: 12 } }, scheduleConfig: { delay: { hours: 9 } },
env: mockEnv, env: mockEnv,
}, },
); );
@@ -81,8 +81,8 @@ describe("queueTask - delayed task handling", () => {
}); });
}); });
describe("tasks with delay > 12 hours", () => { describe("tasks with delay > 9 hours", () => {
it("stores task in KV when delay exceeds 12 hours", async () => { it("stores task in KV when delay exceeds 9 hours", async () => {
await queueTask( await queueTask(
"NEW_EPISODE", "NEW_EPISODE",
{ aniListId: 111, episodeNumber: 4 }, { aniListId: 111, episodeNumber: 4 },
@@ -98,12 +98,12 @@ describe("queueTask - delayed task handling", () => {
expect(queueSendSpy).not.toHaveBeenCalled(); expect(queueSendSpy).not.toHaveBeenCalled();
}); });
it("stores task in KV when delay is 12 hours + 1 second", async () => { it("stores task in KV when delay is 9 hours + 1 second", async () => {
await queueTask( await queueTask(
"NEW_EPISODE", "NEW_EPISODE",
{ aniListId: 222, episodeNumber: 5 }, { aniListId: 222, episodeNumber: 5 },
{ {
scheduleConfig: { delay: { hours: 12, seconds: 1 } }, scheduleConfig: { delay: { hours: 9, seconds: 1 } },
env: mockEnv, env: mockEnv,
}, },
); );
@@ -176,7 +176,7 @@ describe("queueTask - delayed task handling", () => {
}); });
describe("epoch time scheduling", () => { describe("epoch time scheduling", () => {
it("queues directly when epoch time is within 12 hours", async () => { it("queues directly when epoch time is within 9 hours", async () => {
const futureTime = Math.floor(Date.now() / 1000) + 3600; // 1 hour from now const futureTime = Math.floor(Date.now() / 1000) + 3600; // 1 hour from now
await queueTask( await queueTask(
@@ -192,7 +192,7 @@ describe("queueTask - delayed task handling", () => {
expect(kvPutSpy).not.toHaveBeenCalled(); expect(kvPutSpy).not.toHaveBeenCalled();
}); });
it("stores in KV when epoch time is beyond 12 hours", async () => { it("stores in KV when epoch time is beyond 9 hours", async () => {
const futureTime = Math.floor(Date.now() / 1000) + 24 * 3600; // 24 hours from now const futureTime = Math.floor(Date.now() / 1000) + 24 * 3600; // 24 hours from now
await queueTask( await queueTask(

View File

@@ -9,9 +9,11 @@ import type { QueueName } from "./queueName";
export type QueueBody = { export type QueueBody = {
ANILIST_UPDATES: { ANILIST_UPDATES: {
deviceId: string; [AnilistUpdateType.UpdateWatchStatus]: {
watchStatus: WatchStatus | null;
titleId: number; titleId: number;
watchStatus: WatchStatus | null;
aniListToken: string;
};
updateType: AnilistUpdateType; updateType: AnilistUpdateType;
}; };
NEW_EPISODE: { aniListId: number; episodeNumber: number }; NEW_EPISODE: { aniListId: number; episodeNumber: number };
@@ -40,17 +42,16 @@ export async function queueTask(
req?.header(), req?.header(),
); );
const MAX_DELAY_SECONDS = 12 * 60 * 60; // 43,200 seconds (12 hours) const MAX_DELAY_SECONDS = Duration.fromObject({ hours: 9 }).as("seconds");
// If delay exceeds 12 hours, store in KV for later processing // If delay exceeds 9 hours, store in KV for later processing
if (scheduleTime > MAX_DELAY_SECONDS) { if (scheduleTime > MAX_DELAY_SECONDS) {
if (!env || !env.DELAYED_TASKS) { if (!env || !env.DELAYED_TASKS) {
throw new Error("DELAYED_TASKS KV namespace not available"); throw new Error("DELAYED_TASKS KV namespace not available");
} }
const { generateTaskKey, serializeDelayedTask } = await import( const { generateTaskKey, serializeDelayedTask } =
"./delayedTask" await import("./delayedTask");
);
const taskId = crypto.randomUUID(); const taskId = crypto.randomUUID();
const scheduledEpochTime = Math.floor(Date.now() / 1000) + scheduleTime; const scheduledEpochTime = Math.floor(Date.now() / 1000) + scheduleTime;

View File

@@ -1,29 +0,0 @@
// import { GraphQLClient } from "graphql-request";
import { HttpsProxyAgent } from "https-proxy-agent";
import nodeFetch from "node-fetch";
// import { GetTitleQuery } from "../libs/anilist/getTitle.ts";
const agent = new HttpsProxyAgent(
"http://ruru:pdh!CQB@kpc3vyb3cwc@45.56.108.251:3128",
);
const response = await nodeFetch("https://httpbin.org/ip", { agent });
console.log(await response.text());
console.log(response.status);
console.log(nodeFetch);
// const client = new GraphQLClient("https://graphql.anilist.co/", {
// fetch: (input, init) => {
// console.log("custom fetch");
// const agent = new HttpsProxyAgent(
// "http://ruru:pdh!CQB@kpc3vyb3cwc@45.56.108.251:3128",
// );
// return nodeFetch(input, { ...init, agent });
// },
// });
// console.log(
// await client
// .request(GetTitleQuery, { id: 186794 })
// .then((data) => data?.Media ?? undefined),
// );