Skip to content

Commit efe51f9

Browse files
authored
Fix Deduplication Issues, Add Two More Special DB Endpoints (#793)
1 parent 243027d commit efe51f9

22 files changed

+522
-2172
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
root = true
22

33
[*] # all files
4-
indent_style = space
4+
indent_style = tab
55
indent_size = 2
66
end_of_line = lf
77
insert_final_newline = true

Dockerfile

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ ENV CI=1
2828
# Install dependencies
2929
RUN pnpm install --frozen-lockfile
3030

31-
RUN pnpm --silent run docs
31+
RUN pnpm run docs
3232

3333
FROM node:20-alpine
3434

docs/openapi.yaml

+76-35
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ openapi: 3.1.0
33
info:
44
version: 2.1.0
55
title: API Docs - arm-server
6+
license:
7+
name: GNU Affero General Public License v3.0 only
8+
identifier: AGPL-3.0-only
69
contact:
710
name: BeeeQueue
811
url: https://github.com/BeeeQueue/arm-server
@@ -24,11 +27,11 @@ tags:
2427
description: |
2528
`v2` adds more Sources thanks to [Fribb/anime-lists](https://github.com/Fribb/anime-lists).
2629
27-
Unfortunately TheTVDB uses one entry per **show** instead of **season** meaning its IDs become one-to-many mappings.
28-
29-
This meant it cannot be queried for in `/api/v2/ids` since it's impossible for the API to look the same in that case.
30-
31-
Instead I added `/api/v2/thetvdb` if you _really_ want to query by their IDs.
30+
Unfortunately IMDB, TheMovieDB, and TheTVDB use one entry per **show** instead of **season** meaning their IDs become one-to-many mappings.
31+
32+
This means it cannot be queried for in `/api/v2/ids` since it's impossible for the API to look the same in that case.
33+
34+
Instead I added `/api/v2/imdb`, `/api/v2/themoviedb`, and `/api/v2/thetvdb` if you want to query by their IDs.
3235
- name: v1
3336

3437
$defs:
@@ -57,7 +60,7 @@ $defs:
5760
example: Bad request
5861
message:
5962
type: string
60-
example: body/1/anilist must be >= 0
63+
example: "1: Number must be greater than or equal to 1, Number must be greater than 0"
6164

6265
relation:
6366
type: object
@@ -211,7 +214,7 @@ paths:
211214
get:
212215
operationId: getIds
213216
summary: Fetch IDs via query parameters
214-
217+
security: [{}]
215218
tags:
216219
- v1
217220

@@ -254,6 +257,7 @@ paths:
254257
If using array queries, the resulting array will map to the corresponding input!
255258
256259
e.g. `body[1]` will be the result of `query[1]`.
260+
security: [{}]
257261
tags:
258262
- v1
259263

@@ -286,6 +290,7 @@ paths:
286290
operationId: v2-getIds
287291
summary: Fetch IDs via query parameters
288292
description: ' '
293+
security: [{}]
289294
tags:
290295
- v2
291296

@@ -301,10 +306,8 @@ paths:
301306
- anidb
302307
- anime-planet
303308
- anisearch
304-
- imdb
305309
- kitsu
306310
- livechart
307-
- themoviedb
308311
- notify-moe
309312
- myanimelist
310313
- name: id
@@ -338,6 +341,7 @@ paths:
338341
If using array queries, the resulting array will map to the corresponding input!
339342
340343
e.g. `body[1]` will be the result of `query[1]`.
344+
security: [{}]
341345
tags:
342346
- v2
343347

@@ -382,13 +386,6 @@ paths:
382386
- type: integer
383387
minimum: 0
384388
maximum: 50000000
385-
imdb:
386-
oneOf:
387-
- type: 'null'
388-
- type: string
389-
pattern: tt\d+
390-
minLength: 1
391-
maxLength: 50
392389
kitsu:
393390
oneOf:
394391
- type: 'null'
@@ -407,12 +404,6 @@ paths:
407404
- type: string
408405
minLength: 1
409406
maxLength: 50
410-
themoviedb:
411-
oneOf:
412-
- type: 'null'
413-
- type: integer
414-
minimum: 0
415-
maximum: 50000000
416407
myanimelist:
417408
oneOf:
418409
- type: 'null'
@@ -451,13 +442,6 @@ paths:
451442
- type: integer
452443
minimum: 0
453444
maximum: 50000000
454-
imdb:
455-
oneOf:
456-
- type: 'null'
457-
- type: string
458-
pattern: tt\d+
459-
minLength: 1
460-
maxLength: 50
461445
kitsu:
462446
oneOf:
463447
- type: 'null'
@@ -476,12 +460,6 @@ paths:
476460
- type: string
477461
minLength: 1
478462
maxLength: 50
479-
themoviedb:
480-
oneOf:
481-
- type: 'null'
482-
- type: integer
483-
minimum: 0
484-
maximum: 50000000
485463
myanimelist:
486464
oneOf:
487465
- type: 'null'
@@ -499,11 +477,74 @@ paths:
499477
'400':
500478
$ref: '#/$defs/400'
501479

480+
/api/v2/imdb:
481+
get:
482+
operationId: v2-imdb
483+
summary: Fetch IDs by IMDB ID
484+
description: ' '
485+
security: [{}]
486+
tags:
487+
- v2
488+
489+
parameters:
490+
- name: id
491+
in: query
492+
required: true
493+
example: tt5370118
494+
schema:
495+
type: integer
496+
minimum: 1
497+
- $ref: "#/$defs/include_param"
498+
499+
responses:
500+
'200':
501+
description: OK
502+
content:
503+
application/json:
504+
schema:
505+
type: array
506+
items:
507+
$ref: '#/$defs/nullable_relation'
508+
'400':
509+
$ref: '#/$defs/400'
510+
511+
/api/v2/themoviedb:
512+
get:
513+
operationId: v2-themoviedb
514+
summary: Fetch IDs by TheMovieDB ID
515+
description: ' '
516+
security: [{}]
517+
tags:
518+
- v2
519+
520+
parameters:
521+
- name: id
522+
in: query
523+
required: true
524+
example: 1337
525+
schema:
526+
type: integer
527+
minimum: 1
528+
- $ref: "#/$defs/include_param"
529+
530+
responses:
531+
'200':
532+
description: OK
533+
content:
534+
application/json:
535+
schema:
536+
type: array
537+
items:
538+
$ref: '#/$defs/nullable_relation'
539+
'400':
540+
$ref: '#/$defs/400'
541+
502542
/api/v2/thetvdb:
503543
get:
504544
operationId: v2-thetvdb
505545
summary: Fetch IDs by TheTVDB ID
506546
description: ' '
547+
security: [{}]
507548
tags:
508549
- v2
509550

+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/** @param knex {import("knex").Knex} */
2+
export async function up(knex) {
3+
await knex.schema.alterTable("relations", (table) => {
4+
table.dropUnique("imdb")
5+
table.dropUnique("themoviedb")
6+
})
7+
}
8+
9+
/** @param knex {import("knex").Knex} */
10+
export async function down(knex) {
11+
await knex.schema.alterTable("relations", (table) => {
12+
table.unique("imdb")
13+
table.unique("themoviedb")
14+
})
15+
}

package.json

+2-7
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
},
1919
"scripts": {
2020
"dev": "onchange --initial --kill 'src/**' pnpm-lock.yaml -- pnpm --silent start",
21-
"docs": "redoc-cli build docs/openapi.yaml",
21+
"docs": "pnpm --package=@redocly/cli dlx redocly build-docs docs/openapi.yaml",
2222
"docs:dev": "onchange --initial --kill docs/openapi.yaml -- pnpm --silent docs",
2323
"docker:build": "docker build . --tag arm-server",
2424
"docker:start": "pnpm --silent docker:build; pnpm --silent docker:run",
@@ -59,22 +59,17 @@
5959
"@types/json-schema": "7.0.15",
6060
"@types/node": "20.14.2",
6161
"@vitest/coverage-v8": "1.6.0",
62-
"ajv": "8.16.0",
6362
"dotenv": "16.4.5",
6463
"eslint": "8.57.0",
6564
"lint-staged": "15.2.7",
6665
"onchange": "7.1.0",
67-
"redoc-cli": "0.13.21",
6866
"simple-git-hooks": "2.11.1",
6967
"tsconfig-paths": "4.2.0",
7068
"vitest": "1.6.0"
7169
},
7270
"pnpm": {
7371
"overrides": {
74-
"assert": "npm:@nolyfill/assert@latest",
75-
"hasown": "npm:@nolyfill/hasown@latest",
76-
"isarray": "npm:@nolyfill/isarray@latest",
77-
"side-channel": "npm:@nolyfill/side-channel@latest"
72+
"hasown": "npm:@nolyfill/hasown@latest"
7873
}
7974
}
8075
}

0 commit comments

Comments
 (0)