changed some files to ts

This commit is contained in:
2025-11-29 17:41:30 +01:00
parent 91526e1755
commit 655ab9c987
13 changed files with 624 additions and 168 deletions

View File

@@ -1,47 +1,48 @@
const fs = require('fs');
const path = require('path');
import { FastifyInstance, FastifyRequest, FastifyReply } from 'fastify';
import * as fs from 'fs';
import * as path from 'path';
async function viewsRoutes(fastify, options) {
async function viewsRoutes(fastify: FastifyInstance) {
fastify.get('/', (req, reply) => {
fastify.get('/', (req: FastifyRequest, reply: FastifyReply) => {
const stream = fs.createReadStream(path.join(__dirname, '..', '..', 'views', 'index.html'));
reply.type('text/html').send(stream);
});
fastify.get('/books', (req, reply) => {
fastify.get('/books', (req: FastifyRequest, reply: FastifyReply) => {
const stream = fs.createReadStream(path.join(__dirname, '..', '..', 'views', 'books.html'));
reply.type('text/html').send(stream);
});
fastify.get('/anime/:id', (req, reply) => {
fastify.get('/anime/:id', (req: FastifyRequest, reply: FastifyReply) => {
const stream = fs.createReadStream(path.join(__dirname, '..', '..', 'views', 'anime.html'));
reply.type('text/html').send(stream);
});
fastify.get('/anime/:extension/*', (req, reply) => {
fastify.get('/anime/:extension/*', (req: FastifyRequest, reply: FastifyReply) => {
const stream = fs.createReadStream(path.join(__dirname, '..', '..', 'views', 'anime.html'));
reply.type('text/html').send(stream);
});
fastify.get('/watch/:id/:episode', (req, reply) => {
fastify.get('/watch/:id/:episode', (req: FastifyRequest, reply: FastifyReply) => {
const stream = fs.createReadStream(path.join(__dirname, '..', '..', 'views', 'watch.html'));
reply.type('text/html').send(stream);
});
fastify.get('/book/:id', (req, reply) => {
fastify.get('/book/:id', (req: FastifyRequest, reply: FastifyReply) => {
const stream = fs.createReadStream(path.join(__dirname, '..', '..', 'views', 'book.html'));
reply.type('text/html').send(stream);
});
fastify.get('/book/:extension/*', (req, reply) => {
fastify.get('/book/:extension/*', (req: FastifyRequest, reply: FastifyReply) => {
const stream = fs.createReadStream(path.join(__dirname, '..', '..', 'views', 'book.html'));
reply.type('text/html').send(stream);
});
fastify.get('/read/:provider/:chapter/*', (req, reply) => {
fastify.get('/read/:provider/:chapter/*', (req: FastifyRequest, reply: FastifyReply) => {
const stream = fs.createReadStream(path.join(__dirname, '..', '..', 'views', 'read.html'));
reply.type('text/html').send(stream);
});
}
module.exports = viewsRoutes;
export default viewsRoutes;