organisation & minor fixes
This commit is contained in:
37
src/api/extensions/extensions.controller.ts
Normal file
37
src/api/extensions/extensions.controller.ts
Normal file
@@ -0,0 +1,37 @@
|
||||
import { FastifyReply, FastifyRequest } from 'fastify';
|
||||
import { getExtension, getExtensionsList, getGalleryExtensionsMap, getBookExtensionsMap, getAnimeExtensionsMap } from '../../shared/extensions';
|
||||
import { ExtensionNameRequest } from '../types';
|
||||
|
||||
export async function getExtensions(req: FastifyRequest, reply: FastifyReply) {
|
||||
return { extensions: getExtensionsList() };
|
||||
}
|
||||
|
||||
export async function getAnimeExtensions(req: FastifyRequest, reply: FastifyReply) {
|
||||
const animeExtensions = getAnimeExtensionsMap();
|
||||
return { extensions: Array.from(animeExtensions.keys()) };
|
||||
}
|
||||
|
||||
export async function getBookExtensions(req: FastifyRequest, reply: FastifyReply) {
|
||||
const bookExtensions = getBookExtensionsMap();
|
||||
return { extensions: Array.from(bookExtensions.keys()) };
|
||||
}
|
||||
|
||||
export async function getGalleryExtensions(req: FastifyRequest, reply: FastifyReply) {
|
||||
const galleryExtensions = getGalleryExtensionsMap();
|
||||
return { extensions: Array.from(galleryExtensions.keys()) };
|
||||
}
|
||||
|
||||
export async function getExtensionSettings(req: ExtensionNameRequest, reply: FastifyReply) {
|
||||
const { name } = req.params;
|
||||
const ext = getExtension(name);
|
||||
|
||||
if (!ext) {
|
||||
return { error: "Extension not found" };
|
||||
}
|
||||
|
||||
if (!ext.getSettings) {
|
||||
return { episodeServers: ["default"], supportsDub: false };
|
||||
}
|
||||
|
||||
return ext.getSettings();
|
||||
}
|
||||
Reference in New Issue
Block a user