Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Deduplication Issues, Add Two More Special DB Endpoints #793

Merged
merged 13 commits into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
root = true

[*] # all files
indent_style = space
indent_style = tab
indent_size = 2
end_of_line = lf
insert_final_newline = true
Expand Down
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ ENV CI=1
# Install dependencies
RUN pnpm install --frozen-lockfile

RUN pnpm --silent run docs
RUN pnpm run docs

FROM node:20-alpine

Expand Down
111 changes: 76 additions & 35 deletions docs/openapi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ openapi: 3.1.0
info:
version: 2.1.0
title: API Docs - arm-server
license:
name: GNU Affero General Public License v3.0 only
identifier: AGPL-3.0-only
contact:
name: BeeeQueue
url: https://github.com/BeeeQueue/arm-server
Expand All @@ -24,11 +27,11 @@ tags:
description: |
`v2` adds more Sources thanks to [Fribb/anime-lists](https://github.com/Fribb/anime-lists).

Unfortunately TheTVDB uses one entry per **show** instead of **season** meaning its IDs become one-to-many mappings.
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.
Instead I added `/api/v2/thetvdb` if you _really_ want to query by their IDs.
Unfortunately IMDB, TheMovieDB, and TheTVDB use one entry per **show** instead of **season** meaning their IDs become one-to-many mappings.

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.

Instead I added `/api/v2/imdb`, `/api/v2/themoviedb`, and `/api/v2/thetvdb` if you want to query by their IDs.
- name: v1

$defs:
Expand Down Expand Up @@ -57,7 +60,7 @@ $defs:
example: Bad request
message:
type: string
example: body/1/anilist must be >= 0
example: "1: Number must be greater than or equal to 1, Number must be greater than 0"

relation:
type: object
Expand Down Expand Up @@ -211,7 +214,7 @@ paths:
get:
operationId: getIds
summary: Fetch IDs via query parameters

security: [{}]
tags:
- v1

Expand Down Expand Up @@ -254,6 +257,7 @@ paths:
If using array queries, the resulting array will map to the corresponding input!

e.g. `body[1]` will be the result of `query[1]`.
security: [{}]
tags:
- v1

Expand Down Expand Up @@ -286,6 +290,7 @@ paths:
operationId: v2-getIds
summary: Fetch IDs via query parameters
description: ' '
security: [{}]
tags:
- v2

Expand All @@ -301,10 +306,8 @@ paths:
- anidb
- anime-planet
- anisearch
- imdb
- kitsu
- livechart
- themoviedb
- notify-moe
- myanimelist
- name: id
Expand Down Expand Up @@ -338,6 +341,7 @@ paths:
If using array queries, the resulting array will map to the corresponding input!

e.g. `body[1]` will be the result of `query[1]`.
security: [{}]
tags:
- v2

Expand Down Expand Up @@ -382,13 +386,6 @@ paths:
- type: integer
minimum: 0
maximum: 50000000
imdb:
oneOf:
- type: 'null'
- type: string
pattern: tt\d+
minLength: 1
maxLength: 50
kitsu:
oneOf:
- type: 'null'
Expand All @@ -407,12 +404,6 @@ paths:
- type: string
minLength: 1
maxLength: 50
themoviedb:
oneOf:
- type: 'null'
- type: integer
minimum: 0
maximum: 50000000
myanimelist:
oneOf:
- type: 'null'
Expand Down Expand Up @@ -451,13 +442,6 @@ paths:
- type: integer
minimum: 0
maximum: 50000000
imdb:
oneOf:
- type: 'null'
- type: string
pattern: tt\d+
minLength: 1
maxLength: 50
kitsu:
oneOf:
- type: 'null'
Expand All @@ -476,12 +460,6 @@ paths:
- type: string
minLength: 1
maxLength: 50
themoviedb:
oneOf:
- type: 'null'
- type: integer
minimum: 0
maximum: 50000000
myanimelist:
oneOf:
- type: 'null'
Expand All @@ -499,11 +477,74 @@ paths:
'400':
$ref: '#/$defs/400'

/api/v2/imdb:
get:
operationId: v2-imdb
summary: Fetch IDs by IMDB ID
description: ' '
security: [{}]
tags:
- v2

parameters:
- name: id
in: query
required: true
example: tt5370118
schema:
type: integer
minimum: 1
- $ref: "#/$defs/include_param"

responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/$defs/nullable_relation'
'400':
$ref: '#/$defs/400'

/api/v2/themoviedb:
get:
operationId: v2-themoviedb
summary: Fetch IDs by TheMovieDB ID
description: ' '
security: [{}]
tags:
- v2

parameters:
- name: id
in: query
required: true
example: 1337
schema:
type: integer
minimum: 1
- $ref: "#/$defs/include_param"

responses:
'200':
description: OK
content:
application/json:
schema:
type: array
items:
$ref: '#/$defs/nullable_relation'
'400':
$ref: '#/$defs/400'

/api/v2/thetvdb:
get:
operationId: v2-thetvdb
summary: Fetch IDs by TheTVDB ID
description: ' '
security: [{}]
tags:
- v2

Expand Down
15 changes: 15 additions & 0 deletions migrations/20240617000000_special_dbs.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/** @param knex {import("knex").Knex} */
export async function up(knex) {
await knex.schema.alterTable("relations", (table) => {
table.dropUnique("imdb")
table.dropUnique("themoviedb")
})
}

/** @param knex {import("knex").Knex} */
export async function down(knex) {
await knex.schema.alterTable("relations", (table) => {
table.unique("imdb")
table.unique("themoviedb")
})
}
9 changes: 2 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"scripts": {
"dev": "onchange --initial --kill 'src/**' pnpm-lock.yaml -- pnpm --silent start",
"docs": "redoc-cli build docs/openapi.yaml",
"docs": "pnpm --package=@redocly/cli dlx redocly build-docs docs/openapi.yaml",
"docs:dev": "onchange --initial --kill docs/openapi.yaml -- pnpm --silent docs",
"docker:build": "docker build . --tag arm-server",
"docker:start": "pnpm --silent docker:build; pnpm --silent docker:run",
Expand Down Expand Up @@ -59,22 +59,17 @@
"@types/json-schema": "7.0.15",
"@types/node": "20.14.2",
"@vitest/coverage-v8": "1.6.0",
"ajv": "8.16.0",
"dotenv": "16.4.5",
"eslint": "8.57.0",
"lint-staged": "15.2.7",
"onchange": "7.1.0",
"redoc-cli": "0.13.21",
"simple-git-hooks": "2.11.1",
"tsconfig-paths": "4.2.0",
"vitest": "1.6.0"
},
"pnpm": {
"overrides": {
"assert": "npm:@nolyfill/assert@latest",
"hasown": "npm:@nolyfill/hasown@latest",
"isarray": "npm:@nolyfill/isarray@latest",
"side-channel": "npm:@nolyfill/side-channel@latest"
"hasown": "npm:@nolyfill/hasown@latest"
}
}
}
Loading
Loading