Skip to content

Commit 5455f99

Browse files
authored
Revert "Merge pull request #711 from 2004durgesh/main" (#714)
This reverts commit 60eeb49.
1 parent 60eeb49 commit 5455f99

34 files changed

+152
-344
lines changed

package.json

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"version": "1.0.0",
44
"main": "src/main.ts",
55
"scripts": {
6-
"start": "tsx src/main.ts",
7-
"dev": "tsx --watch src/main.ts",
6+
"start": "ts-node src/main.ts",
7+
"dev": "nodemon src/main.ts",
88
"build": "tsc",
99
"lint": "prettier --write \"src/**/*.ts\""
1010
},
@@ -25,24 +25,21 @@
2525
"dependencies": {
2626
"@consumet/extensions": "github:consumet/consumet.ts",
2727
"@fastify/cors": "^8.5.0",
28+
"@types/node": "^18.11.17",
29+
"@types/ws": "^8.5.3",
2830
"axios": "^1.0.0",
29-
"chalk": "^5.6.2",
31+
"chalk": "4.1.2",
3032
"cheerio": "1.0.0-rc.12",
3133
"dotenv": "^16.0.3",
3234
"fastify": "^4.10.2",
3335
"ioredis": "^5.2.4",
3436
"reconnecting-websocket": "^4.4.0",
37+
"ts-node": "^10.9.1",
3538
"ws": "^8.8.1"
3639
},
3740
"devDependencies": {
38-
"@fastify/swagger": "^8.14.0",
39-
"@scalar/fastify-api-reference": "^1.40.1",
40-
"@types/chalk": "^0.4.31",
41-
"@types/node": "^18.11.17",
42-
"@types/ws": "^8.5.3",
41+
"nodemon": "3.0.1",
4342
"prettier": "^3.0.0",
44-
"ts-node": "^10.9.1",
45-
"tsx": "^4.21.0",
4643
"typescript": "5.3.3"
4744
}
4845
}

src/main.ts

Lines changed: 2 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import lightnovels from './routes/light-novels';
1212
import movies from './routes/movies';
1313
import meta from './routes/meta';
1414
import news from './routes/news';
15+
import chalk from 'chalk';
1516
import Utils from './utils';
1617

1718
export const redis =
@@ -32,67 +33,12 @@ const fastify = Fastify({
3233
export const tmdbApi = process.env.TMDB_KEY && process.env.TMDB_KEY;
3334
(async () => {
3435
const PORT = Number(process.env.PORT) || 3000;
35-
36-
// The current file is a CommonJS module, so we use dynamic import to load ESM modules
37-
const chalk = await import('chalk').then((mod) => mod.default);
36+
3837
await fastify.register(FastifyCors, {
3938
origin: '*',
4039
methods: 'GET',
4140
});
4241

43-
// Only register Swagger and docs in development
44-
if (process.env.NODE_ENV !== 'production') {
45-
await fastify.register((await import('@fastify/swagger')).default, {
46-
openapi: {
47-
info: {
48-
title: 'Consumet API',
49-
description: 'A REST API for fetching data from various entertainment sources.',
50-
version: '1.0.0',
51-
},
52-
servers: [
53-
{
54-
url: `http://localhost:${PORT}`,
55-
description: 'Local server',
56-
},
57-
],
58-
'x-tagGroups': [
59-
{
60-
name: 'Anime',
61-
tags: [
62-
'hianime',
63-
'animekai',
64-
'animepahe',
65-
'animesaturn',
66-
'animeunity',
67-
'kickassanime',
68-
],
69-
},
70-
{ name: 'Movies', tags: ['flixhq', 'dramacool', 'goku', 'sflix', 'himovies'] },
71-
{ name: 'Manga', tags: ['mangadex', 'mangahere', 'mangapill', 'mangareader'] },
72-
{ name: 'Meta', tags: ['anilist', 'anilist-manga', 'mal', 'tmdb'] },
73-
// { name: 'Books', tags: ['books'] },
74-
// { name: 'Comics', tags: ['getcomics'] },
75-
// { name: 'Light Novels', tags: ['light-novels'] },
76-
{ name: 'News', tags: ['ann'] },
77-
],
78-
} as any,
79-
});
80-
81-
await fastify.register((await import('@scalar/fastify-api-reference')).default, {
82-
routePrefix: '/docs',
83-
configuration: {
84-
title: 'Consumet API Documentation',
85-
theme: 'bluePlanet',
86-
defaultOpenAllTags: false,
87-
hideModels: true,
88-
tagsSorter: 'alpha',
89-
sidebar: {
90-
showOperations: true,
91-
},
92-
} as any,
93-
});
94-
}
95-
9642
if (process.env.NODE_ENV === 'DEMO') {
9743
console.log(chalk.yellowBright('DEMO MODE ENABLED'));
9844

src/routes/anime/animekai.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ import { Redis } from 'ioredis';
99
const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
1010
const animekai = new ANIME.AnimeKai();
1111

12-
fastify.addHook('onRoute', (routeOptions) => {
13-
routeOptions.schema = routeOptions.schema || {};
14-
routeOptions.schema.tags = ['animekai'];
15-
});
16-
1712
fastify.get('/', (_, rp) => {
1813
rp.status(200).send({
1914
intro: `Welcome to the animekai provider: check out the provider's website @ ${animekai.toString.baseUrl}`,

src/routes/anime/animepahe.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ import { Redis } from 'ioredis';
88
const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
99
const animepahe = new ANIME.AnimePahe();
1010

11-
fastify.addHook('onRoute', (routeOptions) => {
12-
routeOptions.schema = routeOptions.schema || {};
13-
routeOptions.schema.tags = ['animepahe'];
14-
});
15-
1611
fastify.get('/', (_, rp) => {
1712
rp.status(200).send({
1813
intro: `Welcome to the animepahe provider: check out the provider's website @ ${animepahe.toString.baseUrl}`,

src/routes/anime/animesaturn.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,6 @@ import cache from '../../utils/cache';
77
const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
88
const animesaturn = new ANIME.AnimeSaturn();
99

10-
fastify.addHook('onRoute', (routeOptions) => {
11-
routeOptions.schema = routeOptions.schema || {};
12-
routeOptions.schema.tags = ['animesaturn'];
13-
});
14-
1510
fastify.get('/', (_, rp) => {
1611
rp.status(200).send({
1712
intro:

src/routes/anime/animeunity.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,6 @@ import { Redis } from 'ioredis';
88
const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
99
const animeunity = new ANIME.AnimeUnity();
1010

11-
fastify.addHook('onRoute', (routeOptions) => {
12-
routeOptions.schema = routeOptions.schema || {};
13-
routeOptions.schema.tags = ['animeunity'];
14-
});
15-
1611
fastify.get('/', (_, rp) => {
1712
rp.status(200).send({
1813
intro: `Welcome to the animeunity provider: check out the provider's website @ ${animeunity.toString.baseUrl}`,

src/routes/anime/hianime.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ import { Redis } from 'ioredis';
99
const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
1010
const hianime = new ANIME.Hianime();
1111

12-
fastify.addHook('onRoute', (routeOptions) => {
13-
routeOptions.schema = routeOptions.schema || {};
14-
routeOptions.schema.tags = ['hianime'];
15-
});
16-
1712
fastify.get('/', (_, rp) => {
1813
rp.status(200).send({
1914
intro: `Welcome to the hianime provider: check out the provider's website @ ${hianime.toString.baseUrl}`,

src/routes/anime/index.ts

Lines changed: 30 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -16,44 +16,40 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
1616
await fastify.register(animesaturn, { prefix: '/animesaturn' });
1717
await fastify.register(kickassanime, { prefix: '/kickassanime' });
1818

19-
fastify.get('/', { schema: { hide: true } }, async (request: any, reply: any) => {
19+
fastify.get('/', async (request: any, reply: any) => {
2020
reply.status(200).send('Welcome to Consumet Anime 🗾');
2121
});
2222

23-
fastify.get(
24-
'/:animeProvider',
25-
{ schema: { hide: true } },
26-
async (request: FastifyRequest, reply: FastifyReply) => {
27-
const queries: { animeProvider: string; page: number } = {
28-
animeProvider: '',
29-
page: 1,
30-
};
31-
32-
queries.animeProvider = decodeURIComponent(
33-
(request.params as { animeProvider: string; page: number }).animeProvider,
34-
);
35-
36-
queries.page = (request.query as { animeProvider: string; page: number }).page;
37-
38-
if (queries.page! < 1) queries.page = 1;
39-
40-
const provider = PROVIDERS_LIST.ANIME.find(
41-
(provider: any) => provider.toString.name === queries.animeProvider,
42-
);
43-
44-
try {
45-
if (provider) {
46-
reply.redirect(`/anime/${provider.toString.name}`);
47-
} else {
48-
reply
49-
.status(404)
50-
.send({ message: 'Provider not found, please check the providers list.' });
51-
}
52-
} catch (err) {
53-
reply.status(500).send('Something went wrong. Please try again later.');
23+
fastify.get('/:animeProvider', async (request: FastifyRequest, reply: FastifyReply) => {
24+
const queries: { animeProvider: string; page: number } = {
25+
animeProvider: '',
26+
page: 1,
27+
};
28+
29+
queries.animeProvider = decodeURIComponent(
30+
(request.params as { animeProvider: string; page: number }).animeProvider,
31+
);
32+
33+
queries.page = (request.query as { animeProvider: string; page: number }).page;
34+
35+
if (queries.page! < 1) queries.page = 1;
36+
37+
const provider = PROVIDERS_LIST.ANIME.find(
38+
(provider: any) => provider.toString.name === queries.animeProvider,
39+
);
40+
41+
try {
42+
if (provider) {
43+
reply.redirect(`/anime/${provider.toString.name}`);
44+
} else {
45+
reply
46+
.status(404)
47+
.send({ message: 'Provider not found, please check the providers list.' });
5448
}
55-
},
56-
);
49+
} catch (err) {
50+
reply.status(500).send('Something went wrong. Please try again later.');
51+
}
52+
});
5753
};
5854

5955
export default routes;

src/routes/anime/kickassanime.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,6 @@ import { Redis } from 'ioredis';
99
const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
1010
const kickassanime = new ANIME.KickAssAnime();
1111

12-
fastify.addHook('onRoute', (routeOptions) => {
13-
routeOptions.schema = routeOptions.schema || {};
14-
routeOptions.schema.tags = ['kickassanime'];
15-
});
16-
1712
fastify.get('/', (_, rp) => {
1813
rp.status(200).send({
1914
intro: `Welcome to the kickassanime provider: check out the provider's website @ ${kickassanime.toString.baseUrl}`,

src/routes/books/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { FastifyInstance, RegisterOptions } from 'fastify';
22

33
const routes = async (fastify: FastifyInstance, options: RegisterOptions) => {
4-
fastify.get('/', { schema: { hide: true } }, async (request: any, reply: any) => {
4+
fastify.get('/', async (request: any, reply: any) => {
55
reply.status(200).send('Welcome to Consumet Books 📚');
66
});
77
};

0 commit comments

Comments
 (0)