Implement very basic search

This commit is contained in:
2025-06-20 00:28:05 +05:00
parent 0bf60ad783
commit 2ca6a63e39
8 changed files with 1320 additions and 191 deletions

365
openapi/search.json Normal file
View File

@ -0,0 +1,365 @@
{
"openapi": "3.1.0",
"info": {
"title": "OpenAPI definition",
"version": "v0"
},
"servers": [
{
"url": "http://localhost:8080",
"description": "Generated server url"
}
],
"paths": {
"/search": {
"get": {
"tags": [
"search-controller"
],
"operationId": "search",
"parameters": [
{
"name": "title",
"in": "query",
"required": true,
"schema": {
"type": "string"
}
}
],
"responses": {
"200": {
"description": "OK",
"content": {
"*/*": {
"schema": {
"$ref": "#/components/schemas/KodikResponse"
}
}
}
}
}
}
}
},
"components": {
"schemas": {
"KodikResponse": {
"type": "object",
"properties": {
"total": {
"type": "integer",
"format": "int32"
},
"results": {
"type": "array",
"items": {
"$ref": "#/components/schemas/Result"
}
}
}
},
"MaterialData": {
"type": "object",
"properties": {
"title": {
"type": "string"
},
"year": {
"type": "integer",
"format": "int32"
},
"description": {
"type": "string"
},
"screenshots": {
"type": "array",
"items": {
"type": "string"
}
},
"duration": {
"type": "integer",
"format": "int32"
},
"countries": {
"type": "array",
"items": {
"type": "string"
}
},
"genres": {
"type": "array",
"items": {
"type": "string"
}
},
"actors": {
"type": "array",
"items": {
"type": "string"
}
},
"directors": {
"type": "array",
"items": {
"type": "string"
}
},
"producers": {
"type": "array",
"items": {
"type": "string"
}
},
"writers": {
"type": "array",
"items": {
"type": "string"
}
},
"composers": {
"type": "array",
"items": {
"type": "string"
}
},
"editors": {
"type": "array",
"items": {
"type": "string"
}
},
"designers": {
"type": "array",
"items": {
"type": "string"
}
},
"operators": {
"type": "array",
"items": {
"type": "string"
}
},
"anime_title": {
"type": "string"
},
"title_en": {
"type": "string"
},
"other_titles": {
"type": "array",
"items": {
"type": "string"
}
},
"other_titles_en": {
"type": "array",
"items": {
"type": "string"
}
},
"other_titles_jp": {
"type": "array",
"items": {
"type": "string"
}
},
"anime_license_name": {
"type": "string"
},
"anime_licensed_by": {
"type": "array",
"items": {
"type": "string"
}
},
"anime_kind": {
"type": "string"
},
"all_status": {
"type": "string"
},
"anime_status": {
"type": "string"
},
"anime_description": {
"type": "string"
},
"poster_url": {
"type": "string"
},
"anime_poster_url": {
"type": "string"
},
"all_genres": {
"type": "array",
"items": {
"type": "string"
}
},
"anime_genres": {
"type": "array",
"items": {
"type": "string"
}
},
"anime_studios": {
"type": "array",
"items": {
"type": "string"
}
},
"kinopoisk_rating": {
"type": "number",
"format": "double"
},
"kinopoisk_votes": {
"type": "integer",
"format": "int32"
},
"imdb_rating": {
"type": "number",
"format": "double"
},
"imdb_votes": {
"type": "integer",
"format": "int32"
},
"shikimori_rating": {
"type": "number",
"format": "double"
},
"shikimori_votes": {
"type": "integer",
"format": "int32"
},
"premiere_world": {
"type": "string"
},
"aired_at": {
"type": "string"
},
"released_at": {
"type": "string"
},
"rating_mpaa": {
"type": "string"
},
"minimal_age": {
"type": "integer",
"format": "int32"
},
"episodes_total": {
"type": "integer",
"format": "int32"
},
"episodes_aired": {
"type": "integer",
"format": "int32"
}
}
},
"Result": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string"
},
"link": {
"type": "string"
},
"title": {
"type": "string"
},
"translation": {
"$ref": "#/components/schemas/Translation"
},
"year": {
"type": "integer",
"format": "int32"
},
"quality": {
"type": "string"
},
"camrip": {
"type": "boolean"
},
"lgbt": {
"type": "boolean"
},
"screenshots": {
"type": "array",
"items": {
"type": "string"
}
},
"title_orig": {
"type": "string"
},
"other_title": {
"type": "string"
},
"last_season": {
"type": "integer",
"format": "int32"
},
"last_episode": {
"type": "integer",
"format": "int32"
},
"episodes_count": {
"type": "integer",
"format": "int32"
},
"kinopoisk_id": {
"type": "string"
},
"imdb_id": {
"type": "string"
},
"worldart_link": {
"type": "string"
},
"shikimori_id": {
"type": "string"
},
"blocked_countries": {
"type": "array",
"items": {
"type": "string"
}
},
"created_at": {
"type": "string"
},
"updated_at": {
"type": "string"
},
"material_data": {
"$ref": "#/components/schemas/MaterialData"
}
}
},
"Translation": {
"type": "object",
"properties": {
"id": {
"type": "integer",
"format": "int32"
},
"title": {
"type": "string"
},
"type": {
"type": "string"
}
}
}
}
}
}

111
openapi/search.ts Normal file
View File

@ -0,0 +1,111 @@
/**
* Generated by orval v7.10.0 🍺
* Do not edit manually.
* OpenAPI definition
* OpenAPI spec version: v0
*/
import axios from 'axios';
import type {
AxiosRequestConfig,
AxiosResponse
} from 'axios';
export interface KodikResponse {
total?: number;
results?: Result[];
}
export interface MaterialData {
title?: string;
year?: number;
description?: string;
screenshots?: string[];
duration?: number;
countries?: string[];
genres?: string[];
actors?: string[];
directors?: string[];
producers?: string[];
writers?: string[];
composers?: string[];
editors?: string[];
designers?: string[];
operators?: string[];
anime_title?: string;
title_en?: string;
other_titles?: string[];
other_titles_en?: string[];
other_titles_jp?: string[];
anime_license_name?: string;
anime_licensed_by?: string[];
anime_kind?: string;
all_status?: string;
anime_status?: string;
anime_description?: string;
poster_url?: string;
anime_poster_url?: string;
all_genres?: string[];
anime_genres?: string[];
anime_studios?: string[];
kinopoisk_rating?: number;
kinopoisk_votes?: number;
imdb_rating?: number;
imdb_votes?: number;
shikimori_rating?: number;
shikimori_votes?: number;
premiere_world?: string;
aired_at?: string;
released_at?: string;
rating_mpaa?: string;
minimal_age?: number;
episodes_total?: number;
episodes_aired?: number;
}
export interface Result {
id?: string;
type?: string;
link?: string;
title?: string;
translation?: Translation;
year?: number;
quality?: string;
camrip?: boolean;
lgbt?: boolean;
screenshots?: string[];
title_orig?: string;
other_title?: string;
last_season?: number;
last_episode?: number;
episodes_count?: number;
kinopoisk_id?: string;
imdb_id?: string;
worldart_link?: string;
shikimori_id?: string;
blocked_countries?: string[];
created_at?: string;
updated_at?: string;
material_data?: MaterialData;
}
export interface Translation {
id?: number;
title?: string;
type?: string;
}
export type SearchParams = {
title: string;
};
export const search = <TData = AxiosResponse<KodikResponse>>(
params: SearchParams, options?: AxiosRequestConfig
): Promise<TData> => {
return axios.get(
`http://localhost:8080/search`,{
...options,
params: {...params, ...options?.params},}
);
}
export type SearchResult = AxiosResponse<KodikResponse>