@@ -12,6 +12,7 @@ import lightnovels from './routes/light-novels';
1212import movies from './routes/movies' ;
1313import meta from './routes/meta' ;
1414import news from './routes/news' ;
15+ import chalk from 'chalk' ;
1516import Utils from './utils' ;
1617
1718export const redis =
@@ -32,67 +33,12 @@ const fastify = Fastify({
3233export 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
0 commit comments