diff --git a/.env.example b/.env.example new file mode 100644 index 000000000..4f55c8ff7 --- /dev/null +++ b/.env.example @@ -0,0 +1,8 @@ +PORT=Port number of the server. (optional) +PROXY=Proxies for requests (optional) (e.g. ["https://proxy1.com", "https://proxy2.com"]) +REDIS_HOST=Redis host (optional) +REDIS_PORT=Redis port (optional) +REDIS_TTL=Redis cache timeout (seconds) (optional) +REDIS_PASSWORD=Redis password (optional) +TMDB_KEY=TMDB access token auth (optional) +NODE_ENV=Environment (optional) (DEMO or PROD) diff --git a/.github/dependabot.yml b/.github/dependabot.yml index e8325f301..44cf5911d 100644 --- a/.github/dependabot.yml +++ b/.github/dependabot.yml @@ -7,8 +7,10 @@ updates: open-pull-requests-limit: 3 allow: - dependency-type: 'production' + ignore: + - dependency-name: "axios" - package-ecosystem: github-actions directory: '/' schedule: interval: daily - open-pull-requests-limit: 2 \ No newline at end of file + open-pull-requests-limit: 2 diff --git a/.github/scripts/install-dependencies.sh b/.github/scripts/install-dependencies.sh new file mode 100644 index 000000000..a82ff186b --- /dev/null +++ b/.github/scripts/install-dependencies.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo "Code BeforeInstall event script ran." \ No newline at end of file diff --git a/.github/scripts/start-server.sh b/.github/scripts/start-server.sh new file mode 100644 index 000000000..3d7dc2367 --- /dev/null +++ b/.github/scripts/start-server.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo "Code ApplicationStart event script ran." \ No newline at end of file diff --git a/.github/scripts/validate-service.sh b/.github/scripts/validate-service.sh new file mode 100644 index 000000000..d148938b9 --- /dev/null +++ b/.github/scripts/validate-service.sh @@ -0,0 +1,2 @@ +#!/bin/bash +echo "Code ValidateService event script ran." \ No newline at end of file diff --git a/.github/workflows/codeql-analysis.yml b/.github/workflows/codeql-analysis.yml index 180d1caa7..e89b3db69 100644 --- a/.github/workflows/codeql-analysis.yml +++ b/.github/workflows/codeql-analysis.yml @@ -42,7 +42,7 @@ jobs: # Initializes the CodeQL tools for scanning. - name: Initialize CodeQL - uses: github/codeql-action/init@v2 + uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} # If you wish to specify custom queries, you can do so here or in a config file. @@ -56,7 +56,7 @@ jobs: # Autobuild attempts to build any compiled languages (C/C++, C#, or Java). # If this step fails, then you should remove it and run the build manually (see below) - name: Autobuild - uses: github/codeql-action/autobuild@v2 + uses: github/codeql-action/autobuild@v3 # â„šī¸ Command-line programs to run using the OS shell. # 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun @@ -69,4 +69,4 @@ jobs: # ./location_of_script_within_repo/buildscript.sh - name: Perform CodeQL Analysis - uses: github/codeql-action/analyze@v2 \ No newline at end of file + uses: github/codeql-action/analyze@v3 \ No newline at end of file diff --git a/.github/workflows/deploy-pi.yml b/.github/workflows/deploy-pi.yml new file mode 100644 index 000000000..6251ba023 --- /dev/null +++ b/.github/workflows/deploy-pi.yml @@ -0,0 +1,80 @@ +name: Deploy to Pi (Production) + +on: + workflow_run: + workflows: ["Node.js CI"] + types: + - completed + branches: [master, main] + workflow_dispatch: + +permissions: + contents: read + actions: read + +jobs: + deploy: + runs-on: [self-hosted, production-deploy, api-consumet-only] + if: ${{ github.event.workflow_run.conclusion == 'success' || github.event_name == 'workflow_dispatch' }} + env: + ACTIONS_RUNNER_DEBUG: false + ACTIONS_STEP_DEBUG: false + + steps: + - name: Validate workflow execution + run: | + if [[ "${{ github.repository }}" != "consumet/api.consumet.org" ]]; then + echo "ERROR: Unauthorized repository: ${{ github.repository }}" + exit 1 + fi + if [[ "${{ github.ref }}" != "refs/heads/main" ]] && [[ "${{ github.ref }}" != "refs/heads/master" ]] && [[ "${{ github.event_name }}" != "workflow_dispatch" ]]; then + echo "ERROR: Unauthorized branch: ${{ github.ref }}" + exit 1 + fi + echo "Workflow validation passed" + + - name: Mask sensitive paths + run: | + echo "::add-mask::$HOME" + echo "::add-mask::$USER" + echo "::add-mask::$(pwd)" + echo "::add-mask::$(dirname $HOME)" + echo "::add-mask::${GITHUB_WORKSPACE}" + # Mask runner directory if it exists + if [ -d "$HOME/actions-runner" ]; then + echo "::add-mask::$HOME/actions-runner" + fi + + - name: Checkout code + uses: actions/checkout@v3 + with: + clean: false + fetch-depth: 1 + + - name: Use Node.js 20.x + uses: actions/setup-node@v4.0.2 + with: + node-version: "20.x" + + - name: Install dependencies + run: | + yarn install --silent 2>&1 | grep -v "^warning" || true + yarn upgrade --silent 2>&1 | grep -v "^warning" || true + + - name: Build API + run: yarn build --silent 2>&1 | tail -5 || true + + - name: Restart PM2 process + run: | + if pm2 describe consumet-api > /dev/null 2>&1; then + pm2 restart consumet-api --silent + else + pm2 start ecosystem.config.js --silent + pm2 save --silent + fi + echo "PM2 process restarted successfully" + + - name: Check PM2 status + run: | + pm2 status 2>&1 | grep -E "(id|name|status|cpu|memory)" | head -3 + echo "Deployment completed" diff --git a/.github/workflows/docker-ci.yml b/.github/workflows/docker-build.yml similarity index 89% rename from .github/workflows/docker-ci.yml rename to .github/workflows/docker-build.yml index 0625aeb7e..4f25b28ee 100644 --- a/.github/workflows/docker-ci.yml +++ b/.github/workflows/docker-build.yml @@ -1,4 +1,4 @@ -name: Docker CI +name: Docker Build on: push: @@ -18,7 +18,7 @@ jobs: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - name: Build and push - uses: docker/build-push-action@v3 + uses: docker/build-push-action@v4 with: push: true tags: ${{ secrets.DOCKERHUB_TAGS }} diff --git a/.github/workflows/nodejs-ci.yml b/.github/workflows/nodejs-ci.yml new file mode 100644 index 000000000..e36a593e6 --- /dev/null +++ b/.github/workflows/nodejs-ci.yml @@ -0,0 +1,27 @@ +name: Node.js CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + strategy: + matrix: + node-version: [ "18.x" ] + + steps: + - uses: actions/checkout@v3 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4.0.2 + with: + node-version: ${{ matrix.node-version }} + - name: Install dependencies & build + run: | + npm install + npx tsc diff --git a/.gitignore b/.gitignore index c51fb098f..3dab0adf6 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,9 @@ node_modules/ yarn-error.log .env src/scripts -.vscode \ No newline at end of file +.vscode +yarn.lock +test.ts +dist +package-lock.json +yarn.lock \ No newline at end of file diff --git a/.npmrc b/.npmrc deleted file mode 100644 index d1cdf2f06..000000000 --- a/.npmrc +++ /dev/null @@ -1 +0,0 @@ -engine-strict = true \ No newline at end of file diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..dd56a6569 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,9 @@ +node_modules +*.js +*.md +*.json +*.lock +*.yml +*.yaml +Dockerfile +Dockerfile.* \ No newline at end of file diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 000000000..22d42466a --- /dev/null +++ b/.travis.yml @@ -0,0 +1,10 @@ +language: node_js +node_js: + - "12.22.12" + - 13 + - 14 + - 15 + - 16 + - 17 +script: + - npm run lint \ No newline at end of file diff --git a/Dockerfile b/Dockerfile index 2669fec65..d41f8514a 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:16 as builder +FROM node:20 as builder LABEL version="1.0.0" LABEL description="Consumet API (fastify) Docker Image" @@ -15,12 +15,16 @@ RUN mkdir -p /home/nodejs/app/node_modules && chown -R nodejs:nodejs /home/nodej WORKDIR /home/nodejs/app # set default node env -ARG NODE_ENV=development +ARG NODE_ENV=PROD ARG PORT=3000 + # ARG NODE_ENV=production # to be able to run tests (for example in CI), do not set production as environment ENV NODE_ENV=${NODE_ENV} ENV PORT=${PORT} +ENV REDIS_HOST=${REDIS_HOST} +ENV REDIS_PORT=${REDIS_PORT} +ENV REDIS_PASSWORD=${REDIS_PASSWORD} ENV NPM_CONFIG_LOGLEVEL=warn @@ -51,4 +55,4 @@ HEALTHCHECK --interval=30s --timeout=10s --start-period=5s CMD npm run healthche # ENTRYPOINT [ "node" ] CMD [ "npm", "start" ] -# end. \ No newline at end of file +# end. diff --git a/Dockerfile.alpine b/Dockerfile.alpine index a6d23df10..22c8cad13 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -1,4 +1,4 @@ -FROM node:16.16-alpine as builder +FROM node:20.8-alpine as builder LABEL version="1.0.0" LABEL description="Consumet API (fastify) Docker Image" diff --git a/Dockerfile.distroless b/Dockerfile.distroless index 90a7bacf2..0291dcb34 100644 --- a/Dockerfile.distroless +++ b/Dockerfile.distroless @@ -1,4 +1,4 @@ -FROM node:14 as builder +FROM node:20 as builder LABEL version="1.0.0" LABEL description="Consumet API (fastify) Docker Image" @@ -21,7 +21,7 @@ COPY . . # release layer (the only one in the final image) -FROM gcr.io/distroless/nodejs:14 AS release +FROM gcr.io/distroless/nodejs:18 AS release COPY --from=builder /app /app WORKDIR /app diff --git a/LICENSE b/LICENSE index e92b21cfa..f288702d2 100644 --- a/LICENSE +++ b/LICENSE @@ -1,21 +1,674 @@ -MIT License - -Copyright (c) 2022 Consumet - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file + GNU GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The GNU General Public License is a free, copyleft license for +software and other kinds of works. + + The licenses for most software and other practical works are designed +to take away your freedom to share and change the works. By contrast, +the GNU General Public License is intended to guarantee your freedom to +share and change all versions of a program--to make sure it remains free +software for all its users. We, the Free Software Foundation, use the +GNU General Public License for most of our software; it applies also to +any other work released this way by its authors. You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +them if you wish), that you receive source code or can get it if you +want it, that you can change the software or use pieces of it in new +free programs, and that you know you can do these things. + + To protect your rights, we need to prevent others from denying you +these rights or asking you to surrender the rights. Therefore, you have +certain responsibilities if you distribute copies of the software, or if +you modify it: responsibilities to respect the freedom of others. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must pass on to the recipients the same +freedoms that you received. You must make sure that they, too, receive +or can get the source code. And you must show them these terms so they +know their rights. + + Developers that use the GNU GPL protect your rights with two steps: +(1) assert copyright on the software, and (2) offer you this License +giving you legal permission to copy, distribute and/or modify it. + + For the developers' and authors' protection, the GPL clearly explains +that there is no warranty for this free software. For both users' and +authors' sake, the GPL requires that modified versions be marked as +changed, so that their problems will not be attributed erroneously to +authors of previous versions. + + Some devices are designed to deny users access to install or run +modified versions of the software inside them, although the manufacturer +can do so. This is fundamentally incompatible with the aim of +protecting users' freedom to change the software. The systematic +pattern of such abuse occurs in the area of products for individuals to +use, which is precisely where it is most unacceptable. Therefore, we +have designed this version of the GPL to prohibit the practice for those +products. If such problems arise substantially in other domains, we +stand ready to extend this provision to those domains in future versions +of the GPL, as needed to protect the freedom of users. + + Finally, every program is threatened constantly by software patents. +States should not allow patents to restrict development and use of +software on general-purpose computers, but in those that do, we wish to +avoid the special danger that patents applied to a free program could +make it effectively proprietary. To prevent this, the GPL assures that +patents cannot be used to render the program non-free. + + The precise terms and conditions for copying, distribution and +modification follow. + + TERMS AND CONDITIONS + + 0. Definitions. + + "This License" refers to version 3 of the GNU General Public License. + + "Copyright" also means copyright-like laws that apply to other kinds of +works, such as semiconductor masks. + + "The Program" refers to any copyrightable work licensed under this +License. Each licensee is addressed as "you". "Licensees" and +"recipients" may be individuals or organizations. + + To "modify" a work means to copy from or adapt all or part of the work +in a fashion requiring copyright permission, other than the making of an +exact copy. The resulting work is called a "modified version" of the +earlier work or a work "based on" the earlier work. + + A "covered work" means either the unmodified Program or a work based +on the Program. + + To "propagate" a work means to do anything with it that, without +permission, would make you directly or secondarily liable for +infringement under applicable copyright law, except executing it on a +computer or modifying a private copy. Propagation includes copying, +distribution (with or without modification), making available to the +public, and in some countries other activities as well. + + To "convey" a work means any kind of propagation that enables other +parties to make or receive copies. Mere interaction with a user through +a computer network, with no transfer of a copy, is not conveying. + + An interactive user interface displays "Appropriate Legal Notices" +to the extent that it includes a convenient and prominently visible +feature that (1) displays an appropriate copyright notice, and (2) +tells the user that there is no warranty for the work (except to the +extent that warranties are provided), that licensees may convey the +work under this License, and how to view a copy of this License. If +the interface presents a list of user commands or options, such as a +menu, a prominent item in the list meets this criterion. + + 1. Source Code. + + The "source code" for a work means the preferred form of the work +for making modifications to it. "Object code" means any non-source +form of a work. + + A "Standard Interface" means an interface that either is an official +standard defined by a recognized standards body, or, in the case of +interfaces specified for a particular programming language, one that +is widely used among developers working in that language. + + The "System Libraries" of an executable work include anything, other +than the work as a whole, that (a) is included in the normal form of +packaging a Major Component, but which is not part of that Major +Component, and (b) serves only to enable use of the work with that +Major Component, or to implement a Standard Interface for which an +implementation is available to the public in source code form. A +"Major Component", in this context, means a major essential component +(kernel, window system, and so on) of the specific operating system +(if any) on which the executable work runs, or a compiler used to +produce the work, or an object code interpreter used to run it. + + The "Corresponding Source" for a work in object code form means all +the source code needed to generate, install, and (for an executable +work) run the object code and to modify the work, including scripts to +control those activities. However, it does not include the work's +System Libraries, or general-purpose tools or generally available free +programs which are used unmodified in performing those activities but +which are not part of the work. For example, Corresponding Source +includes interface definition files associated with source files for +the work, and the source code for shared libraries and dynamically +linked subprograms that the work is specifically designed to require, +such as by intimate data communication or control flow between those +subprograms and other parts of the work. + + The Corresponding Source need not include anything that users +can regenerate automatically from other parts of the Corresponding +Source. + + The Corresponding Source for a work in source code form is that +same work. + + 2. Basic Permissions. + + All rights granted under this License are granted for the term of +copyright on the Program, and are irrevocable provided the stated +conditions are met. This License explicitly affirms your unlimited +permission to run the unmodified Program. The output from running a +covered work is covered by this License only if the output, given its +content, constitutes a covered work. This License acknowledges your +rights of fair use or other equivalent, as provided by copyright law. + + You may make, run and propagate covered works that you do not +convey, without conditions so long as your license otherwise remains +in force. You may convey covered works to others for the sole purpose +of having them make modifications exclusively for you, or provide you +with facilities for running those works, provided that you comply with +the terms of this License in conveying all material for which you do +not control copyright. Those thus making or running the covered works +for you must do so exclusively on your behalf, under your direction +and control, on terms that prohibit them from making any copies of +your copyrighted material outside their relationship with you. + + Conveying under any other circumstances is permitted solely under +the conditions stated below. Sublicensing is not allowed; section 10 +makes it unnecessary. + + 3. Protecting Users' Legal Rights From Anti-Circumvention Law. + + No covered work shall be deemed part of an effective technological +measure under any applicable law fulfilling obligations under article +11 of the WIPO copyright treaty adopted on 20 December 1996, or +similar laws prohibiting or restricting circumvention of such +measures. + + When you convey a covered work, you waive any legal power to forbid +circumvention of technological measures to the extent such circumvention +is effected by exercising rights under this License with respect to +the covered work, and you disclaim any intention to limit operation or +modification of the work as a means of enforcing, against the work's +users, your or third parties' legal rights to forbid circumvention of +technological measures. + + 4. Conveying Verbatim Copies. + + You may convey verbatim copies of the Program's source code as you +receive it, in any medium, provided that you conspicuously and +appropriately publish on each copy an appropriate copyright notice; +keep intact all notices stating that this License and any +non-permissive terms added in accord with section 7 apply to the code; +keep intact all notices of the absence of any warranty; and give all +recipients a copy of this License along with the Program. + + You may charge any price or no price for each copy that you convey, +and you may offer support or warranty protection for a fee. + + 5. Conveying Modified Source Versions. + + You may convey a work based on the Program, or the modifications to +produce it from the Program, in the form of source code under the +terms of section 4, provided that you also meet all of these conditions: + + a) The work must carry prominent notices stating that you modified + it, and giving a relevant date. + + b) The work must carry prominent notices stating that it is + released under this License and any conditions added under section + 7. This requirement modifies the requirement in section 4 to + "keep intact all notices". + + c) You must license the entire work, as a whole, under this + License to anyone who comes into possession of a copy. This + License will therefore apply, along with any applicable section 7 + additional terms, to the whole of the work, and all its parts, + regardless of how they are packaged. This License gives no + permission to license the work in any other way, but it does not + invalidate such permission if you have separately received it. + + d) If the work has interactive user interfaces, each must display + Appropriate Legal Notices; however, if the Program has interactive + interfaces that do not display Appropriate Legal Notices, your + work need not make them do so. + + A compilation of a covered work with other separate and independent +works, which are not by their nature extensions of the covered work, +and which are not combined with it such as to form a larger program, +in or on a volume of a storage or distribution medium, is called an +"aggregate" if the compilation and its resulting copyright are not +used to limit the access or legal rights of the compilation's users +beyond what the individual works permit. Inclusion of a covered work +in an aggregate does not cause this License to apply to the other +parts of the aggregate. + + 6. Conveying Non-Source Forms. + + You may convey a covered work in object code form under the terms +of sections 4 and 5, provided that you also convey the +machine-readable Corresponding Source under the terms of this License, +in one of these ways: + + a) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by the + Corresponding Source fixed on a durable physical medium + customarily used for software interchange. + + b) Convey the object code in, or embodied in, a physical product + (including a physical distribution medium), accompanied by a + written offer, valid for at least three years and valid for as + long as you offer spare parts or customer support for that product + model, to give anyone who possesses the object code either (1) a + copy of the Corresponding Source for all the software in the + product that is covered by this License, on a durable physical + medium customarily used for software interchange, for a price no + more than your reasonable cost of physically performing this + conveying of source, or (2) access to copy the + Corresponding Source from a network server at no charge. + + c) Convey individual copies of the object code with a copy of the + written offer to provide the Corresponding Source. This + alternative is allowed only occasionally and noncommercially, and + only if you received the object code with such an offer, in accord + with subsection 6b. + + d) Convey the object code by offering access from a designated + place (gratis or for a charge), and offer equivalent access to the + Corresponding Source in the same way through the same place at no + further charge. You need not require recipients to copy the + Corresponding Source along with the object code. If the place to + copy the object code is a network server, the Corresponding Source + may be on a different server (operated by you or a third party) + that supports equivalent copying facilities, provided you maintain + clear directions next to the object code saying where to find the + Corresponding Source. Regardless of what server hosts the + Corresponding Source, you remain obligated to ensure that it is + available for as long as needed to satisfy these requirements. + + e) Convey the object code using peer-to-peer transmission, provided + you inform other peers where the object code and Corresponding + Source of the work are being offered to the general public at no + charge under subsection 6d. + + A separable portion of the object code, whose source code is excluded +from the Corresponding Source as a System Library, need not be +included in conveying the object code work. + + A "User Product" is either (1) a "consumer product", which means any +tangible personal property which is normally used for personal, family, +or household purposes, or (2) anything designed or sold for incorporation +into a dwelling. In determining whether a product is a consumer product, +doubtful cases shall be resolved in favor of coverage. For a particular +product received by a particular user, "normally used" refers to a +typical or common use of that class of product, regardless of the status +of the particular user or of the way in which the particular user +actually uses, or expects or is expected to use, the product. A product +is a consumer product regardless of whether the product has substantial +commercial, industrial or non-consumer uses, unless such uses represent +the only significant mode of use of the product. + + "Installation Information" for a User Product means any methods, +procedures, authorization keys, or other information required to install +and execute modified versions of a covered work in that User Product from +a modified version of its Corresponding Source. The information must +suffice to ensure that the continued functioning of the modified object +code is in no case prevented or interfered with solely because +modification has been made. + + If you convey an object code work under this section in, or with, or +specifically for use in, a User Product, and the conveying occurs as +part of a transaction in which the right of possession and use of the +User Product is transferred to the recipient in perpetuity or for a +fixed term (regardless of how the transaction is characterized), the +Corresponding Source conveyed under this section must be accompanied +by the Installation Information. But this requirement does not apply +if neither you nor any third party retains the ability to install +modified object code on the User Product (for example, the work has +been installed in ROM). + + The requirement to provide Installation Information does not include a +requirement to continue to provide support service, warranty, or updates +for a work that has been modified or installed by the recipient, or for +the User Product in which it has been modified or installed. Access to a +network may be denied when the modification itself materially and +adversely affects the operation of the network or violates the rules and +protocols for communication across the network. + + Corresponding Source conveyed, and Installation Information provided, +in accord with this section must be in a format that is publicly +documented (and with an implementation available to the public in +source code form), and must require no special password or key for +unpacking, reading or copying. + + 7. Additional Terms. + + "Additional permissions" are terms that supplement the terms of this +License by making exceptions from one or more of its conditions. +Additional permissions that are applicable to the entire Program shall +be treated as though they were included in this License, to the extent +that they are valid under applicable law. If additional permissions +apply only to part of the Program, that part may be used separately +under those permissions, but the entire Program remains governed by +this License without regard to the additional permissions. + + When you convey a copy of a covered work, you may at your option +remove any additional permissions from that copy, or from any part of +it. (Additional permissions may be written to require their own +removal in certain cases when you modify the work.) You may place +additional permissions on material, added by you to a covered work, +for which you have or can give appropriate copyright permission. + + Notwithstanding any other provision of this License, for material you +add to a covered work, you may (if authorized by the copyright holders of +that material) supplement the terms of this License with terms: + + a) Disclaiming warranty or limiting liability differently from the + terms of sections 15 and 16 of this License; or + + b) Requiring preservation of specified reasonable legal notices or + author attributions in that material or in the Appropriate Legal + Notices displayed by works containing it; or + + c) Prohibiting misrepresentation of the origin of that material, or + requiring that modified versions of such material be marked in + reasonable ways as different from the original version; or + + d) Limiting the use for publicity purposes of names of licensors or + authors of the material; or + + e) Declining to grant rights under trademark law for use of some + trade names, trademarks, or service marks; or + + f) Requiring indemnification of licensors and authors of that + material by anyone who conveys the material (or modified versions of + it) with contractual assumptions of liability to the recipient, for + any liability that these contractual assumptions directly impose on + those licensors and authors. + + All other non-permissive additional terms are considered "further +restrictions" within the meaning of section 10. If the Program as you +received it, or any part of it, contains a notice stating that it is +governed by this License along with a term that is a further +restriction, you may remove that term. If a license document contains +a further restriction but permits relicensing or conveying under this +License, you may add to a covered work material governed by the terms +of that license document, provided that the further restriction does +not survive such relicensing or conveying. + + If you add terms to a covered work in accord with this section, you +must place, in the relevant source files, a statement of the +additional terms that apply to those files, or a notice indicating +where to find the applicable terms. + + Additional terms, permissive or non-permissive, may be stated in the +form of a separately written license, or stated as exceptions; +the above requirements apply either way. + + 8. Termination. + + You may not propagate or modify a covered work except as expressly +provided under this License. Any attempt otherwise to propagate or +modify it is void, and will automatically terminate your rights under +this License (including any patent licenses granted under the third +paragraph of section 11). + + However, if you cease all violation of this License, then your +license from a particular copyright holder is reinstated (a) +provisionally, unless and until the copyright holder explicitly and +finally terminates your license, and (b) permanently, if the copyright +holder fails to notify you of the violation by some reasonable means +prior to 60 days after the cessation. + + Moreover, your license from a particular copyright holder is +reinstated permanently if the copyright holder notifies you of the +violation by some reasonable means, this is the first time you have +received notice of violation of this License (for any work) from that +copyright holder, and you cure the violation prior to 30 days after +your receipt of the notice. + + Termination of your rights under this section does not terminate the +licenses of parties who have received copies or rights from you under +this License. If your rights have been terminated and not permanently +reinstated, you do not qualify to receive new licenses for the same +material under section 10. + + 9. Acceptance Not Required for Having Copies. + + You are not required to accept this License in order to receive or +run a copy of the Program. Ancillary propagation of a covered work +occurring solely as a consequence of using peer-to-peer transmission +to receive a copy likewise does not require acceptance. However, +nothing other than this License grants you permission to propagate or +modify any covered work. These actions infringe copyright if you do +not accept this License. Therefore, by modifying or propagating a +covered work, you indicate your acceptance of this License to do so. + + 10. Automatic Licensing of Downstream Recipients. + + Each time you convey a covered work, the recipient automatically +receives a license from the original licensors, to run, modify and +propagate that work, subject to this License. You are not responsible +for enforcing compliance by third parties with this License. + + An "entity transaction" is a transaction transferring control of an +organization, or substantially all assets of one, or subdividing an +organization, or merging organizations. If propagation of a covered +work results from an entity transaction, each party to that +transaction who receives a copy of the work also receives whatever +licenses to the work the party's predecessor in interest had or could +give under the previous paragraph, plus a right to possession of the +Corresponding Source of the work from the predecessor in interest, if +the predecessor has it or can get it with reasonable efforts. + + You may not impose any further restrictions on the exercise of the +rights granted or affirmed under this License. For example, you may +not impose a license fee, royalty, or other charge for exercise of +rights granted under this License, and you may not initiate litigation +(including a cross-claim or counterclaim in a lawsuit) alleging that +any patent claim is infringed by making, using, selling, offering for +sale, or importing the Program or any portion of it. + + 11. Patents. + + A "contributor" is a copyright holder who authorizes use under this +License of the Program or a work on which the Program is based. The +work thus licensed is called the contributor's "contributor version". + + A contributor's "essential patent claims" are all patent claims +owned or controlled by the contributor, whether already acquired or +hereafter acquired, that would be infringed by some manner, permitted +by this License, of making, using, or selling its contributor version, +but do not include claims that would be infringed only as a +consequence of further modification of the contributor version. For +purposes of this definition, "control" includes the right to grant +patent sublicenses in a manner consistent with the requirements of +this License. + + Each contributor grants you a non-exclusive, worldwide, royalty-free +patent license under the contributor's essential patent claims, to +make, use, sell, offer for sale, import and otherwise run, modify and +propagate the contents of its contributor version. + + In the following three paragraphs, a "patent license" is any express +agreement or commitment, however denominated, not to enforce a patent +(such as an express permission to practice a patent or covenant not to +sue for patent infringement). To "grant" such a patent license to a +party means to make such an agreement or commitment not to enforce a +patent against the party. + + If you convey a covered work, knowingly relying on a patent license, +and the Corresponding Source of the work is not available for anyone +to copy, free of charge and under the terms of this License, through a +publicly available network server or other readily accessible means, +then you must either (1) cause the Corresponding Source to be so +available, or (2) arrange to deprive yourself of the benefit of the +patent license for this particular work, or (3) arrange, in a manner +consistent with the requirements of this License, to extend the patent +license to downstream recipients. "Knowingly relying" means you have +actual knowledge that, but for the patent license, your conveying the +covered work in a country, or your recipient's use of the covered work +in a country, would infringe one or more identifiable patents in that +country that you have reason to believe are valid. + + If, pursuant to or in connection with a single transaction or +arrangement, you convey, or propagate by procuring conveyance of, a +covered work, and grant a patent license to some of the parties +receiving the covered work authorizing them to use, propagate, modify +or convey a specific copy of the covered work, then the patent license +you grant is automatically extended to all recipients of the covered +work and works based on it. + + A patent license is "discriminatory" if it does not include within +the scope of its coverage, prohibits the exercise of, or is +conditioned on the non-exercise of one or more of the rights that are +specifically granted under this License. You may not convey a covered +work if you are a party to an arrangement with a third party that is +in the business of distributing software, under which you make payment +to the third party based on the extent of your activity of conveying +the work, and under which the third party grants, to any of the +parties who would receive the covered work from you, a discriminatory +patent license (a) in connection with copies of the covered work +conveyed by you (or copies made from those copies), or (b) primarily +for and in connection with specific products or compilations that +contain the covered work, unless you entered into that arrangement, +or that patent license was granted, prior to 28 March 2007. + + Nothing in this License shall be construed as excluding or limiting +any implied license or other defenses to infringement that may +otherwise be available to you under applicable patent law. + + 12. No Surrender of Others' Freedom. + + If conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot convey a +covered work so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you may +not convey it at all. For example, if you agree to terms that obligate you +to collect a royalty for further conveying from those to whom you convey +the Program, the only way you could satisfy both those terms and this +License would be to refrain entirely from conveying the Program. + + 13. Use with the GNU Affero General Public License. + + Notwithstanding any other provision of this License, you have +permission to link or combine any covered work with a work licensed +under version 3 of the GNU Affero General Public License into a single +combined work, and to convey the resulting work. The terms of this +License will continue to apply to the part which is the covered work, +but the special requirements of the GNU Affero General Public License, +section 13, concerning interaction through a network will apply to the +combination as such. + + 14. Revised Versions of this License. + + The Free Software Foundation may publish revised and/or new versions of +the GNU General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + + Each version is given a distinguishing version number. If the +Program specifies that a certain numbered version of the GNU General +Public License "or any later version" applies to it, you have the +option of following the terms and conditions either of that numbered +version or of any later version published by the Free Software +Foundation. If the Program does not specify a version number of the +GNU General Public License, you may choose any version ever published +by the Free Software Foundation. + + If the Program specifies that a proxy can decide which future +versions of the GNU General Public License can be used, that proxy's +public statement of acceptance of a version permanently authorizes you +to choose that version for the Program. + + Later license versions may give you additional or different +permissions. However, no additional obligations are imposed on any +author or copyright holder as a result of your choosing to follow a +later version. + + 15. Disclaimer of Warranty. + + THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY +APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT +HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY +OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, +THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR +PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM +IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF +ALL NECESSARY SERVICING, REPAIR OR CORRECTION. + + 16. Limitation of Liability. + + IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS +THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY +GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE +USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF +DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD +PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), +EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF +SUCH DAMAGES. + + 17. Interpretation of Sections 15 and 16. + + If the disclaimer of warranty and limitation of liability provided +above cannot be given local legal effect according to their terms, +reviewing courts shall apply local law that most closely approximates +an absolute waiver of all civil liability in connection with the +Program, unless a warranty or assumption of liability accompanies a +copy of the Program in return for a fee. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +state the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program. If not, see . + +Also add information on how to contact you by electronic and paper mail. + + If the program does terminal interaction, make it output a short +notice like this when it starts in an interactive mode: + + Copyright (C) + This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, your program's commands +might be different; for a GUI interface, you would use an "about box". + + You should also get your employer (if you work as a programmer) or school, +if any, to sign a "copyright disclaimer" for the program, if necessary. +For more information on this, and how to apply and follow the GNU GPL, see +. + + The GNU General Public License does not permit incorporating your program +into proprietary programs. If your program is a subroutine library, you +may consider it more useful to permit linking proprietary applications with +the library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. But first, please read +. diff --git a/Procfile b/Procfile new file mode 100644 index 000000000..d2990ebaf --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: yarn install && yarn build && node dist/main.js \ No newline at end of file diff --git a/README.md b/README.md index 89678a353..56dccf92b 100644 --- a/README.md +++ b/README.md @@ -8,30 +8,47 @@ Consumet API

- Consumet provides an APIs for accessing information and links for various entertertainments like movies, books, anime, etc. + Consumet provides an APIs for accessing information and links for various entertainments like movies, books, anime, etc.

- - GitHub - + + Discord + + + Discord + - Discord + Discord + + + GitHub

Consumet scrapes data from various websites and provides APIs for accessing the data to satisfy your needs. +> [!IMPORTANT] +> Self-hosting the Consumet is required to use the API. Consumet API is no longer publicly available. Please refer to the [Installation section](#installation) for more information on hosting your own instance. + +> [!CAUTION] +> Consumet is not affiliated with any of the providers it scrapes data from. Consumet is not responsible for any misuse of the data provided by the API. Commercial utilization may lead to serious consequences, including potential site takedown measures. Ensure that you understand the legal implications before using this API. +

Table of Contents

- [Installation](#installation) - [Locally](#locally) - [Docker](#docker) - [Heroku](#heroku) + - [Vercel](#vercel) + - [Render](#render) + - [Railway](#railway) - [Documentation](#documentation) - [Development](#development) +- [Showcases](#showcases) - [Provider Request](#provider-request) - [Support](#support) -- [Other repositories](#other-repositories) +- [Contributors ✨](#contributors-) +- [Related repositories](#related-repositories) ## Installation ### Locally @@ -40,8 +57,8 @@ installation is simple. Run the following command to clone the repository, and install the dependencies. ```sh -$ git clone https://github.com/consumet/consumet-api.git -$ cd consumet-api +$ git clone https://github.com/consumet/api.consumet.org.git +$ cd api.consumet.org $ npm install #or yarn install ``` @@ -62,30 +79,57 @@ $ docker run -p 3000:3000 riimuru/consumet-api ``` This will start the server on port 3000. You can access the server at http://localhost:3000/, And can change the port by changing the -p option to `-p :3000`. +Be sure to set `NODE_ENV` to `PROD` in your environment variables when running your own instance. +Check out the `.env.example` file for more information. + You can add `-d` flag to run the server in detached mode. ### Heroku -Host your own instance of Consumet API on Heroku using the button below.\ -[![Deploy on Heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/consumet/consumet-api/tree/main) +Host your own instance of Consumet API on Heroku using the button below. + +[![Deploy on Heroku](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/consumet/api.consumet.org/tree/main) + +### Vercel +Host your own instance of Consumet API on Vercel using the button below. + +[![Deploy with Vercel](https://vercel.com/button)](https://vercel.com/new/clone?repository-url=https%3A%2F%2Fgithub.com%2Fconsumet%2Fapi.consumet.org) + +### Render +Host your own instance of Consumet API on Render using the button below. + +[![Deploy to Render](https://render.com/images/deploy-to-render-button.svg)](https://render.com/deploy?repo=https://github.com/consumet/api.consumet.org) + +### Railway +Host your own instance of Consumet API on Railway using the button below. + +[![Deploy on Railway](https://railway.app/button.svg)](https://railway.app/new/template/C0FwuP?referralCode=dv4TuD) ## Documentation Please refer to the [documentation](https://docs.consumet.org). Join our [Discord server](https://discord.gg/qTPfvMxzNH) if you need any additional help or have any questions, comments, or suggestions. ## Development -Pull requests and stars are always welcome, for bugs and features create a new [issue](https://github.com/consumet/consumet-api/issues). If you're brave to make make a commit to the project see [CONTRIBUTING.md](https://github.com/consumet/extensions/blob/master/docs/guides/contributing.md). +Pull requests and stars are always welcome, for bugs and features create a new [issue](https://github.com/consumet/api.consumet.org/issues). If you're brave to make make a commit to the project see [CONTRIBUTING.md](https://github.com/consumet/consumet.ts/blob/master/docs/guides/contributing.md). + +## Showcases +Showcases are welcome! If you have a project that uses Consumet API, please let us know by making a new discussion [here](https://github.com/consumet/api.consumet.org/discussions/categories/show-and-tell) or by joining our [Discord server](https://discord.gg/qTPfvMxzNH). We will add your project to our [showcases page](https://consumet.org/showcase). ## Provider Request Make a new [issue](https://github.com/consumet/consumet.ts/issues/new?assignees=&labels=provider+request&template=provider-request.yml) with the name of the provider on the title, as well as a link to the provider in the body paragraph. ## Support You can contact the maintainers of consumet.ts via [email](mailto:consumet.org@gmail.com), or [join the discord server](https://discord.gg/qTPfvMxzNH) (Recommended). -

- - - -

+ + + + + + +## Contributors ✨ +Thanks to the following people for keeping this project alive and thriving. + +[![](https://contrib.rocks/image?repo=consumet/consumet.ts)](https://github.com/consumet/consumet.ts/graphs/contributors) ## Related repositories - - [Consumet.ts](https://github.com/consumet/extensions) + - [Consumet.ts](https://github.com/consumet/consumet.ts) - [Website](https://github.com/consumet/consumet.org) - [Providers Status](https://github.com/consumet/providers-status) diff --git a/app.json b/app.json index f01345882..8011253a0 100644 --- a/app.json +++ b/app.json @@ -9,6 +9,18 @@ "PORT": { "description": "Set PORT for the fastify application to run on.", "value": "3000" + }, + "REDIS_HOST": { + "description": "Set redis host, you can create a redis instance on your own or use upstash (https://upstash.com) its for free.", + "value": "" + }, + "REDIS_PASS": { + "description": "Set redis password, you can create a redis instance on your own or use upstash (https://upstash.com) its for free.", + "value": "" + }, + "REDIS_PORT": { + "description": "Set redis port, you can create a redis instance on your own or use upstash (https://upstash.com) its for free.", + "value": "" } } } \ No newline at end of file diff --git a/appspec.yaml b/appspec.yaml new file mode 100644 index 000000000..43b9973c9 --- /dev/null +++ b/appspec.yaml @@ -0,0 +1,19 @@ +version: 0.0 +os: linux +files: + - source: / + destination: /api-consumet-org +hooks: + BeforeInstall: + - location: .github/scripts/install_dependencies.sh + timeout: 300 + runas: root + + ApplicationStart: + - location: .github/scripts/start_server.sh + timeout: 300 + runas: root + + ValidateService: + - location: .github/scripts/validate_service.sh + timeout: 300 \ No newline at end of file diff --git a/buildspec.yaml b/buildspec.yaml new file mode 100644 index 000000000..ced6a31c0 --- /dev/null +++ b/buildspec.yaml @@ -0,0 +1,38 @@ +version: 0.2 + +env: + parameter-store: + REDIS_HOST: /redis/host + REDIS_PORT: /redis/port + REDIS_PASSWORD: /redis/password + PORT: /port + NODE_ENV: /node/env + +phases: + install: + runtime-versions: + nodejs: 18 + commands: + - echo "đŸ“Ļ installing packages..." + - echo "✅ Packages installed successfully." + pre_build: + commands: + - echo "âš™ī¸ Testing..." + - echo "✅ Tests passed successfully." + - echo $PASSWORD + + build: + commands: + - echo "🚧 Starting compiling packages..." + - echo "✅ Build passed successfully." + post_build: + commands: + - echo "🚚 Performing post-build packing and operations..." + - aws deploy push --application-name deploy.api.consumet.org --s3-location s3://deploy-deployment-revisions/development/source.zip --ignore-hidden-files + - aws deploy create-deployment --application-name deploy.api.consumet.org --s3-location bucket=deploy-deployment-revisions,key=development/source.zip,bundleType=zip,eTag=80e501480a8545019660e87ca42a6f00,version=67ZE9Q8CZeo9XszaZ4F.eKmrlW7mnDrm --deployment-group-name DGN --deployment-config-name CodeDeployDefault.AllAtOnce --description "This deployment aims to deploy our code to the eligible EC2 instance(s)." + - echo "✅ Post build successful" + +artifacts: + files: + - '**/*' + name: deploy-build-artifacts \ No newline at end of file diff --git a/demo/apidemo.html b/demo/apidemo.html new file mode 100644 index 000000000..79fb7ad0a --- /dev/null +++ b/demo/apidemo.html @@ -0,0 +1,90 @@ + + + + +Demo of Consumet API + + + + +
+ This is a demo of Consumet API. It should be only used for development purposes. + To temporarily unlock access to the API, click the button below and follow the instructions. + +
+ + + + \ No newline at end of file diff --git a/ecosystem.config.js b/ecosystem.config.js new file mode 100644 index 000000000..691dcfb7b --- /dev/null +++ b/ecosystem.config.js @@ -0,0 +1,16 @@ +module.exports = { + apps: [{ + name: 'consumet-api', + script: 'dist/main.js', + cwd: process.env.HOME + '/api.consumet.org', + interpreter: process.env.HOME + '/.bun/bin/bun', + cron_restart: '0 0 * * *', + env: { + PORT: 8000, + NODE_ENV: 'production' + }, + autorestart: true, + max_restarts: 10, + min_uptime: '10s' + }] +}; diff --git a/ecosystem.preview.config.js b/ecosystem.preview.config.js new file mode 100644 index 000000000..4edbed980 --- /dev/null +++ b/ecosystem.preview.config.js @@ -0,0 +1,15 @@ +module.exports = { + apps: [{ + name: 'consumet-api-preview', + script: 'dist/main.js', + cwd: process.env.HOME + '/api.consumet.org-preview', + interpreter: process.env.HOME + '/.bun/bin/bun', + cron_restart: '0 0 * * *', + env: { + PORT: 8001, + }, + autorestart: true, + max_restarts: 10, + min_uptime: '10s' + }] +}; diff --git a/package.json b/package.json index 83bee6a3e..8ac0b3d04 100644 --- a/package.json +++ b/package.json @@ -1,10 +1,12 @@ { - "name": "consumet", + "name": "api.consumet.org", "version": "1.0.0", "main": "src/main.ts", "scripts": { "start": "ts-node src/main.ts", - "dev": "nodemon src/main.ts" + "dev": "nodemon src/main.ts", + "build": "tsc", + "lint": "prettier --write \"src/**/*.ts\"" }, "engines": { "node": ">=12.5.0", @@ -21,20 +23,23 @@ }, "homepage": "https://github.com/consumet/consumet.ts#readme", "dependencies": { - "@consumet/extensions": "https://github.com/consumet/consumet.ts.git", - "@fastify/cors": "^8.0.0", - "@types/fastify-cors": "^2.1.0", - "@types/node": "^18.0.2", - "axios": "^0.27.2", - "cheerio": "^1.0.0-rc.11", - "consumet.ts": "https://github.com/consumet/consumet.ts.git", - "dotenv": "^16.0.1", - "fastify": "^4.2.0", - "fastify-cors": "^6.1.0", + "@consumet/extensions": "github:consumet/consumet.ts", + "@fastify/cors": "^8.5.0", + "@types/node": "^18.11.17", + "@types/ws": "^8.5.3", + "axios": "^1.0.0", + "chalk": "4.1.2", + "cheerio": "1.0.0-rc.12", + "dotenv": "^16.0.3", + "fastify": "^4.10.2", + "ioredis": "^5.2.4", + "reconnecting-websocket": "^4.4.0", "ts-node": "^10.9.1", - "typescript": "4.7.4" + "ws": "^8.8.1" }, "devDependencies": { - "nodemon": "^2.0.19" + "nodemon": "3.0.1", + "prettier": "^3.0.0", + "typescript": "5.3.3" } } diff --git a/render.yaml b/render.yaml new file mode 100644 index 000000000..6b69f1907 --- /dev/null +++ b/render.yaml @@ -0,0 +1,10 @@ +services: + - type: web + name: consumet-api # Name of the service + env: docker + repo: https://github.com/consumet/api.consumet.org.git + plan: free + branch: main + envVars: + - key: PORT + value: 3000 \ No newline at end of file diff --git a/renovate.json b/renovate.json new file mode 100644 index 000000000..de882b2c8 --- /dev/null +++ b/renovate.json @@ -0,0 +1,21 @@ +{ + "$schema": "https://docs.renovatebot.com/renovate-schema.json", + "extends": [ + "config:base" + ], + "lockFileMaintenance": { + "enabled": true, + "automerge": true, + "automergeType": "pr", + "platformAutomerge": true + }, + "packageRules": [{ + "matchDatasources": [ + "npm", "yarn" + ], + "matchDepTypes": ["dependencies"], + "matchPackagePatterns": ["*"], + "automerge": false, + "schedule": "before 10pm" + }] +} \ No newline at end of file diff --git a/src/main.ts b/src/main.ts index 089654372..81184be71 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,7 +1,8 @@ require('dotenv').config(); - +import Redis from 'ioredis'; import Fastify from 'fastify'; import FastifyCors from '@fastify/cors'; +import fs from 'fs'; import books from './routes/books'; import anime from './routes/anime'; @@ -10,16 +11,133 @@ import comics from './routes/comics'; import lightnovels from './routes/light-novels'; import movies from './routes/movies'; import meta from './routes/meta'; +import news from './routes/news'; +import chalk from 'chalk'; +import Utils from './utils'; -(async () => { - const PORT = Number(process.env.PORT); - const fastify = Fastify({ - logger: true, +export const redis = + process.env.REDIS_HOST && + new Redis({ + host: process.env.REDIS_HOST, + port: Number(process.env.REDIS_PORT), + password: process.env.REDIS_PASSWORD, }); + +// Sets default TTL to 1 hour (3600 seconds) if not provided in .env +export const REDIS_TTL = Number(process.env.REDIS_TTL) || 3600; + +const fastify = Fastify({ + maxParamLength: 1000, + logger: true, +}); +export const tmdbApi = process.env.TMDB_KEY && process.env.TMDB_KEY; +(async () => { + const PORT = Number(process.env.PORT) || 3000; + await fastify.register(FastifyCors, { origin: '*', methods: 'GET', }); + + if (process.env.NODE_ENV === 'DEMO') { + console.log(chalk.yellowBright('DEMO MODE ENABLED')); + + const map = new Map(); + // session duration in milliseconds (5 hours) + const sessionDuration = 1000 * 60 * 60 * 5; + + fastify.addHook('onRequest', async (request, reply) => { + const ip = request.ip; + const session = map.get(ip); + + // check if the requester ip has a session (temporary access) + if (session) { + // if session is found, check if the session is expired + const { expiresIn } = session; + const currentTime = new Date(); + const sessionTime = new Date(expiresIn); + + // check if the session has been expired + if (currentTime.getTime() > sessionTime.getTime()) { + console.log('session expired'); + // if expired, delete the session and continue + map.delete(ip); + + // redirect to the demo request page + return reply.redirect('/apidemo'); + } + console.log('session found. expires in', expiresIn); + if (request.url === '/apidemo') return reply.redirect('/'); + return; + } + + // if route is not /apidemo, redirect to the demo request page + if (request.url === '/apidemo') return; + + console.log('session not found'); + reply.redirect('/apidemo'); + }); + + fastify.post('/apidemo', async (request, reply) => { + const { ip } = request; + + // check if the requester ip has a session (temporary access) + const session = map.get(ip); + + if (session) return reply.redirect('/'); + + // if no session, create a new session + const expiresIn = new Date(Date.now() + sessionDuration); + map.set(ip, { expiresIn }); + + // redirect to the demo request page + reply.redirect('/'); + }); + + fastify.get('/apidemo', async (_, reply) => { + try { + const stream = fs.readFileSync(__dirname + '/../demo/apidemo.html'); + return reply.type('text/html').send(stream); + } catch (err) { + console.error(err); + return reply.status(500).send({ + message: 'Could not load the demo page. Please try again later.', + }); + } + }); + + // set interval to delete expired sessions every 1 hour + setInterval( + () => { + const currentTime = new Date(); + for (const [ip, session] of map.entries()) { + const { expiresIn } = session; + const sessionTime = new Date(expiresIn); + + // check if the session is expired + if (currentTime.getTime() > sessionTime.getTime()) { + console.log('session expired for', ip); + // if expired, delete the session and continue + map.delete(ip); + } + } + }, + 1000 * 60 * 60, + ); + } + + console.log(chalk.green(`Starting server on port ${PORT}... 🚀`)); + if (!process.env.REDIS_HOST) { + console.warn(chalk.yellowBright('Redis not found. Cache disabled.')); + } else { + console.log(chalk.green(`Redis connected. Default Cache TTL: ${REDIS_TTL} seconds`)); + } + + if (!process.env.TMDB_KEY) + console.warn( + chalk.yellowBright('TMDB api key not found. the TMDB meta route may not work.'), + ); + await fastify.register(books, { prefix: '/books' }); await fastify.register(anime, { prefix: '/anime' }); await fastify.register(manga, { prefix: '/manga' }); @@ -27,10 +145,18 @@ import meta from './routes/meta'; await fastify.register(lightnovels, { prefix: '/light-novels' }); await fastify.register(movies, { prefix: '/movies' }); await fastify.register(meta, { prefix: '/meta' }); + await fastify.register(news, { prefix: '/news' }); + await fastify.register(Utils, { prefix: '/utils' }); try { fastify.get('/', (_, rp) => { - rp.status(200).send('Welcome to consumet api! 🎉'); + rp.status(200).send( + `Welcome to consumet api! 🎉 \n${ + process.env.NODE_ENV === 'DEMO' + ? 'This is a demo of the api. You should only use this for testing purposes.' + : '' + }`, + ); }); fastify.get('*', (request, reply) => { reply.status(404).send({ @@ -48,3 +174,7 @@ import meta from './routes/meta'; process.exit(1); } })(); +export default async function handler(req: any, res: any) { + await fastify.ready(); + fastify.server.emit('request', req, res); +} diff --git a/src/routes/anime/animekai.ts b/src/routes/anime/animekai.ts new file mode 100644 index 000000000..d7fb64a09 --- /dev/null +++ b/src/routes/anime/animekai.ts @@ -0,0 +1,462 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { ANIME } from '@consumet/extensions'; +import { StreamingServers, SubOrSub } from '@consumet/extensions/dist/models'; + +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + const animekai = new ANIME.AnimeKai(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: `Welcome to the animekai provider: check out the provider's website @ ${animekai.toString.baseUrl}`, + routes: [ + '/:query', + '/latest-completed', + '/new-releases', + '/recent-added', + '/recent-episodes', + '/schedule/:date', + '/spotlight', + '/search-suggestions/:query', + '/servers', + '/info', + '/watch/:episodeId', + '/genre/list', + '/genre/:genre', + '/movies', + '/ona', + '/ova', + '/specials', + '/tv', + ], + documentation: 'https://docs.consumet.org/#tag/animekai', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const query = (request.params as { query: string }).query; + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:search:${query}:${page}`, + async () => await animekai.search(query, page), + REDIS_TTL, + ) + : await animekai.search(query, page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } + }); + + fastify.get( + '/latest-completed', + async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:latest-completed:${page}`, + async () => await animekai.fetchLatestCompleted(page), + REDIS_TTL, + ) + : await animekai.fetchLatestCompleted(page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } + }, + ); + + fastify.get('/new-releases', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:new-releases:${page}`, + async () => await animekai.fetchNewReleases(page), + REDIS_TTL, + ) + : await animekai.fetchNewReleases(page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } + }); + + fastify.get('/recent-added', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:recent-added:${page}`, + async () => await animekai.fetchRecentlyAdded(page), + REDIS_TTL, + ) + : await animekai.fetchRecentlyAdded(page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } + }); + + fastify.get( + '/recent-episodes', + async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:recent-episodes:${page}`, + async () => await animekai.fetchRecentlyUpdated(page), + REDIS_TTL, + ) + : await animekai.fetchRecentlyUpdated(page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } + }, + ); + + fastify.get('/schedule/:date', async (request: FastifyRequest, reply: FastifyReply) => { + const date = (request.params as { date: string }).date; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:schedule:${date}`, + async () => await animekai.fetchSchedule(date), + REDIS_TTL, + ) + : await animekai.fetchSchedule(date); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } + }); + + fastify.get('/spotlight', async (request: FastifyRequest, reply: FastifyReply) => { + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:spotlight`, + async () => await animekai.fetchSpotlight(), + REDIS_TTL, + ) + : await animekai.fetchSpotlight(); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } + }); + + fastify.get( + '/search-suggestions/:query', + async (request: FastifyRequest, reply: FastifyReply) => { + const query = (request.params as { query: string }).query; + + if (typeof query === 'undefined') + return reply.status(400).send({ message: 'query is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:suggestions:${query}`, + async () => await animekai.fetchSearchSuggestions(query), + REDIS_TTL, + ) + : await animekai.fetchSearchSuggestions(query); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } + }, + ); + + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.query as { id: string }).id; + + if (typeof id === 'undefined') + return reply.status(400).send({ message: 'id is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:info:${id}`, + async () => await animekai.fetchAnimeInfo(id), + REDIS_TTL, + ) + : await animekai.fetchAnimeInfo(id); + + return reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get( + '/watch/:episodeId', + async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.params as { episodeId: string }).episodeId; + const server = (request.query as { server: string }).server as StreamingServers; + + let dub = (request.query as { dub?: string | boolean }).dub; + if (dub === 'true' || dub === '1') dub = true; + else dub = false; + + if (server && !Object.values(StreamingServers).includes(server)) + return reply.status(400).send({ message: 'server is invalid' }); + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'id is required' }); + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:watch:${episodeId}:${server}:${dub}`, + async () => + await animekai.fetchEpisodeSources( + episodeId, + server, + dub === true ? SubOrSub.DUB : SubOrSub.SUB, + ), + REDIS_TTL, + ) + : await animekai.fetchEpisodeSources( + episodeId, + server, + dub === true ? SubOrSub.DUB : SubOrSub.SUB, + ); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }, + ); + + fastify.get( + '/servers/:episodeId', + async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.params as { episodeId: string }).episodeId; + let dub = (request.query as { dub?: string | boolean }).dub; + if (dub === 'true' || dub === '1') dub = true; + else dub = false; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'id is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:servers:${episodeId}:${dub}`, + async () => + await animekai.fetchEpisodeServers( + episodeId, + dub === true ? SubOrSub.DUB : SubOrSub.SUB, + ), + REDIS_TTL, + ) + : await animekai.fetchEpisodeServers( + episodeId, + dub === true ? SubOrSub.DUB : SubOrSub.SUB, + ); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }, + ); + + fastify.get('/genre/list', async (_, reply) => { + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:genre-list`, + async () => await animekai.fetchGenres(), + REDIS_TTL, + ) + : await animekai.fetchGenres(); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } + }); + + fastify.get('/genre/:genre', async (request: FastifyRequest, reply: FastifyReply) => { + const genre = (request.params as { genre: string }).genre; + const page = (request.query as { page: number }).page; + + if (typeof genre === 'undefined') + return reply.status(400).send({ message: 'genre is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:genre:${genre}:${page}`, + async () => await animekai.genreSearch(genre, page), + REDIS_TTL, + ) + : await animekai.genreSearch(genre, page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } + }); + + fastify.get('/movies', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:movies:${page}`, + async () => await animekai.fetchMovie(page), + REDIS_TTL, + ) + : await animekai.fetchMovie(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/ona', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:ona:${page}`, + async () => await animekai.fetchONA(page), + REDIS_TTL, + ) + : await animekai.fetchONA(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/ova', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:ova:${page}`, + async () => await animekai.fetchOVA(page), + REDIS_TTL, + ) + : await animekai.fetchOVA(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/specials', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:specials:${page}`, + async () => await animekai.fetchSpecial(page), + REDIS_TTL, + ) + : await animekai.fetchSpecial(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/tv', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animekai:tv:${page}`, + async () => await animekai.fetchTV(page), + REDIS_TTL, + ) + : await animekai.fetchTV(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); +}; + +export default routes; diff --git a/src/routes/anime/animepahe.ts b/src/routes/anime/animepahe.ts index 6a086a0d3..c9e9e030d 100644 --- a/src/routes/anime/animepahe.ts +++ b/src/routes/anime/animepahe.ts @@ -1,68 +1,111 @@ import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; import { ANIME } from '@consumet/extensions'; +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { const animepahe = new ANIME.AnimePahe(); - fastify.get('/animephane', (_, rp) => { + fastify.get('/', (_, rp) => { rp.status(200).send({ - intro: - "Welcome to the animepahe provider: check out the provider's website @ https://animepahe.com/", - routes: ['/:query', '/info/:id', '/watch/:episodeId'], + intro: `Welcome to the animepahe provider: check out the provider's website @ ${animepahe.toString.baseUrl}`, + routes: ['/:query', '/info/:id', '/watch/:episodeId', '/recent-episodes'], documentation: 'https://docs.consumet.org/#tag/animepahe', }); }); - fastify.get( - '/animepahe/:query', - async (request: FastifyRequest, reply: FastifyReply) => { - const query = (request.params as { query: string }).query; + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const query = (request.params as { query: string }).query; - const res = await animepahe.search(query); + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animepahe:search:${query}`, + async () => await animepahe.search(query), + REDIS_TTL, + ) + : await animepahe.search(query); reply.status(200).send(res); + } catch (err) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); } - ); + }); fastify.get( - '/animepahe/info/:id', + '/recent-episodes', async (request: FastifyRequest, reply: FastifyReply) => { - const id = decodeURIComponent((request.params as { id: string }).id); - - const episodePage = (request.query as { episodePage: number }).episodePage; - + const page = (request.query as { page: number }).page; try { - const res = await animepahe - .fetchAnimeInfo(id, episodePage) - .catch((err) => reply.status(404).send({ message: err })); + let res = redis + ? await cache.fetch( + redis as Redis, + `animepahe:recent-episodes:${page}`, + async () => await animepahe.fetchRecentEpisodes(page), + REDIS_TTL, + ) + : await animepahe.fetchRecentEpisodes(page); reply.status(200).send(res); - } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Contact developer for help.' }); + } catch (error) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); } - } + }, ); - fastify.get( - '/animepahe/watch/:episodeId', - async (request: FastifyRequest, reply: FastifyReply) => { - const episodeId = (request.params as { episodeId: string }).episodeId; + fastify.get('/info/:id', async (request: FastifyRequest, reply: FastifyReply) => { + const id = decodeURIComponent((request.params as { id: string }).id); + const episodePage = (request.query as { episodePage: number }).episodePage; - try { - const res = await animepahe - .fetchEpisodeSources(episodeId) - .catch((err) => reply.status(404).send({ message: err })); + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animepahe:info:${id}:${episodePage}`, + async () => await animepahe.fetchAnimeInfo(id, episodePage), + REDIS_TTL, + ) + : await animepahe.fetchAnimeInfo(id, episodePage); - reply.status(200).send(res); - } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Contact developer for help.' }); - } + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); } - ); + }); + + fastify.get('/watch', async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.query as { episodeId: string }).episodeId; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animepahe:watch:${episodeId}`, + async () => await animepahe.fetchEpisodeSources(episodeId), + REDIS_TTL, + ) + : await animepahe.fetchEpisodeSources(episodeId); + + reply.status(200).send(res); + } catch (err) { + console.log(err); + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); }; export default routes; diff --git a/src/routes/anime/animesaturn.ts b/src/routes/anime/animesaturn.ts new file mode 100644 index 000000000..eac39d50d --- /dev/null +++ b/src/routes/anime/animesaturn.ts @@ -0,0 +1,119 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { ANIME } from '@consumet/extensions'; +import Redis from 'ioredis/built'; +import { redis, REDIS_TTL } from '../../main'; +import cache from '../../utils/cache'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + const animesaturn = new ANIME.AnimeSaturn(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: + "Welcome to the animesaturn provider: check out the provider's website @ https://www.animesaturn.tv/", + routes: ['/:query', '/info/:id', '/watch/:episodeId'], + documentation: 'https://docs.consumet.org/#tag/animesaturn', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const query = (request.params as { query: string }).query; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animesaturn:search:${query}`, + async () => await animesaturn.search(query), + REDIS_TTL, + ) + : await animesaturn.search(query); + + reply.status(200).send(res); + } catch (err) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } + }); + + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.query as { id: string }).id; + + if (typeof id === 'undefined') + return reply.status(400).send({ message: 'id is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animesaturn:info:${id}`, + async () => await animesaturn.fetchAnimeInfo(id), + REDIS_TTL, + ) + : await animesaturn.fetchAnimeInfo(id); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get( + '/watch/:episodeId', + async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.params as { episodeId: string }).episodeId; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animesaturn:watch:${episodeId}`, + async () => await animesaturn.fetchEpisodeSources(episodeId), + REDIS_TTL, + ) + : await animesaturn.fetchEpisodeSources(episodeId); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }, + ); + + fastify.get( + '/servers/:episodeId', + async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.params as { episodeId: string }).episodeId; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animesaturn:servers:${episodeId}`, + async () => await animesaturn.fetchEpisodeServers(episodeId), + REDIS_TTL, + ) + : await animesaturn.fetchEpisodeServers(episodeId); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }, + ); +}; + +export default routes; diff --git a/src/routes/anime/animeunity.ts b/src/routes/anime/animeunity.ts new file mode 100644 index 000000000..74a7f0fa8 --- /dev/null +++ b/src/routes/anime/animeunity.ts @@ -0,0 +1,93 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { ANIME } from '@consumet/extensions'; + +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + const animeunity = new ANIME.AnimeUnity(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: `Welcome to the animeunity provider: check out the provider's website @ ${animeunity.toString.baseUrl}`, + routes: ['/:query', '/info', '/watch/:episodeId'], + documentation: 'https://docs.consumet.org/#tag/animeunity', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const query = (request.params as { query: string }).query; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animeunity:search:${query}`, + async () => await animeunity.search(query), + REDIS_TTL, + ) + : await animeunity.search(query); + + reply.status(200).send(res); + } catch (err) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } + }); + + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.query as { id: string }).id; + const page = (request.query as { page: number }).page; + + if (typeof id === 'undefined') + return reply.status(400).send({ message: 'id is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animeunity:info:${id}:${page}`, + async () => await animeunity.fetchAnimeInfo(id, page), + REDIS_TTL, + ) + : await animeunity.fetchAnimeInfo(id, page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get( + '/watch/:episodeId', + async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.params as { episodeId: string }).episodeId; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `animeunity:watch:${episodeId}`, + async () => await animeunity.fetchEpisodeSources(episodeId), + REDIS_TTL, + ) + : await animeunity.fetchEpisodeSources(episodeId); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }, + ); +}; + +export default routes; diff --git a/src/routes/anime/gogoanime.ts b/src/routes/anime/gogoanime.ts deleted file mode 100644 index ca817c2d7..000000000 --- a/src/routes/anime/gogoanime.ts +++ /dev/null @@ -1,134 +0,0 @@ -import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; -import { ANIME } from '@consumet/extensions'; -import { StreamingServers } from '@consumet/extensions/dist/models'; - -const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { - const gogoanime = new ANIME.Gogoanime(); - - fastify.get('/gogoanime', (_, rp) => { - rp.status(200).send({ - intro: - "Welcome to the gogoanime provider: check out the provider's website @ https://gogoanime.gg/", - routes: [ - '/:query', - '/info/:id', - '/watch/:episodeId', - '/servers/:episodeId', - '/top-airing', - '/recent-episodes', - ], - documentation: 'https://docs.consumet.org/#tag/gogoanime', - }); - }); - - fastify.get( - '/gogoanime/:query', - async (request: FastifyRequest, reply: FastifyReply) => { - const query = (request.params as { query: string }).query; - const page = (request.query as { page: number }).page || 1; - - const res = await gogoanime.search(query, page); - - reply.status(200).send(res); - } - ); - - fastify.get( - '/gogoanime/info/:id', - async (request: FastifyRequest, reply: FastifyReply) => { - const id = decodeURIComponent((request.params as { id: string }).id); - - try { - const res = await gogoanime - .fetchAnimeInfo(id) - .catch((err) => reply.status(404).send({ message: err })); - - reply.status(200).send(res); - } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Please try again later.' }); - } - } - ); - - fastify.get( - '/gogoanime/watch/:episodeId', - async (request: FastifyRequest, reply: FastifyReply) => { - const episodeId = (request.params as { episodeId: string }).episodeId; - const server = (request.query as { server: StreamingServers }).server; - - if (server && !Object.values(StreamingServers).includes(server)) { - reply.status(400).send('Invalid server'); - } - - try { - const res = await gogoanime - .fetchEpisodeSources(episodeId, server) - .catch((err) => reply.status(404).send({ message: err })); - - reply.status(200).send(res); - } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Please try again later.' }); - } - } - ); - - fastify.get( - '/gogoanime/servers/:episodeId', - async (request: FastifyRequest, reply: FastifyReply) => { - const episodeId = (request.params as { episodeId: string }).episodeId; - - try { - const res = await gogoanime - .fetchEpisodeServers(episodeId) - .catch((err) => reply.status(404).send({ message: err })); - - reply.status(200).send(res); - } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Please try again later.' }); - } - } - ); - - fastify.get( - '/gogoanime/top-airing', - async (request: FastifyRequest, reply: FastifyReply) => { - try { - const page = (request.query as { page: number }).page; - - const res = await gogoanime.fetchTopAiring(page); - - reply.status(200).send(res); - } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Contact developers for help.' }); - } - } - ); - - fastify.get( - '/gogoanime/recent-episodes', - async (request: FastifyRequest, reply: FastifyReply) => { - try { - const type = (request.query as { type: number }).type; - const page = (request.query as { page: number }).page; - - const res = await gogoanime.fetchRecentEpisodes(page, type); - - reply.status(200).send(res); - } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Contact developers for help.' }); - } - } - ); -}; - -export default routes; diff --git a/src/routes/anime/hianime.ts b/src/routes/anime/hianime.ts new file mode 100644 index 000000000..9a27ecf31 --- /dev/null +++ b/src/routes/anime/hianime.ts @@ -0,0 +1,641 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { ANIME } from '@consumet/extensions'; +import { StreamingServers, SubOrSub } from '@consumet/extensions/dist/models'; + +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + const hianime = new ANIME.Hianime(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: `Welcome to the hianime provider: check out the provider's website @ ${hianime.toString.baseUrl}`, + routes: [ + '/:query', + '/info', + '/watch/:episodeId', + '/advanced-search', + '/top-airing', + '/most-popular', + '/most-favorite', + '/latest-completed', + '/recently-updated', + '/recently-added', + '/top-upcoming', + '/studio/:studio', + '/subbed-anime', + '/dubbed-anime', + '/movie', + '/tv', + '/ova', + '/ona', + '/special', + '/genres', + '/genre/:genre', + '/schedule', + '/spotlight', + '/search-suggestions/:query', + ], + documentation: 'https://docs.consumet.org/#tag/hianime', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const query = (request.params as { query: string }).query; + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:search:${query}:${page}`, + async () => await hianime.search(query, page), + REDIS_TTL, + ) + : await hianime.search(query, page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.query as { id: string }).id; + + if (typeof id === 'undefined') + return reply.status(400).send({ message: 'id is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:info:${id}`, + async () => await hianime.fetchAnimeInfo(id), + REDIS_TTL, + ) + : await hianime.fetchAnimeInfo(id); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get( + '/watch/:episodeId', + async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.params as { episodeId: string }).episodeId; + const server = (request.query as { server: StreamingServers }).server; + const category = (request.query as { category: SubOrSub }).category; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:watch:${episodeId}:${server}:${category}`, + async () => await hianime.fetchEpisodeSources(episodeId, server, category), + REDIS_TTL, + ) + : await hianime.fetchEpisodeSources(episodeId, server, category); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }, + ); + + fastify.get('/genres', async (request: FastifyRequest, reply: FastifyReply) => { + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:genres`, + async () => await hianime.fetchGenres(), + REDIS_TTL, + ) + : await hianime.fetchGenres(); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/schedule', async (request: FastifyRequest, reply: FastifyReply) => { + const date = (request.query as { date: string }).date; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:schedule:${date}`, + async () => await hianime.fetchSchedule(date), + REDIS_TTL, + ) + : await hianime.fetchSchedule(date); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/spotlight', async (request: FastifyRequest, reply: FastifyReply) => { + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:spotlight`, + async () => await hianime.fetchSpotlight(), + REDIS_TTL, + ) + : await hianime.fetchSpotlight(); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get( + '/search-suggestions/:query', + async (request: FastifyRequest, reply: FastifyReply) => { + const query = (request.params as { query: string }).query; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:suggestions:${query}`, + async () => await hianime.fetchSearchSuggestions(query), + REDIS_TTL, + ) + : await hianime.fetchSearchSuggestions(query); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }, + ); + + fastify.get( + '/advanced-search', + async (request: FastifyRequest, reply: FastifyReply) => { + const queryParams = request.query as { + page?: number; + type?: string; + status?: string; + rated?: string; + score?: number; + season?: string; + language?: string; + startDate?: string; + endDate?: string; + sort?: string; + genres?: string; + }; + + const { + page = 1, + type, + status, + rated, + score, + season, + language, + startDate, + endDate, + sort, + genres, + } = queryParams; + + try { + // Explicitly typed to avoid implicit any errors + let parsedStartDate: { year: number; month: number; day: number } | undefined; + let parsedEndDate: { year: number; month: number; day: number } | undefined; + + if (startDate) { + const [year, month, day] = startDate.split('-').map(Number); + parsedStartDate = { year, month, day }; + } + if (endDate) { + const [year, month, day] = endDate.split('-').map(Number); + parsedEndDate = { year, month, day }; + } + + const genresArray = genres ? genres.split(',') : undefined; + + // Create a unique key based on all parameters + const cacheKey = `hianime:advanced-search:${JSON.stringify(queryParams)}`; + + let res = redis + ? await cache.fetch( + redis as Redis, + cacheKey, + async () => + await hianime.fetchAdvancedSearch( + page, + type, + status, + rated, + score, + season, + language, + parsedStartDate, + parsedEndDate, + sort, + genresArray, + ), + REDIS_TTL, + ) + : await hianime.fetchAdvancedSearch( + page, + type, + status, + rated, + score, + season, + language, + parsedStartDate, + parsedEndDate, + sort, + genresArray, + ); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }, + ); + + fastify.get('/top-airing', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:top-airing:${page}`, + async () => await hianime.fetchTopAiring(page), + REDIS_TTL, + ) + : await hianime.fetchTopAiring(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/most-popular', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:most-popular:${page}`, + async () => await hianime.fetchMostPopular(page), + REDIS_TTL, + ) + : await hianime.fetchMostPopular(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/most-favorite', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:most-favorite:${page}`, + async () => await hianime.fetchMostFavorite(page), + REDIS_TTL, + ) + : await hianime.fetchMostFavorite(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get( + '/latest-completed', + async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:latest-completed:${page}`, + async () => await hianime.fetchLatestCompleted(page), + REDIS_TTL, + ) + : await hianime.fetchLatestCompleted(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }, + ); + + fastify.get( + '/recently-updated', + async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:recently-updated:${page}`, + async () => await hianime.fetchRecentlyUpdated(page), + REDIS_TTL, + ) + : await hianime.fetchRecentlyUpdated(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }, + ); + + fastify.get('/recently-added', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:recently-added:${page}`, + async () => await hianime.fetchRecentlyAdded(page), + REDIS_TTL, + ) + : await hianime.fetchRecentlyAdded(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/top-upcoming', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:top-upcoming:${page}`, + async () => await hianime.fetchTopUpcoming(page), + REDIS_TTL, + ) + : await hianime.fetchTopUpcoming(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/studio/:studio', async (request: FastifyRequest, reply: FastifyReply) => { + const studio = (request.params as { studio: string }).studio; + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:studio:${studio}:${page}`, + async () => await hianime.fetchStudio(studio, page), + REDIS_TTL, + ) + : await hianime.fetchStudio(studio, page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/subbed-anime', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:subbed:${page}`, + async () => await hianime.fetchSubbedAnime(page), + REDIS_TTL, + ) + : await hianime.fetchSubbedAnime(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/dubbed-anime', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:dubbed:${page}`, + async () => await hianime.fetchDubbedAnime(page), + REDIS_TTL, + ) + : await hianime.fetchDubbedAnime(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/movie', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:movie:${page}`, + async () => await hianime.fetchMovie(page), + REDIS_TTL, + ) + : await hianime.fetchMovie(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/tv', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:tv:${page}`, + async () => await hianime.fetchTV(page), + REDIS_TTL, + ) + : await hianime.fetchTV(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/ova', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:ova:${page}`, + async () => await hianime.fetchOVA(page), + REDIS_TTL, + ) + : await hianime.fetchOVA(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/ona', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:ona:${page}`, + async () => await hianime.fetchONA(page), + REDIS_TTL, + ) + : await hianime.fetchONA(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/special', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:special:${page}`, + async () => await hianime.fetchSpecial(page), + REDIS_TTL, + ) + : await hianime.fetchSpecial(page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/genre/:genre', async (request: FastifyRequest, reply: FastifyReply) => { + const genre = (request.params as { genre: string }).genre; + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `hianime:genre:${genre}:${page}`, + async () => await hianime.genreSearch(genre, page), + REDIS_TTL, + ) + : await hianime.genreSearch(genre, page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); +}; + +export default routes; diff --git a/src/routes/anime/index.ts b/src/routes/anime/index.ts index e6a2248b7..e788aad2e 100644 --- a/src/routes/anime/index.ts +++ b/src/routes/anime/index.ts @@ -1,12 +1,20 @@ import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; import { PROVIDERS_LIST } from '@consumet/extensions'; -import gogoanime from './gogoanime'; +import animeunity from './animeunity'; import animepahe from './animepahe'; +import hianime from './hianime'; +import animekai from './animekai'; +import animesaturn from './animesaturn'; +import kickassanime from './kickassanime'; const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { - await fastify.register(gogoanime, { prefix: '/' }); - await fastify.register(animepahe, { prefix: '/' }); + await fastify.register(animepahe, { prefix: '/animepahe' }); + await fastify.register(animeunity, { prefix: '/animeunity' }); + await fastify.register(hianime, { prefix: '/hianime' }); + await fastify.register(animekai, { prefix: '/animekai' }); + await fastify.register(animesaturn, { prefix: '/animesaturn' }); + await fastify.register(kickassanime, { prefix: '/kickassanime' }); fastify.get('/', async (request: any, reply: any) => { reply.status(200).send('Welcome to Consumet Anime 🗾'); @@ -19,7 +27,7 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { }; queries.animeProvider = decodeURIComponent( - (request.params as { animeProvider: string; page: number }).animeProvider + (request.params as { animeProvider: string; page: number }).animeProvider, ); queries.page = (request.query as { animeProvider: string; page: number }).page; @@ -27,7 +35,7 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { if (queries.page! < 1) queries.page = 1; const provider = PROVIDERS_LIST.ANIME.find( - (provider: any) => provider.toString.name === queries.animeProvider + (provider: any) => provider.toString.name === queries.animeProvider, ); try { diff --git a/src/routes/anime/kickassanime.ts b/src/routes/anime/kickassanime.ts new file mode 100644 index 000000000..bbce5a3fb --- /dev/null +++ b/src/routes/anime/kickassanime.ts @@ -0,0 +1,122 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { ANIME } from '@consumet/extensions'; +import { StreamingServers } from '@consumet/extensions/dist/models'; + +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + const kickassanime = new ANIME.KickAssAnime(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: `Welcome to the kickassanime provider: check out the provider's website @ ${kickassanime.toString.baseUrl}`, + routes: ['/:query', '/info', '/watch/:episodeId', '/servers/:episodeId'], + documentation: 'https://docs.consumet.org/#tag/kickassanime', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const query = (request.params as { query: string }).query; + const page = (request.query as { page: number }).page; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `kickassanime:search:${query}:${page}`, + async () => await kickassanime.search(query, page), + REDIS_TTL, + ) + : await kickassanime.search(query, page); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.query as { id: string }).id; + + if (typeof id === 'undefined') + return reply.status(400).send({ message: 'id is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `kickassanime:info:${id}`, + async () => await kickassanime.fetchAnimeInfo(id), + REDIS_TTL, + ) + : await kickassanime.fetchAnimeInfo(id); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get( + '/watch/:episodeId', + async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.params as { episodeId: string }).episodeId; + const server = (request.query as { server: StreamingServers }).server; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `kickassanime:watch:${episodeId}:${server}`, + async () => await kickassanime.fetchEpisodeSources(episodeId, server), + REDIS_TTL, + ) + : await kickassanime.fetchEpisodeSources(episodeId, server); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }, + ); + + fastify.get( + '/servers/:episodeId', + async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.params as { episodeId: string }).episodeId; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `kickassanime:servers:${episodeId}`, + async () => await kickassanime.fetchEpisodeServers(episodeId), + REDIS_TTL, + ) + : await kickassanime.fetchEpisodeServers(episodeId); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }, + ); +}; + +export default routes; diff --git a/src/routes/books/index.ts b/src/routes/books/index.ts index 6c5878080..913352a9f 100644 --- a/src/routes/books/index.ts +++ b/src/routes/books/index.ts @@ -1,36 +1,9 @@ -import { BOOKS } from '@consumet/extensions'; -import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { FastifyInstance, RegisterOptions } from 'fastify'; -import libgen from './libgen'; const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { - const lbgen = new BOOKS.Libgen(); - fastify.get('/', async (request: any, reply: any) => { reply.status(200).send('Welcome to Consumet Books 📚'); }); - - fastify.get('/s', async (request: FastifyRequest, reply: FastifyReply) => { - const { bookTitle, page } = request.query as { - bookTitle: string; - page: number; - }; - if (!bookTitle) - return reply.status(400).send({ - message: 'bookTitle query needed', - error: 'invalid_input', - }); - try { - const data = await lbgen.search(bookTitle, page); - return reply.status(200).send(data); - } catch (e) { - return reply.status(500).send({ - message: e, - error: 'internal_error', - }); - } - }); - - await fastify.register(libgen, { prefix: '/libgen' }); }; export default routes; diff --git a/src/routes/books/libgen.ts b/src/routes/books/libgen.ts deleted file mode 100644 index 1f598eb56..000000000 --- a/src/routes/books/libgen.ts +++ /dev/null @@ -1,41 +0,0 @@ -import { BOOKS } from '@consumet/extensions'; -import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; - -const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { - const libgen = new BOOKS.Libgen(); - - fastify.get('/', (_, rp) => { - rp.status(200).send({ - intro: - "Welcome to the libgen provider. check out the provider's website @ http://libgen.rs/", - routes: ['/s', '/fs'], - documentation: 'https://docs.consumet.org/#tag/libgen (needs to be updated)', - }); - }); - - fastify.get('/s', async (request: FastifyRequest, reply: FastifyReply) => { - const { bookTitle, page } = request.query as { - bookTitle: string; - page: number; - }; - if (bookTitle.length < 4) - return reply.status(400).send({ - message: 'length of bookTItle must be > 4 characters', - error: 'short_length', - }); - if (isNaN(page)) { - return reply.status(400).send({ - message: 'page number is valid', - error: 'invalid_input', - }); - } - try { - const data = await libgen.search(bookTitle, page); - return reply.status(200).send(data); - } catch (e) { - return reply.status(400).send(e); - } - }); -}; - -export default routes; diff --git a/src/routes/comics/getComics.ts b/src/routes/comics/getComics.ts index 575fed70e..4f0ee663a 100644 --- a/src/routes/comics/getComics.ts +++ b/src/routes/comics/getComics.ts @@ -1,39 +1,47 @@ -import { COMICS } from '@consumet/extensions'; import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { COMICS } from '@consumet/extensions'; + +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { - fastify.get('/s', async (request: FastifyRequest, reply: FastifyReply) => { - const { comicTitle, page } = request.query as { - comicTitle: string; - page: number | undefined; - }; - if (comicTitle.length < 4) + const getComics = new COMICS.GetComics(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: `Welcome to the getComics provider: check out the provider's website @ ${getComics.toString.baseUrl}`, + routes: ['/:query'], + documentation: 'https://docs.consumet.org/#tag/getComics', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const { comicTitle } = request.query as { comicTitle: string }; + const page = (request.query as { page: number }).page || 1; + + if (!comicTitle || comicTitle.length < 4) return reply.status(400).send({ - message: 'length of comicTitle must be > 4 charactes', + message: 'length of comicTitle must be > 4 characters', error: 'short_length', }); - const getComics = new COMICS.GetComics(); - const result = await getComics - .search(comicTitle, page == undefined ? 1 : page) - .catch((err) => { - return reply.status(400).send({ - // temp - message: 'page query must be defined', - error: 'invalid_input', - // temp - }); - }); - return reply.status(200).send(result); - }); + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `getcomics:search:${comicTitle}:${page}`, + async () => await getComics.search(comicTitle, page), + REDIS_TTL, + ) + : await getComics.search(comicTitle, page); - fastify.get('/', (_, rp) => { - rp.status(200).send({ - intro: - "Welcome to the getComics provider: check out the provider's website @ https://getcomics.info/", - routes: ['/s'], - documentation: 'https://docs.consumet.org/#tag/getComics (need to be updated)', - }); + return reply.status(200).send(res); + } catch (err) { + return reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } }); }; diff --git a/src/routes/comics/index.ts b/src/routes/comics/index.ts index 4bd8afa55..f245d89a6 100644 --- a/src/routes/comics/index.ts +++ b/src/routes/comics/index.ts @@ -1,8 +1,9 @@ import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; -import getComics from './getComics'; + +import getcomics from './getComics'; const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { - await fastify.register(getComics, { prefix: '/getComics' }); + await fastify.register(getcomics, { prefix: '/getcomics' }); fastify.get('/', async (request: FastifyRequest, reply: FastifyReply) => { reply.status(200).send('Welcome to Consumet Comics đŸĻ¸â€â™‚ī¸'); @@ -10,7 +11,7 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { fastify.get('/s', async (request: FastifyRequest, reply: FastifyReply) => { const { comicTitle, page } = request.query as { comicTitle: string; page: number }; - reply.status(300).redirect(`getComics/s?comicTitle=${comicTitle}&page=${page}`); + reply.status(300).redirect(`getcomics/s?comicTitle=${comicTitle}&page=${page}`); }); }; diff --git a/src/routes/light-novels/index.ts b/src/routes/light-novels/index.ts index 8244203cb..c041500a8 100644 --- a/src/routes/light-novels/index.ts +++ b/src/routes/light-novels/index.ts @@ -1,49 +1,9 @@ -import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; -import { PROVIDERS_LIST } from '@consumet/extensions'; - -import readlightnovels from './readlightnovels'; +import { FastifyInstance, RegisterOptions } from 'fastify'; const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { - await fastify.register(readlightnovels, { prefix: '/' }); - fastify.get('/', async (request: any, reply: any) => { reply.status(200).send('Welcome to Consumet Light Novels'); }); - - fastify.get( - '/:lightNovelProvider', - async (request: FastifyRequest, reply: FastifyReply) => { - const queries: { lightNovelProvider: string; page: number } = { - lightNovelProvider: '', - page: 1, - }; - - queries.lightNovelProvider = decodeURIComponent( - (request.params as { lightNovelProvider: string; page: number }) - .lightNovelProvider - ); - - queries.page = (request.query as { lightNovelProvider: string; page: number }).page; - - if (queries.page! < 1) queries.page = 1; - - const provider = PROVIDERS_LIST.LIGHT_NOVELS.find( - (provider: any) => provider.toString.name === queries.lightNovelProvider - ); - - try { - if (provider) { - reply.redirect(`/light-novels/${provider.toString.name}`); - } else { - reply - .status(404) - .send({ message: 'Page not found, please check the providers list.' }); - } - } catch (err) { - reply.status(500).send('Something went wrong. Please try again later.'); - } - } - ); }; export default routes; diff --git a/src/routes/light-novels/readlightnovels.ts b/src/routes/light-novels/readlightnovels.ts deleted file mode 100644 index 47da7ecb9..000000000 --- a/src/routes/light-novels/readlightnovels.ts +++ /dev/null @@ -1,79 +0,0 @@ -import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; -import { LIGHT_NOVELS } from '@consumet/extensions'; - -const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { - const readlightnovels = new LIGHT_NOVELS.ReadLightNovels(); - - fastify.get('/readlightnovels', (_, rp) => { - rp.status(200).send({ - intro: - "Welcome to the readlightnovels provider: check out the provider's website @ https://readlightnovels.net/", - routes: ['/:query', '/info', '/read'], - documentation: 'https://docs.consumet.org/#tag/readlightnovels', - }); - }); - - fastify.get( - '/readlightnovels/:query', - async (request: FastifyRequest, reply: FastifyReply) => { - const query = (request.params as { query: string }).query; - - const res = await readlightnovels.search(query); - - reply.status(200).send(res); - } - ); - - fastify.get( - '/readlightnovels/info', - async (request: FastifyRequest, reply: FastifyReply) => { - const id = (request.query as { id: string }).id; - const chapterPage = (request.query as { chapterPage: number }).chapterPage; - - if (typeof id === 'undefined') { - return reply.status(400).send({ - message: 'id is required', - }); - } - - try { - const res = await readlightnovels - .fetchLightNovelInfo(id, chapterPage) - .catch((err) => reply.status(404).send({ message: err })); - - reply.status(200).send(res); - } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Please try again later.' }); - } - } - ); - - fastify.get( - '/readlightnovels/read', - async (request: FastifyRequest, reply: FastifyReply) => { - const chapterId = (request.query as { chapterId: string }).chapterId; - - if (typeof chapterId === 'undefined') { - return reply.status(400).send({ - message: 'chapterId is required', - }); - } - - try { - const res = await readlightnovels - .fetchChapterContent(chapterId) - .catch((err) => reply.status(404).send(err)); - - reply.status(200).send(res); - } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Please try again later.' }); - } - } - ); -}; - -export default routes; diff --git a/src/routes/manga/index.ts b/src/routes/manga/index.ts index 818e83dec..744861ed2 100644 --- a/src/routes/manga/index.ts +++ b/src/routes/manga/index.ts @@ -1,15 +1,22 @@ import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; import { PROVIDERS_LIST } from '@consumet/extensions'; - +import mangapill from './mangapill'; +import managreader from './managreader'; import mangadex from './mangadex'; +import mangakakalot from './mangakakalot'; import mangahere from './mangahere'; const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { - await fastify.register(mangadex, { prefix: '/' }); - await fastify.register(mangahere, { prefix: '/' }); + await fastify.register(mangadex, { prefix: '/mangadex' }); + await fastify.register(mangahere, { prefix: '/mangahere' }); + await fastify.register(mangapill, { prefix: '/mangapill' }); + await fastify.register(mangakakalot, { prefix: '/mangakakalot' }); + await fastify.register(managreader, { prefix: '/managreader' }); fastify.get('/', async (request: any, reply: any) => { - reply.status(200).send('Welcome to Consumet Manga'); + reply.status(200).send('Welcome to Consumet Manga our available providers are: ' + + PROVIDERS_LIST.MANGA.map((provider: any) => provider.toString.name).join(', ')); + }); fastify.get('/:mangaProvider', async (request: FastifyRequest, reply: FastifyReply) => { @@ -19,7 +26,7 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { }; queries.mangaProvider = decodeURIComponent( - (request.params as { mangaProvider: string; page: number }).mangaProvider + (request.params as { mangaProvider: string; page: number }).mangaProvider, ); queries.page = (request.query as { mangaProvider: string; page: number }).page; @@ -27,7 +34,7 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { if (queries.page! < 1) queries.page = 1; const provider = PROVIDERS_LIST.MANGA.find( - (provider: any) => provider.toString.name === queries.mangaProvider + (provider: any) => provider.toString.name === queries.mangaProvider, ); try { diff --git a/src/routes/manga/managreader.ts b/src/routes/manga/managreader.ts new file mode 100644 index 000000000..2a761789a --- /dev/null +++ b/src/routes/manga/managreader.ts @@ -0,0 +1,89 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { MANGA } from '@consumet/extensions'; + +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + const managreader = new MANGA.MangaReader(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: `Welcome to the Mangapill provider: check out the provider's website @ ${managreader.toString.baseUrl}`, + routes: ['/:query', '/info', '/read'], + documentation: 'https://docs.consumet.org/#tag/mangapill', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const query = (request.params as { query: string }).query; + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `mangareader:search:${query}`, + async () => await managreader.search(query), + REDIS_TTL, + ) + : await managreader.search(query); + + reply.status(200).send(res); + } catch (err) { + reply.status(500).send({ + message: 'Something went wrong. Contact developer for help.', + }); + } + }); + + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.query as { id: string }).id; + + if (typeof id === 'undefined') + return reply.status(400).send({ message: 'id is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `mangareader:info:${id}`, + async () => await managreader.fetchMangaInfo(id), + REDIS_TTL, + ) + : await managreader.fetchMangaInfo(id); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); + + fastify.get('/read', async (request: FastifyRequest, reply: FastifyReply) => { + const chapterId = (request.query as { chapterId: string }).chapterId; + + if (typeof chapterId === 'undefined') + return reply.status(400).send({ message: 'chapterId is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `mangareader:read:${chapterId}`, + async () => await managreader.fetchChapterPages(chapterId), + REDIS_TTL, + ) + : await managreader.fetchChapterPages(chapterId); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }); +}; + +export default routes; diff --git a/src/routes/manga/mangadex.ts b/src/routes/manga/mangadex.ts index ee1bd6783..8e91a2629 100644 --- a/src/routes/manga/mangadex.ts +++ b/src/routes/manga/mangadex.ts @@ -1,67 +1,89 @@ import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; import { MANGA } from '@consumet/extensions'; +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { const mangadex = new MANGA.MangaDex(); - fastify.get('/mangadex', (_, rp) => { + fastify.get('/', (_, rp) => { rp.status(200).send({ - intro: - "Welcome to the mangadex provider: check out the provider's website @ https://mangadex.org/", + intro: `Welcome to the mangadex provider: check out the provider's website @ ${mangadex.toString.baseUrl}`, routes: ['/:query', '/info/:id', '/read/:chapterId'], documentation: 'https://docs.consumet.org/#tag/mangadex', }); }); - fastify.get( - '/mangadex/:query', - async (request: FastifyRequest, reply: FastifyReply) => { - const query = (request.params as { query: string }).query; - - const page = (request.query as { page: number }).page; + // --- SEARCH --- + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const { query } = request.params as { query: string }; + const { page } = request.query as { page?: number }; - const res = await mangadex.search(query, page); + try { + const res = redis + ? await cache.fetch( + redis as Redis, + `mangadex:search:${query}:${page ?? 1}`, + () => mangadex.search(query, page), + REDIS_TTL, + ) + : await mangadex.search(query, page); reply.status(200).send(res); + } catch (err) { + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + }); } - ); + }); - fastify.get( - '/mangadex/info/:id', - async (request: FastifyRequest, reply: FastifyReply) => { - const id = decodeURIComponent((request.params as { id: string }).id); + // --- INFO --- + fastify.get('/info/:id', async (request: FastifyRequest, reply: FastifyReply) => { + const id = decodeURIComponent((request.params as { id: string }).id); - try { - const res = await mangadex - .fetchMangaInfo(id) - .catch((err) => reply.status(404).send({ message: err })); + try { + const res = redis + ? await cache.fetch( + redis as Redis, + `mangadex:info:${id}`, + () => mangadex.fetchMangaInfo(id), + REDIS_TTL, + ) + : await mangadex.fetchMangaInfo(id); - reply.status(200).send(res); - } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Please try again later.' }); - } + reply.status(200).send(res); + } catch (err) { + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + }); } - ); + }); + // --- READ CHAPTER --- fastify.get( - '/mangadex/read/:chapterId', + '/read/:chapterId', async (request: FastifyRequest, reply: FastifyReply) => { - const chapterId = (request.params as { chapterId: string }).chapterId; + const { chapterId } = request.params as { chapterId: string }; try { - const res = await mangadex - .fetchChapterPages(chapterId) - .catch((err) => reply.status(404).send({ message: err })); + const res = redis + ? await cache.fetch( + redis as Redis, + `mangadex:read:${chapterId}`, + () => mangadex.fetchChapterPages(chapterId), + REDIS_TTL, + ) + : await mangadex.fetchChapterPages(chapterId); reply.status(200).send(res); } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Please try again later.' }); + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + }); } - } + }, ); }; diff --git a/src/routes/manga/mangahere.ts b/src/routes/manga/mangahere.ts index d06f60be4..6759f248c 100644 --- a/src/routes/manga/mangahere.ts +++ b/src/routes/manga/mangahere.ts @@ -1,10 +1,14 @@ import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; -import { MANGA } from 'consumet.ts'; +import { MANGA } from '@consumet/extensions'; + +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { const mangahere = new MANGA.MangaHere(); - fastify.get('/mangahere', (_, rp) => { + fastify.get('/', (_, rp) => { rp.status(200).send({ intro: `Welcome to the MangaHere provider: check out the provider's website @ ${mangahere.toString.baseUrl}`, routes: ['/:query', '/info', '/read'], @@ -12,54 +16,71 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { }); }); - fastify.get( - '/mangahere/:query', - async (request: FastifyRequest, reply: FastifyReply) => { - const query = (request.params as { query: string }).query; - - const page = (request.query as { page: number }).page; + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const { query } = request.params as { query: string }; + const { page } = request.query as { page?: number }; - const res = await mangahere.search(query, page); + try { + const res = redis + ? await cache.fetch( + redis as Redis, + `mangahere:search:${query}:${page ?? 1}`, + () => mangahere.search(query, page), + REDIS_TTL, + ) + : await mangahere.search(query, page); reply.status(200).send(res); + } catch (err) { + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + }); } - ); + }); - fastify.get('/mangahere/info', async (request: FastifyRequest, reply: FastifyReply) => { + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { const id = (request.query as { id: string }).id; - if (typeof id === 'undefined') - return reply.status(400).send({ message: 'id is required' }); + if (!id) return reply.status(400).send({ message: 'id is required' }); try { - const res = await mangahere - .fetchMangaInfo(id) - .catch((err) => reply.status(404).send({ message: err })); + const res = redis + ? await cache.fetch( + redis as Redis, + `mangahere:info:${id}`, + () => mangahere.fetchMangaInfo(id), + REDIS_TTL, + ) + : await mangahere.fetchMangaInfo(id); reply.status(200).send(res); } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Please try again later.' }); + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + }); } }); - fastify.get('/mangahere/read', async (request: FastifyRequest, reply: FastifyReply) => { + fastify.get('/read', async (request: FastifyRequest, reply: FastifyReply) => { const chapterId = (request.query as { chapterId: string }).chapterId; - if (typeof chapterId === 'undefined') - return reply.status(400).send({ message: 'chapterId is required' }); + if (!chapterId) return reply.status(400).send({ message: 'chapterId is required' }); try { - const res = await mangahere - .fetchChapterPages(chapterId) - .catch((err: Error) => reply.status(404).send({ message: err.message })); + const res = redis + ? await cache.fetch( + redis as Redis, + `mangahere:read:${chapterId}`, + () => mangahere.fetchChapterPages(chapterId), + REDIS_TTL, + ) + : await mangahere.fetchChapterPages(chapterId); reply.status(200).send(res); } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Please try again later.' }); + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + }); } }); }; diff --git a/src/routes/manga/mangakakalot.ts b/src/routes/manga/mangakakalot.ts new file mode 100644 index 000000000..23046aa53 --- /dev/null +++ b/src/routes/manga/mangakakalot.ts @@ -0,0 +1,240 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { MANGA } from '@consumet/extensions'; + +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + const mangakakalot = new MANGA.MangaKakalot(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: `Welcome to the Mangakakalot provider: check out the provider's website @ ${mangakakalot.toString.baseUrl}`, + routes: { + '/:query': { + description: 'Search for manga by title', + example: '/manga/mangakakalot/naruto', + parameters: { + query: '(path) - The manga title to search for', + page: '(query, optional) - Page number for pagination. Default: 1', + }, + exampleWithPage: '/manga/mangakakalot/naruto?page=2', + }, + '/info': { + description: 'Get detailed information about a specific manga', + example: '/manga/mangakakalot/info?id=naruto', + parameters: { + id: '(query, required) - The manga ID from search results', + }, + }, + '/read': { + description: 'Get chapter pages/images for reading', + example: '/manga/mangakakalot/read?chapterId=naruto/chapter-700-5', + parameters: { + chapterId: '(query, required) - The chapter ID in format "mangaId/chapterId"', + }, + }, + '/latestmanga': { + description: 'Get the latest manga updates', + example: '/manga/mangakakalot/latestmanga', + parameters: { + page: '(query, optional) - Page number for pagination. Default: 1', + }, + exampleWithPage: '/manga/mangakakalot/latestmanga?page=2', + }, + '/suggestions': { + description: 'Get autocomplete suggestions for dropdown menu while typing', + example: '/manga/mangakakalot/suggestions?query=one piece', + parameters: { + query: '(query, required) - The search term for autocomplete dropdown', + }, + hint: 'Use this for implementing search dropdown/autocomplete in your UI', + }, + '/bygenre': { + description: 'Get manga filtered by genre', + example: '/manga/mangakakalot/bygenre?genre=action', + parameters: { + genre: '(query, required) - Genre slug (e.g., action, romance, comedy)', + page: '(query, optional) - Page number for pagination. Default: 1', + }, + exampleWithPage: '/manga/mangakakalot/bygenre?genre=action&page=2', + }, + }, + documentation: 'https://docs.consumet.org/#tag/mangakakalot', + }); + }); + + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.query as { id: string }).id; + + if (!id) + return reply.status(400).send({ + message: 'id is required', + error: 'Missing required query parameter: id', + example: '/manga/mangakakalot/info?id=naruto', + hint: 'Get the manga ID from search results using /:query or /latestmanga', + }); + + try { + const res = redis + ? await cache.fetch( + redis as Redis, + `mangakakalot:info:${id}`, + () => mangakakalot.fetchMangaInfo(id), + REDIS_TTL, + ) + : await mangakakalot.fetchMangaInfo(id); + + reply.status(200).send(res); + } catch { + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + error: 'Failed to fetch manga info', + hint: 'Make sure the manga ID is valid and exists', + }); + } + }); + + fastify.get('/read', async (request: FastifyRequest, reply: FastifyReply) => { + const chapterId = (request.query as { chapterId: string }).chapterId; + + if (!chapterId) + return reply.status(400).send({ + message: 'chapterId is required', + error: 'Missing required query parameter: chapterId', + example: '/manga/mangakakalot/read?chapterId=naruto/chapter-700-5', + hint: 'Get the chapter ID from /info endpoint. Format: "mangaId/chapterId"', + }); + + try { + const res = redis + ? await cache.fetch( + redis as Redis, + `mangakakalot:read:${chapterId}`, + () => mangakakalot.fetchChapterPages(chapterId), + REDIS_TTL, + ) + : await mangakakalot.fetchChapterPages(chapterId); + + reply.status(200).send(res); + } catch { + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + error: 'Failed to fetch chapter pages', + hint: 'Make sure the chapter ID is valid and in correct format: "mangaId/chapterId"', + }); + } + }); + + fastify.get('/latestmanga', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page || 1; + + try { + const res = redis + ? await cache.fetch( + redis as Redis, + `mangakakalot:latestmanga:${page}`, + () => mangakakalot.fetchLatestUpdates(page), + REDIS_TTL, + ) + : await mangakakalot.fetchLatestUpdates(page); + + reply.status(200).send(res); + } catch { + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + error: 'Failed to fetch latest manga updates', + hint: 'Try again later or check if the page number is valid', + }); + } + }); + + fastify.get('/bygenre', async (request: FastifyRequest, reply: FastifyReply) => { + const genre = (request.query as { genre: string }).genre; + const page = (request.query as { page: number }).page || 1; + + if (!genre) + return reply.status(400).send({ + message: 'genre is required', + error: 'Missing required query parameter: genre', + example: '/manga/mangakakalot/bygenre?genre=action', + hint: 'Use genre slugs like: action, romance, comedy, fantasy, horror, etc.', + }); + + try { + const res = redis + ? await cache.fetch( + redis as Redis, + `mangakakalot:bygenre:${genre}:${page}`, + () => mangakakalot.fetchByGenre(genre, page), + REDIS_TTL, + ) + : await mangakakalot.fetchByGenre(genre, page); + + reply.status(200).send(res); + } catch { + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + error: 'Failed to fetch manga by genre', + hint: 'Make sure the genre slug is valid (e.g., action, romance, comedy)', + }); + } + }); + + fastify.get('/suggestions', async (request: FastifyRequest, reply: FastifyReply) => { + const query = (request.query as { query: string }).query; + + if (!query) + return reply.status(400).send({ + message: 'query is required', + error: 'Missing required query parameter: query', + example: '/manga/mangakakalot/suggestions?query=naruto', + hint: 'Provide a search term for autocomplete suggestions', + }); + + try { + const res = redis + ? await cache.fetch( + redis as Redis, + `mangakakalot:suggestions:${query}`, + () => mangakakalot.fetchSuggestions(query), + REDIS_TTL, + ) + : await mangakakalot.fetchSuggestions(query); + + reply.status(200).send(res); + } catch { + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + error: 'Failed to fetch suggestions', + hint: 'Try again with a different search term', + }); + } + }); + + // This parametric route MUST be last to avoid catching static routes like /info, /read, etc. + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const { query } = request.params as { query: string }; + const page = (request.query as { page: number }).page || 1; + try { + const res = redis + ? await cache.fetch( + redis as Redis, + `mangakakalot:search:${query}:${page}`, + () => mangakakalot.search(query, page), + REDIS_TTL, + ) + : await mangakakalot.search(query, page); + reply.status(200).send(res); + } catch { + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + error: 'Failed to search for manga', + hint: 'Try again with a different search query', + }); + } + }); +}; + +export default routes; diff --git a/src/routes/manga/mangapill.ts b/src/routes/manga/mangapill.ts new file mode 100644 index 000000000..fa0733f34 --- /dev/null +++ b/src/routes/manga/mangapill.ts @@ -0,0 +1,87 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { MANGA } from '@consumet/extensions'; + +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + const mangapill = new MANGA.MangaPill(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: `Welcome to the Mangapill provider: check out the provider's website @ ${mangapill.toString.baseUrl}`, + routes: ['/:query', '/info', '/read'], + documentation: 'https://docs.consumet.org/#tag/mangapill', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const { query } = request.params as { query: string }; + + try { + const res = redis + ? await cache.fetch( + redis as Redis, + `mangapill:search:${query}`, + () => mangapill.search(query), + REDIS_TTL, + ) + : await mangapill.search(query); + + reply.status(200).send(res); + } catch { + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + }); + } + }); + + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.query as { id: string }).id; + + if (!id) return reply.status(400).send({ message: 'id is required' }); + + try { + const res = redis + ? await cache.fetch( + redis as Redis, + `mangapill:info:${id}`, + () => mangapill.fetchMangaInfo(id), + REDIS_TTL, + ) + : await mangapill.fetchMangaInfo(id); + + reply.status(200).send(res); + } catch { + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + }); + } + }); + + fastify.get('/read', async (request: FastifyRequest, reply: FastifyReply) => { + const chapterId = (request.query as { chapterId: string }).chapterId; + + if (!chapterId) return reply.status(400).send({ message: 'chapterId is required' }); + + try { + const res = redis + ? await cache.fetch( + redis as Redis, + `mangapill:read:${chapterId}`, + () => mangapill.fetchChapterPages(chapterId), + REDIS_TTL, + ) + : await mangapill.fetchChapterPages(chapterId); + + reply.status(200).send(res); + } catch { + reply.status(500).send({ + message: 'Something went wrong. Please try again later.', + }); + } + }); +}; + +export default routes; diff --git a/src/routes/meta/anilist-manga.ts b/src/routes/meta/anilist-manga.ts new file mode 100644 index 000000000..cffff3ee3 --- /dev/null +++ b/src/routes/meta/anilist-manga.ts @@ -0,0 +1,109 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { META } from '@consumet/extensions'; +import { PROVIDERS_LIST } from '@consumet/extensions'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + let anilist = new META.Anilist.Manga(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: `Welcome to the anilist manga provider: check out the provider's website @ ${anilist.provider.toString.baseUrl}`, + routes: ['/:query', '/info', '/read'], + documentation: 'https://docs.consumet.org/#tag/anilist', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const query = (request.params as { query: string }).query; + + const res = await anilist.search(query); + + reply.status(200).send(res); + }); + + fastify.get('/info/:id', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.params as { id: string }).id; + const provider = (request.query as { provider: string }).provider; + + if (typeof provider !== 'undefined') { + const possibleProvider = PROVIDERS_LIST.MANGA.find( + (p) => p.name.toLowerCase() === provider.toLocaleLowerCase(), + ); + anilist = new META.Anilist.Manga(possibleProvider); + } + + if (typeof id === 'undefined') + return reply.status(400).send({ message: 'id is required' }); + + try { + const res = await anilist + .fetchMangaInfo(id) + .catch((err) => reply.status(404).send({ message: err })); + + reply.status(200).send(res); + anilist = new META.Anilist.Manga(); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Please try again later.' }); + } + }); + + fastify.get('/read', async (request: FastifyRequest, reply: FastifyReply) => { + const chapterId = (request.query as { chapterId: string }).chapterId; + const provider = (request.query as { provider: string }).provider; + + if (typeof provider !== 'undefined') { + const possibleProvider = PROVIDERS_LIST.MANGA.find( + (p) => p.name.toLowerCase() === provider.toLocaleLowerCase(), + ); + anilist = new META.Anilist.Manga(possibleProvider); + } + + if (typeof chapterId === 'undefined') + return reply.status(400).send({ message: 'chapterId is required' }); + + try { + const res = await anilist + .fetchChapterPages(chapterId) + .catch((err: Error) => reply.status(404).send({ message: err.message })); + + anilist = new META.Anilist.Manga(); + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Please try again later.' }); + } + }); + + fastify.get('/chapters/:id', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.params as { id: string }).id; + const provider = (request.query as { provider: string }).provider; + + if (typeof provider !== 'undefined') { + const possibleProvider = PROVIDERS_LIST.MANGA.find( + (p) => p.name.toLowerCase() === provider.toLocaleLowerCase(), + ); + anilist = new META.Anilist.Manga(possibleProvider); + } + + if (typeof id === 'undefined') + return reply.status(400).send({ message: 'id is required' }); + + try { + const res = await anilist + .fetchChaptersList(id) + .catch((err: Error) => reply.status(404).send({ message: err.message })); + + anilist = new META.Anilist.Manga(); + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Please try again later.' }); + } + }); +}; + +export default routes; diff --git a/src/routes/meta/anilist.ts b/src/routes/meta/anilist.ts index 6a74aa79d..607137896 100644 --- a/src/routes/meta/anilist.ts +++ b/src/routes/meta/anilist.ts @@ -1,10 +1,17 @@ +import { Redis } from 'ioredis'; import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; import { META } from '@consumet/extensions'; +import { Genres, SubOrSub } from '@consumet/extensions/dist/models'; +import Anilist from '@consumet/extensions/dist/providers/meta/anilist'; +import { StreamingServers } from '@consumet/extensions/dist/models'; -const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { - const anilist = new META.Anilist(); +import cache from '../../utils/cache'; +import { redis } from '../../main'; +import Hianime from '@consumet/extensions/dist/providers/anime/hianime'; +import Providers from '../../utils/providers'; - fastify.get('/anilist', (_, rp) => { +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + fastify.get('/', (_, rp) => { rp.status(200).send({ intro: "Welcome to the anilist provider: check out the provider's website @ https://anilist.co/", @@ -13,53 +20,398 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { }); }); - fastify.get('/anilist/:query', async (request: FastifyRequest, reply: FastifyReply) => { + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const anilist = generateAnilistMeta(); + const query = (request.params as { query: string }).query; - const res = await anilist.search(query); + const page = (request.query as { page: number }).page; + const perPage = (request.query as { perPage: number }).perPage; + + const res = await anilist.search(query, page, perPage); reply.status(200).send(res); }); fastify.get( - '/anilist/info/:id', + '/advanced-search', async (request: FastifyRequest, reply: FastifyReply) => { - const id = decodeURIComponent((request.params as { id: string }).id); + const query = (request.query as { query: string }).query; + const page = (request.query as { page: number }).page; + const perPage = (request.query as { perPage: number }).perPage; + const type = (request.query as { type: string }).type; + let genres = (request.query as { genres: string | string[] }).genres; + const id = (request.query as { id: string }).id; + const format = (request.query as { format: string }).format; + let sort = (request.query as { sort: string | string[] }).sort; + const status = (request.query as { status: string }).status; + const year = (request.query as { year: number }).year; + const season = (request.query as { season: string }).season; + const countryOfOrigin = (request.query as {countryOfOrigin: string}).countryOfOrigin - const isDub = (request.query as { dub?: boolean }).dub; + const anilist = generateAnilistMeta(); - try { - const res = await anilist - .fetchAnimeInfo(id, isDub) - .catch((err) => reply.status(404).send({ message: err })); + if (genres) { + JSON.parse(genres as string).forEach((genre: string) => { + if (!Object.values(Genres).includes(genre as Genres)) { + return reply.status(400).send({ message: `${genre} is not a valid genre` }); + } + }); - reply.status(200).send(res); - } catch (err) { - reply - .status(500) - .send({ message: 'Something went wrong. Contact developer for help.' }); + genres = JSON.parse(genres as string); } - } + + if (sort) sort = JSON.parse(sort as string); + + if (season) + if (!['WINTER', 'SPRING', 'SUMMER', 'FALL'].includes(season)) + return reply.status(400).send({ message: `${season} is not a valid season` }); + + const res = await anilist.advancedSearch( + query, + type, + page, + perPage, + format, + sort as string[], + genres as string[], + id, + year, + status, + season, + countryOfOrigin + ); + + reply.status(200).send(res); + }, ); + fastify.get('/trending', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + const perPage = (request.query as { perPage: number }).perPage; + + const anilist = generateAnilistMeta(); + + redis + ? reply + .status(200) + .send( + await cache.fetch( + redis as Redis, + `anilist:trending;${page};${perPage}`, + async () => await anilist.fetchTrendingAnime(page, perPage), + 60 * 60, + ), + ) + : reply.status(200).send(await anilist.fetchTrendingAnime(page, perPage)); + }); + + fastify.get('/popular', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + const perPage = (request.query as { perPage: number }).perPage; + + const anilist = generateAnilistMeta(); + + redis + ? reply + .status(200) + .send( + await cache.fetch( + redis as Redis, + `anilist:popular;${page};${perPage}`, + async () => await anilist.fetchPopularAnime(page, perPage), + 60 * 60, + ), + ) + : reply.status(200).send(await anilist.fetchPopularAnime(page, perPage)); + }); + fastify.get( - '/anilist/watch/:episodeId', + '/airing-schedule', + async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + const perPage = (request.query as { perPage: number }).perPage; + const weekStart = (request.query as { weekStart: number | string }).weekStart; + const weekEnd = (request.query as { weekEnd: number | string }).weekEnd; + const notYetAired = (request.query as { notYetAired: boolean }).notYetAired; + + const anilist = generateAnilistMeta(); + const _weekStart = Math.ceil(Date.now() / 1000); + + const res = await anilist.fetchAiringSchedule( + page ?? 1, + perPage ?? 20, + weekStart ?? _weekStart, + weekEnd ?? _weekStart + 604800, + notYetAired ?? true, + ); + + reply.status(200).send(res); + }, + ); + + fastify.get('/genre', async (request: FastifyRequest, reply: FastifyReply) => { + const genres = (request.query as { genres: string }).genres; + const page = (request.query as { page: number }).page; + const perPage = (request.query as { perPage: number }).perPage; + + const anilist = generateAnilistMeta(); + + if (typeof genres === 'undefined') + return reply.status(400).send({ message: 'genres is required' }); + + JSON.parse(genres).forEach((genre: string) => { + if (!Object.values(Genres).includes(genre as Genres)) { + return reply.status(400).send({ message: `${genre} is not a valid genre` }); + } + }); + + const res = await anilist.fetchAnimeGenres(JSON.parse(genres), page, perPage); + + reply.status(200).send(res); + }); + + (fastify.get( + '/recent-episodes', + async (request: FastifyRequest, reply: FastifyReply) => { + const provider = (request.query as { provider: 'Hianime' }).provider; + const page = (request.query as { page: number }).page; + const perPage = (request.query as { perPage: number }).perPage; + + const anilist = generateAnilistMeta(provider); + + const res = await anilist.fetchRecentEpisodes(provider, page, perPage); + + reply.status(200).send(res); + }, + ), + fastify.get('/random-anime', async (request: FastifyRequest, reply: FastifyReply) => { + const anilist = generateAnilistMeta(); + + const res = await anilist.fetchRandomAnime().catch((err) => { + return reply.status(404).send({ message: 'Anime not found' }); + }); + reply.status(200).send(res); + })); + + fastify.get('/servers/:id', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.params as { id: string }).id; + const provider = (request.query as { provider?: string }).provider; + + let anilist = generateAnilistMeta(provider); + + const res = await anilist.fetchEpisodeServers(id); + + anilist = new META.Anilist(); + reply.status(200).send(res); + }); + + fastify.get('/episodes/:id', async (request: FastifyRequest, reply: FastifyReply) => { + const today = new Date(); + const dayOfWeek = today.getDay(); + const id = (request.params as { id: string }).id; + const provider = (request.query as { provider?: string }).provider; + let fetchFiller = (request.query as { fetchFiller?: string | boolean }).fetchFiller; + let dub = (request.query as { dub?: string | boolean }).dub; + const locale = (request.query as { locale?: string }).locale; + + let anilist = generateAnilistMeta(provider); + + if (dub === 'true' || dub === '1') dub = true; + else dub = false; + + if (fetchFiller === 'true' || fetchFiller === '1') fetchFiller = true; + else fetchFiller = false; + + try { + redis + ? reply + .status(200) + .send( + await cache.fetch( + redis, + `anilist:episodes;${id};${dub};${fetchFiller};${anilist.provider.name.toLowerCase()}`, + async () => + anilist.fetchEpisodesListById( + id, + dub as boolean, + fetchFiller as boolean, + ), + dayOfWeek === 0 || dayOfWeek === 6 ? 60 * 120 : (60 * 60) / 2, + ), + ) + : reply + .status(200) + .send(await anilist.fetchEpisodesListById(id, dub, fetchFiller as boolean)); + } catch (err) { + return reply.status(404).send({ message: 'Anime not found' }); + } + }); + + // anilist info without episodes + fastify.get('/data/:id', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.params as { id: string }).id; + + const anilist = generateAnilistMeta(); + const res = await anilist.fetchAnilistInfoById(id); + + reply.status(200).send(res); + }); + + // anilist info with episodes + fastify.get('/info/:id', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.params as { id: string }).id; + const today = new Date(); + const dayOfWeek = today.getDay(); + const provider = (request.query as { provider?: string }).provider; + let fetchFiller = (request.query as { fetchFiller?: string | boolean }).fetchFiller; + let isDub = (request.query as { dub?: string | boolean }).dub; + const locale = (request.query as { locale?: string }).locale; + + let anilist = generateAnilistMeta(provider); + + if (isDub === 'true' || isDub === '1') isDub = true; + else isDub = false; + + if (fetchFiller === 'true' || fetchFiller === '1') fetchFiller = true; + else fetchFiller = false; + + try { + redis + ? reply + .status(200) + .send( + await cache.fetch( + redis, + `anilist:info;${id};${isDub};${fetchFiller};${anilist.provider.name.toLowerCase()}`, + async () => + anilist.fetchAnimeInfo(id, isDub as boolean, fetchFiller as boolean), + dayOfWeek === 0 || dayOfWeek === 6 ? 60 * 120 : (60 * 60) / 2, + ), + ) + : reply + .status(200) + .send( + await anilist.fetchAnimeInfo(id, isDub as boolean, fetchFiller as boolean), + ); + } catch (err: any) { + reply.status(500).send({ message: err.message }); + } + }); + + // anilist character info + fastify.get('/character/:id', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.params as { id: string }).id; + + const anilist = generateAnilistMeta(); + const res = await anilist.fetchCharacterInfoById(id); + + reply.status(200).send(res); + }); + + fastify.get( + '/watch/:episodeId', async (request: FastifyRequest, reply: FastifyReply) => { const episodeId = (request.params as { episodeId: string }).episodeId; + const provider = (request.query as { provider?: string }).provider; + const server = (request.query as { server?: StreamingServers }).server; + let isDub = (request.query as { dub?: string | boolean }).dub; + + if (server && !Object.values(StreamingServers).includes(server)) + return reply.status(400).send('Invalid server'); + + if (isDub === 'true' || isDub === '1') isDub = true; + else isDub = false; + + let anilist = generateAnilistMeta(provider); try { - const res = await anilist - .fetchEpisodeSources(episodeId) - .catch((err) => reply.status(404).send({ message: err })); + redis + ? reply + .status(200) + .send( + await cache.fetch( + redis, + `anilist:watch;${episodeId};${anilist.provider.name.toLowerCase()};${server};${isDub ? 'dub' : 'sub'}`, + async () => + provider === 'zoro' || provider === 'animekai' + ? await anilist.fetchEpisodeSources( + episodeId, + server, + isDub ? SubOrSub.DUB : SubOrSub.SUB, + ) + : await anilist.fetchEpisodeSources(episodeId, server), + 600, + ), + ) + : reply + .status(200) + .send( + provider === 'zoro' || provider === 'animekai' + ? await anilist.fetchEpisodeSources( + episodeId, + server, + isDub ? SubOrSub.DUB : SubOrSub.SUB, + ) + : await anilist.fetchEpisodeSources(episodeId, server), + ); - reply.status(200).send(res); + anilist = new META.Anilist(undefined, { + url: process.env.PROXY as string | string[], + }); } catch (err) { reply .status(500) .send({ message: 'Something went wrong. Contact developer for help.' }); } - } + }, ); + + fastify.get('/staff/:id', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.params as { id: string }).id; + + const anilist = generateAnilistMeta(); + try { + redis + ? reply + .status(200) + .send( + await cache.fetch( + redis, + `anilist:staff;${id}`, + async () => await anilist.fetchStaffById(Number(id)), + 60 * 60, + ), + ) + : reply.status(200).send(await anilist.fetchStaffById(Number(id))); + } catch (err: any) { + reply.status(404).send({ message: err.message }); + } + }); + + fastify.get('/favorites', async (request: FastifyRequest, reply: FastifyReply) => { + const type = (request.query as {type?: "ANIME" | "MANGA" | "BOTH"}).type + const headers = request.headers as Record + + if (!headers.authorization) { + return reply.status(401).send({ message: 'Authorization header is required' }); + } + + const anilist = generateAnilistMeta(); + + try { + const res = await anilist.fetchFavoriteList(headers.authorization, type); + reply.status(200).send(res); + } catch (err: any) { + reply.status(500).send({ message: err.message }); + } + }); +}; + +const generateAnilistMeta = (provider: string | undefined = undefined): Anilist => { + return new Anilist(new Hianime(), { + url: process.env.PROXY as string | string[], + }); }; export default routes; diff --git a/src/routes/meta/index.ts b/src/routes/meta/index.ts index a4077b210..b50744951 100644 --- a/src/routes/meta/index.ts +++ b/src/routes/meta/index.ts @@ -2,9 +2,14 @@ import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from ' import { PROVIDERS_LIST } from '@consumet/extensions'; import anilist from './anilist'; - +import anilistManga from './anilist-manga'; +import mal from './mal'; +import tmdb from './tmdb'; const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { - await fastify.register(anilist, { prefix: '/' }); + await fastify.register(anilist, { prefix: '/anilist' }); + await fastify.register(anilistManga, { prefix: '/anilist-manga' }); + await fastify.register(mal, { prefix: '/mal' }); + await fastify.register(tmdb, { prefix: '/tmdb' }); fastify.get('/', async (request: any, reply: any) => { reply.status(200).send('Welcome to Consumet Meta'); @@ -17,7 +22,7 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { }; queries.metaProvider = decodeURIComponent( - (request.params as { metaProvider: string; page: number }).metaProvider + (request.params as { metaProvider: string; page: number }).metaProvider, ); queries.page = (request.query as { metaProvider: string; page: number }).page; @@ -25,7 +30,7 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { if (queries.page! < 1) queries.page = 1; const provider = PROVIDERS_LIST.META.find( - (provider: any) => provider.toString.name === queries.metaProvider + (provider: any) => provider.toString.name === queries.metaProvider, ); try { diff --git a/src/routes/meta/mal.ts b/src/routes/meta/mal.ts new file mode 100644 index 000000000..c85ba0322 --- /dev/null +++ b/src/routes/meta/mal.ts @@ -0,0 +1,89 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { META, PROVIDERS_LIST } from '@consumet/extensions'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + let mal = new META.Myanimelist(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: + "Welcome to the mal provider: check out the provider's website @ https://mal.co/", + routes: ['/:query', '/info/:id', '/watch/:episodeId'], + documentation: 'https://docs.consumet.org/#tag/mal', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const query = (request.params as { query: string }).query; + + const page = (request.query as { page: number }).page; + const perPage = (request.query as { perPage: number }).perPage; + + const res = await mal.search(query, page); + + reply.status(200).send(res); + }); + + // mal info with episodes + fastify.get('/info/:id', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.params as { id: string }).id; + + const provider = (request.query as { provider?: string }).provider; + let fetchFiller = (request.query as { fetchFiller?: string | boolean }).fetchFiller; + let isDub = (request.query as { dub?: string | boolean }).dub; + const locale = (request.query as { locale?: string }).locale; + + if (typeof provider !== 'undefined') { + const possibleProvider = PROVIDERS_LIST.ANIME.find( + (p) => p.name.toLowerCase() === provider.toLocaleLowerCase(), + ); + + mal = new META.Myanimelist(possibleProvider); + } + + if (isDub === 'true' || isDub === '1') isDub = true; + else isDub = false; + + if (fetchFiller === 'true' || fetchFiller === '1') fetchFiller = true; + else fetchFiller = false; + + try { + const res = await mal.fetchAnimeInfo(id, isDub as boolean, fetchFiller as boolean); + + mal = new META.Myanimelist(undefined); + reply.status(200).send(res); + } catch (err: any) { + reply.status(500).send({ message: err.message }); + } + }); + + fastify.get( + '/watch/:episodeId', + async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.params as { episodeId: string }).episodeId; + const provider = (request.query as { provider?: string }).provider; + + if (typeof provider !== 'undefined') { + const possibleProvider = PROVIDERS_LIST.ANIME.find( + (p) => p.name.toLowerCase() === provider.toLocaleLowerCase(), + ); + + mal = new META.Myanimelist(possibleProvider); + } + try { + const res = await mal + .fetchEpisodeSources(episodeId) + .catch((err) => reply.status(404).send({ message: err })); + + mal = new META.Myanimelist(undefined); + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }, + ); +}; + +export default routes; diff --git a/src/routes/meta/tmdb.ts b/src/routes/meta/tmdb.ts new file mode 100644 index 000000000..e4b45cd6e --- /dev/null +++ b/src/routes/meta/tmdb.ts @@ -0,0 +1,99 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { META, PROVIDERS_LIST, StreamingServers } from '@consumet/extensions'; +import { tmdbApi } from '../../main'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: + "Welcome to the tmdb provider: check out the provider's website @ https://www.themoviedb.org/", + routes: ['/:query', '/info/:id', '/watch/:episodeId'], + documentation: 'https://docs.consumet.org/#tag/tmdb', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const query = (request.params as { query: string }).query; + const page = (request.query as { page: number }).page; + const tmdb = new META.TMDB(tmdbApi); + + const res = await tmdb.search(query, page); + + reply.status(200).send(res); + }); + + fastify.get('/info/:id', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.params as { id: string }).id; + const type = (request.query as { type: string }).type; + const provider = (request.query as { provider?: string }).provider; + let tmdb = new META.TMDB(tmdbApi); + + if (!type) return reply.status(400).send({ message: "The 'type' query is required" }); + + if (typeof provider !== 'undefined') { + const possibleProvider = PROVIDERS_LIST.MOVIES.find( + (p) => p.name.toLowerCase() === provider.toLocaleLowerCase(), + ); + tmdb = new META.TMDB(tmdbApi, possibleProvider); + } + + const res = await tmdb.fetchMediaInfo(id, type); + reply.status(200).send(res); + }); + + fastify.get('/trending', async (request: FastifyRequest, reply: FastifyReply) => { + const validTimePeriods = new Set(['day', 'week'] as const); + type validTimeType = typeof validTimePeriods extends Set ? T : undefined; + + const type = (request.query as { type?: string }).type || 'all'; + let timePeriod = + (request.query as { timePeriod?: validTimeType }).timePeriod || 'day'; + + // make day as default time period + if (!validTimePeriods.has(timePeriod)) timePeriod = 'day'; + + const page = (request.query as { page?: number }).page || 1; + + const tmdb = new META.TMDB(tmdbApi); + + try { + const res = await tmdb.fetchTrending(type, timePeriod, page); + reply.status(200).send(res); + } catch (err) { + reply.status(500).send({ message: 'Failed to fetch trending media.' }); + } + }); + + const watch = async (request: FastifyRequest, reply: FastifyReply) => { + let episodeId = (request.params as { episodeId: string }).episodeId; + if (!episodeId) { + episodeId = (request.query as { episodeId: string }).episodeId; + } + const id = (request.query as { id: string }).id; + const provider = (request.query as { provider?: string }).provider; + const server = (request.query as { server?: StreamingServers }).server; + + let tmdb = new META.TMDB(tmdbApi); + if (typeof provider !== 'undefined') { + const possibleProvider = PROVIDERS_LIST.MOVIES.find( + (p) => p.name.toLowerCase() === provider.toLocaleLowerCase(), + ); + tmdb = new META.TMDB(tmdbApi, possibleProvider); + } + try { + const res = await tmdb + .fetchEpisodeSources(episodeId, id, server) + .catch((err) => reply.status(404).send({ message: err })); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Contact developer for help.' }); + } + }; + fastify.get('/watch', watch); + fastify.get('/watch/:episodeId', watch); +}; + +export default routes; diff --git a/src/routes/movies/dramacool.ts b/src/routes/movies/dramacool.ts new file mode 100644 index 000000000..a24072f02 --- /dev/null +++ b/src/routes/movies/dramacool.ts @@ -0,0 +1,163 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { MOVIES } from '@consumet/extensions'; +import { StreamingServers } from '@consumet/extensions/dist/models'; + +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + const dramacool = new MOVIES.DramaCool(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: `Welcome to the dramacool provider: check out the provider's website @ ${dramacool.toString.baseUrl}`, + routes: [ + '/:query', + '/info', + '/watch', + '/popular', + '/recent-movies', + '/recent-shows', + ], + documentation: 'https://docs.consumet.org/#tag/dramacool', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + try { + const query = decodeURIComponent((request.params as { query: string }).query); + const page = (request.query as { page: number }).page; + + let res = redis + ? await cache.fetch( + redis as Redis, + `dramacool:${query}:${page}`, + async () => await dramacool.search(query, page), + REDIS_TTL, + ) + : await dramacool.search(query, page); + + reply.status(200).send(res); + } catch (err) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); + + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.query as { id: string }).id; + + if (typeof id === 'undefined') + return reply.status(400).send({ + message: 'id is required', + }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `dramacool:info:${id}`, + async () => await dramacool.fetchMediaInfo(id), + REDIS_TTL, + ) + : await dramacool.fetchMediaInfo(id); + + reply.status(200).send(res); + } catch (err) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); + + fastify.get('/watch', async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.query as { episodeId: string }).episodeId; + const server = (request.query as { server: StreamingServers }).server; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `dramacool:watch:${episodeId}:${server}`, + async () => await dramacool.fetchEpisodeSources(episodeId, server), + REDIS_TTL, + ) + : await dramacool.fetchEpisodeSources(episodeId, server); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Please try again later.' }); + } + }); + + fastify.get('/popular', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `dramacool:popular:${page}`, + async () => await dramacool.fetchPopular(page ? page : 1), + REDIS_TTL, + ) + : await dramacool.fetchPopular(page ? page : 1); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Please try again later.' }); + } + }); + + fastify.get('/recent-movies', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `dramacool:recent-movies:${page}`, + async () => await dramacool.fetchRecentMovies(page ? page : 1), + REDIS_TTL, + ) + : await dramacool.fetchRecentMovies(page ? page : 1); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Please try again later.' }); + } + }); + + fastify.get('/recent-shows', async (request: FastifyRequest, reply: FastifyReply) => { + const page = (request.query as { page: number }).page; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `dramacool:recent-shows:${page}`, + async () => await dramacool.fetchRecentTvShows(page ? page : 1), + REDIS_TTL, + ) + : await dramacool.fetchRecentTvShows(page ? page : 1); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Please try again later.' }); + } + }); +}; + +export default routes; diff --git a/src/routes/movies/flixhq.ts b/src/routes/movies/flixhq.ts index 65a9e60d8..cdd428717 100644 --- a/src/routes/movies/flixhq.ts +++ b/src/routes/movies/flixhq.ts @@ -2,29 +2,111 @@ import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from ' import { MOVIES } from '@consumet/extensions'; import { StreamingServers } from '@consumet/extensions/dist/models'; +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { const flixhq = new MOVIES.FlixHQ(); - fastify.get('/flixhq', (_, rp) => { + fastify.get('/', (_, rp) => { rp.status(200).send({ - intro: - "Welcome to the flixhq provider: check out the provider's website @ https://flixhq.to/", - routes: ['/:query', '/info', '/watch'], + intro: `Welcome to the flixhq provider: check out the provider's website @ ${flixhq.toString.baseUrl}`, + routes: [ + '/:query', + '/info', + '/watch', + '/recent-shows', + '/recent-movies', + '/trending', + '/servers', + '/country', + '/genre', + ], documentation: 'https://docs.consumet.org/#tag/flixhq', }); }); - fastify.get('/flixhq/:query', async (request: FastifyRequest, reply: FastifyReply) => { + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { const query = decodeURIComponent((request.params as { query: string }).query); const page = (request.query as { page: number }).page; - const res = await flixhq.search(query, page); + let res = redis + ? await cache.fetch( + redis as Redis, + `flixhq:${query}:${page}`, + async () => await flixhq.search(query, page ? page : 1), + REDIS_TTL, + ) + : await flixhq.search(query, page ? page : 1); + + reply.status(200).send(res); + }); + + fastify.get('/recent-shows', async (request: FastifyRequest, reply: FastifyReply) => { + let res = redis + ? await cache.fetch( + redis as Redis, + `flixhq:recent-shows`, + async () => await flixhq.fetchRecentTvShows(), + REDIS_TTL, + ) + : await flixhq.fetchRecentTvShows(); + + reply.status(200).send(res); + }); + + fastify.get('/recent-movies', async (request: FastifyRequest, reply: FastifyReply) => { + let res = redis + ? await cache.fetch( + redis as Redis, + `flixhq:recent-movies`, + async () => await flixhq.fetchRecentMovies(), + REDIS_TTL, + ) + : await flixhq.fetchRecentMovies(); reply.status(200).send(res); }); - fastify.get('/flixhq/info', async (request: FastifyRequest, reply: FastifyReply) => { + fastify.get('/trending', async (request: FastifyRequest, reply: FastifyReply) => { + const type = (request.query as { type: string }).type; + try { + if (!type) { + const res = { + results: [ + ...(await flixhq.fetchTrendingMovies()), + ...(await flixhq.fetchTrendingTvShows()), + ], + }; + return reply.status(200).send(res); + } + + let res = redis + ? await cache.fetch( + redis as Redis, + `flixhq:trending:${type}`, + async () => + type === 'tv' + ? await flixhq.fetchTrendingTvShows() + : await flixhq.fetchTrendingMovies(), + REDIS_TTL, + ) + : type === 'tv' + ? await flixhq.fetchTrendingTvShows() + : await flixhq.fetchTrendingMovies(); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); + + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { const id = (request.query as { id: string }).id; if (typeof id === 'undefined') @@ -33,9 +115,14 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { }); try { - const res = await flixhq - .fetchMediaInfo(id) - .catch((err) => reply.status(404).send({ message: err })); + let res = redis + ? await cache.fetch( + redis as Redis, + `flixhq:info:${id}`, + async () => await flixhq.fetchMediaInfo(id), + REDIS_TTL, + ) + : await flixhq.fetchMediaInfo(id); reply.status(200).send(res); } catch (err) { @@ -46,7 +133,7 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { } }); - fastify.get('/flixhq/watch', async (request: FastifyRequest, reply: FastifyReply) => { + fastify.get('/watch', async (request: FastifyRequest, reply: FastifyReply) => { const episodeId = (request.query as { episodeId: string }).episodeId; const mediaId = (request.query as { mediaId: string }).mediaId; const server = (request.query as { server: StreamingServers }).server; @@ -60,9 +147,14 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { return reply.status(400).send({ message: 'Invalid server query' }); try { - const res = await flixhq - .fetchEpisodeSources(episodeId, mediaId, server) - .catch((err) => reply.status(404).send({ message: 'Media Not found.' })); + let res = redis + ? await cache.fetch( + redis as Redis, + `flixhq:watch:${episodeId}:${mediaId}:${server}`, + async () => await flixhq.fetchEpisodeSources(episodeId, mediaId, server), + REDIS_TTL, + ) + : await flixhq.fetchEpisodeSources(episodeId, mediaId, server); reply.status(200).send(res); } catch (err) { @@ -71,6 +163,80 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { .send({ message: 'Something went wrong. Please try again later.' }); } }); -}; + fastify.get('/servers', async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.query as { episodeId: string }).episodeId; + const mediaId = (request.query as { mediaId: string }).mediaId; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + if (typeof mediaId === 'undefined') + return reply.status(400).send({ message: 'mediaId is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `flixhq:servers:${episodeId}:${mediaId}`, + async () => await flixhq.fetchEpisodeServers(episodeId, mediaId), + REDIS_TTL, + ) + : await flixhq.fetchEpisodeServers(episodeId, mediaId); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); + + fastify.get( + '/country/:country', + async (request: FastifyRequest, reply: FastifyReply) => { + const country = (request.params as { country: string }).country; + const page = (request.query as { page: number }).page ?? 1; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `flixhq:country:${country}:${page}`, + async () => await flixhq.fetchByCountry(country, page), + REDIS_TTL, + ) + : await flixhq.fetchByCountry(country, page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }, + ); + + fastify.get('/genre/:genre', async (request: FastifyRequest, reply: FastifyReply) => { + const genre = (request.params as { genre: string }).genre; + const page = (request.query as { page: number }).page ?? 1; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `flixhq:genre:${genre}:${page}`, + async () => await flixhq.fetchByGenre(genre, page), + REDIS_TTL, + ) + : await flixhq.fetchByGenre(genre, page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); +}; export default routes; diff --git a/src/routes/movies/goku.ts b/src/routes/movies/goku.ts new file mode 100644 index 000000000..45c2110d4 --- /dev/null +++ b/src/routes/movies/goku.ts @@ -0,0 +1,241 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { MOVIES } from '@consumet/extensions'; +import { StreamingServers } from '@consumet/extensions/dist/models'; + +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + const goku = new MOVIES.Goku(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: `Welcome to the goku provider: check out the provider's website @ ${goku.toString.baseUrl}`, + routes: [ + '/:query', + '/info', + '/watch', + '/recent-shows', + '/recent-movies', + '/trending', + '/servers', + '/country', + '/genre', + ], + documentation: 'https://docs.consumet.org/#tag/goku', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const query = decodeURIComponent((request.params as { query: string }).query); + + const page = (request.query as { page: number }).page; + + let res = redis + ? await cache.fetch( + redis as Redis, + `goku:${query}:${page}`, + async () => await goku.search(query, page ? page : 1), + REDIS_TTL, + ) + : await goku.search(query, page ? page : 1); + + reply.status(200).send(res); + }); + + fastify.get('/recent-shows', async (request: FastifyRequest, reply: FastifyReply) => { + let res = redis + ? await cache.fetch( + redis as Redis, + `goku:recent-shows`, + async () => await goku.fetchRecentTvShows(), + REDIS_TTL, + ) + : await goku.fetchRecentTvShows(); + + reply.status(200).send(res); + }); + + fastify.get('/recent-movies', async (request: FastifyRequest, reply: FastifyReply) => { + let res = redis + ? await cache.fetch( + redis as Redis, + `goku:recent-movies`, + async () => await goku.fetchRecentMovies(), + REDIS_TTL, + ) + : await goku.fetchRecentMovies(); + + reply.status(200).send(res); + }); + + fastify.get('/trending', async (request: FastifyRequest, reply: FastifyReply) => { + const type = (request.query as { type: string }).type; + try { + if (!type) { + const res = { + results: [ + ...(await goku.fetchTrendingMovies()), + ...(await goku.fetchTrendingTvShows()), + ], + }; + return reply.status(200).send(res); + } + + let res = redis + ? await cache.fetch( + redis as Redis, + `goku:trending:${type}`, + async () => + type === 'tv' + ? await goku.fetchTrendingTvShows() + : await goku.fetchTrendingMovies(), + REDIS_TTL, + ) + : type === 'tv' + ? await goku.fetchTrendingTvShows() + : await goku.fetchTrendingMovies(); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); + + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.query as { id: string }).id; + + if (typeof id === 'undefined') + return reply.status(400).send({ + message: 'id is required', + }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `goku:info:${id}`, + async () => await goku.fetchMediaInfo(id), + REDIS_TTL, + ) + : await goku.fetchMediaInfo(id); + + reply.status(200).send(res); + } catch (err) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); + + fastify.get('/watch', async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.query as { episodeId: string }).episodeId; + const mediaId = (request.query as { mediaId: string }).mediaId; + const server = (request.query as { server: StreamingServers }).server; + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + if (typeof mediaId === 'undefined') + return reply.status(400).send({ message: 'mediaId is required' }); + + if (server && !Object.values(StreamingServers).includes(server)) + return reply.status(400).send({ message: 'Invalid server query' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `goku:watch:${episodeId}:${mediaId}:${server}`, + async () => await goku.fetchEpisodeSources(episodeId, mediaId, server), + REDIS_TTL, + ) + : await goku.fetchEpisodeSources(episodeId, mediaId, StreamingServers.VidCloud); + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Please try again later.' }); + } + }); + + fastify.get('/servers', async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.query as { episodeId: string }).episodeId; + const mediaId = (request.query as { mediaId: string }).mediaId; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + if (typeof mediaId === 'undefined') + return reply.status(400).send({ message: 'mediaId is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `goku:servers:${episodeId}:${mediaId}`, + async () => await goku.fetchEpisodeServers(episodeId, mediaId), + REDIS_TTL, + ) + : await goku.fetchEpisodeServers(episodeId, mediaId); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); + + fastify.get( + '/country/:country', + async (request: FastifyRequest, reply: FastifyReply) => { + const country = (request.params as { country: string }).country; + const page = (request.query as { page: number }).page ?? 1; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `goku:country:${country}:${page}`, + async () => await goku.fetchByCountry(country, page), + REDIS_TTL, + ) + : await goku.fetchByCountry(country, page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }, + ); + + fastify.get('/genre/:genre', async (request: FastifyRequest, reply: FastifyReply) => { + const genre = (request.params as { genre: string }).genre; + const page = (request.query as { page: number }).page ?? 1; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `goku:genre:${genre}:${page}`, + async () => await goku.fetchByGenre(genre, page), + REDIS_TTL, + ) + : await goku.fetchByGenre(genre, page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); +}; + +export default routes; diff --git a/src/routes/movies/himovies.ts b/src/routes/movies/himovies.ts new file mode 100644 index 000000000..3a116acad --- /dev/null +++ b/src/routes/movies/himovies.ts @@ -0,0 +1,242 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { MOVIES } from '@consumet/extensions'; +import { StreamingServers } from '@consumet/extensions/dist/models'; + +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + const himovies = new MOVIES.HiMovies(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: `Welcome to the himovies provider: check out the provider's website @ ${himovies.toString.baseUrl}`, + routes: [ + '/:query', + '/info', + '/watch', + '/recent-shows', + '/recent-movies', + '/trending', + '/servers', + '/country', + '/genre', + ], + documentation: 'https://docs.consumet.org/#tag/himovies', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const query = decodeURIComponent((request.params as { query: string }).query); + + const page = (request.query as { page: number }).page; + + let res = redis + ? await cache.fetch( + redis as Redis, + `himovies:${query}:${page}`, + async () => await himovies.search(query, page ? page : 1), + REDIS_TTL, + ) + : await himovies.search(query, page ? page : 1); + + reply.status(200).send(res); + }); + + fastify.get('/recent-shows', async (request: FastifyRequest, reply: FastifyReply) => { + let res = redis + ? await cache.fetch( + redis as Redis, + `himovies:recent-shows`, + async () => await himovies.fetchRecentTvShows(), + REDIS_TTL, + ) + : await himovies.fetchRecentTvShows(); + + reply.status(200).send(res); + }); + + fastify.get('/recent-movies', async (request: FastifyRequest, reply: FastifyReply) => { + let res = redis + ? await cache.fetch( + redis as Redis, + `himovies:recent-movies`, + async () => await himovies.fetchRecentMovies(), + REDIS_TTL, + ) + : await himovies.fetchRecentMovies(); + + reply.status(200).send(res); + }); + + fastify.get('/trending', async (request: FastifyRequest, reply: FastifyReply) => { + const type = (request.query as { type: string }).type; + try { + if (!type) { + const res = { + results: [ + ...(await himovies.fetchTrendingMovies()), + ...(await himovies.fetchTrendingTvShows()), + ], + }; + return reply.status(200).send(res); + } + + let res = redis + ? await cache.fetch( + redis as Redis, + `himovies:trending:${type}`, + async () => + type === 'tv' + ? await himovies.fetchTrendingTvShows() + : await himovies.fetchTrendingMovies(), + REDIS_TTL, + ) + : type === 'tv' + ? await himovies.fetchTrendingTvShows() + : await himovies.fetchTrendingMovies(); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); + + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.query as { id: string }).id; + + if (typeof id === 'undefined') + return reply.status(400).send({ + message: 'id is required', + }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `himovies:info:${id}`, + async () => await himovies.fetchMediaInfo(id), + REDIS_TTL, + ) + : await himovies.fetchMediaInfo(id); + + reply.status(200).send(res); + } catch (err) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); + + fastify.get('/watch', async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.query as { episodeId: string }).episodeId; + const mediaId = (request.query as { mediaId: string }).mediaId; + const server = (request.query as { server: StreamingServers }).server; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + if (typeof mediaId === 'undefined') + return reply.status(400).send({ message: 'mediaId is required' }); + + if (server && !Object.values(StreamingServers).includes(server)) + return reply.status(400).send({ message: 'Invalid server query' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `himovies:watch:${episodeId}:${mediaId}:${server}`, + async () => await himovies.fetchEpisodeSources(episodeId, mediaId, server), + REDIS_TTL, + ) + : await himovies.fetchEpisodeSources(episodeId, mediaId, server); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Please try again later.' }); + } + }); + + fastify.get('/servers', async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.query as { episodeId: string }).episodeId; + const mediaId = (request.query as { mediaId: string }).mediaId; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + if (typeof mediaId === 'undefined') + return reply.status(400).send({ message: 'mediaId is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `himovies:servers:${episodeId}:${mediaId}`, + async () => await himovies.fetchEpisodeServers(episodeId, mediaId), + REDIS_TTL, + ) + : await himovies.fetchEpisodeServers(episodeId, mediaId); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); + + fastify.get( + '/country/:country', + async (request: FastifyRequest, reply: FastifyReply) => { + const country = (request.params as { country: string }).country; + const page = (request.query as { page: number }).page ?? 1; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `himovies:country:${country}:${page}`, + async () => await himovies.fetchByCountry(country, page), + REDIS_TTL, + ) + : await himovies.fetchByCountry(country, page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }, + ); + + fastify.get('/genre/:genre', async (request: FastifyRequest, reply: FastifyReply) => { + const genre = (request.params as { genre: string }).genre; + const page = (request.query as { page: number }).page ?? 1; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `himovies:genre:${genre}:${page}`, + async () => await himovies.fetchByGenre(genre, page), + REDIS_TTL, + ) + : await himovies.fetchByGenre(genre, page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); +}; +export default routes; diff --git a/src/routes/movies/index.ts b/src/routes/movies/index.ts index 0ac1a731b..922dde337 100644 --- a/src/routes/movies/index.ts +++ b/src/routes/movies/index.ts @@ -2,9 +2,17 @@ import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from ' import { PROVIDERS_LIST } from '@consumet/extensions'; import flixhq from './flixhq'; +import dramacool from './dramacool'; +import goku from './goku'; +import sflix from './sflix'; +import himovies from './himovies'; const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { - await fastify.register(flixhq, { prefix: '/' }); + await fastify.register(flixhq, { prefix: '/flixhq' }); + await fastify.register(dramacool, { prefix: '/dramacool' }); + await fastify.register(goku, { prefix: '/goku' }); + await fastify.register(sflix, { prefix: '/sflix' }); + await fastify.register(himovies, { prefix: '/himovies' }); fastify.get('/', async (request: any, reply: any) => { reply.status(200).send('Welcome to Consumet Movies and TV Shows'); @@ -17,7 +25,7 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { }; queries.movieProvider = decodeURIComponent( - (request.params as { movieProvider: string; page: number }).movieProvider + (request.params as { movieProvider: string; page: number }).movieProvider, ); queries.page = (request.query as { movieProvider: string; page: number }).page; @@ -25,7 +33,7 @@ const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { if (queries.page! < 1) queries.page = 1; const provider = PROVIDERS_LIST.MOVIES.find( - (provider: any) => provider.toString.name === queries.movieProvider + (provider: any) => provider.toString.name === queries.movieProvider, ); try { diff --git a/src/routes/movies/sflix.ts b/src/routes/movies/sflix.ts new file mode 100644 index 000000000..b214b4e27 --- /dev/null +++ b/src/routes/movies/sflix.ts @@ -0,0 +1,242 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; +import { MOVIES } from '@consumet/extensions'; +import { StreamingServers } from '@consumet/extensions/dist/models'; + +import cache from '../../utils/cache'; +import { redis, REDIS_TTL } from '../../main'; +import { Redis } from 'ioredis'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + const sflix = new MOVIES.SFlix(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: `Welcome to the sflix provider: check out the provider's website @ ${sflix.toString.baseUrl}`, + routes: [ + '/:query', + '/info', + '/watch', + '/recent-shows', + '/recent-movies', + '/trending', + '/servers', + '/country', + '/genre', + ], + documentation: 'https://docs.consumet.org/#tag/sflix', + }); + }); + + fastify.get('/:query', async (request: FastifyRequest, reply: FastifyReply) => { + const query = decodeURIComponent((request.params as { query: string }).query); + + const page = (request.query as { page: number }).page; + + let res = redis + ? await cache.fetch( + redis as Redis, + `sflix:${query}:${page}`, + async () => await sflix.search(query, page ? page : 1), + REDIS_TTL, + ) + : await sflix.search(query, page ? page : 1); + + reply.status(200).send(res); + }); + + fastify.get('/recent-shows', async (request: FastifyRequest, reply: FastifyReply) => { + let res = redis + ? await cache.fetch( + redis as Redis, + `sflix:recent-shows`, + async () => await sflix.fetchRecentTvShows(), + REDIS_TTL, + ) + : await sflix.fetchRecentTvShows(); + + reply.status(200).send(res); + }); + + fastify.get('/recent-movies', async (request: FastifyRequest, reply: FastifyReply) => { + let res = redis + ? await cache.fetch( + redis as Redis, + `sflix:recent-movies`, + async () => await sflix.fetchRecentMovies(), + REDIS_TTL, + ) + : await sflix.fetchRecentMovies(); + + reply.status(200).send(res); + }); + + fastify.get('/trending', async (request: FastifyRequest, reply: FastifyReply) => { + const type = (request.query as { type: string }).type; + try { + if (!type) { + const res = { + results: [ + ...(await sflix.fetchTrendingMovies()), + ...(await sflix.fetchTrendingTvShows()), + ], + }; + return reply.status(200).send(res); + } + + let res = redis + ? await cache.fetch( + redis as Redis, + `sflix:trending:${type}`, + async () => + type === 'tv' + ? await sflix.fetchTrendingTvShows() + : await sflix.fetchTrendingMovies(), + REDIS_TTL, + ) + : type === 'tv' + ? await sflix.fetchTrendingTvShows() + : await sflix.fetchTrendingMovies(); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); + + fastify.get('/info', async (request: FastifyRequest, reply: FastifyReply) => { + const id = (request.query as { id: string }).id; + + if (typeof id === 'undefined') + return reply.status(400).send({ + message: 'id is required', + }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `sflix:info:${id}`, + async () => await sflix.fetchMediaInfo(id), + REDIS_TTL, + ) + : await sflix.fetchMediaInfo(id); + + reply.status(200).send(res); + } catch (err) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); + + fastify.get('/watch', async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.query as { episodeId: string }).episodeId; + const mediaId = (request.query as { mediaId: string }).mediaId; + const server = (request.query as { server: StreamingServers }).server; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + if (typeof mediaId === 'undefined') + return reply.status(400).send({ message: 'mediaId is required' }); + + if (server && !Object.values(StreamingServers).includes(server)) + return reply.status(400).send({ message: 'Invalid server query' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `sflix:watch:${episodeId}:${mediaId}:${server}`, + async () => await sflix.fetchEpisodeSources(episodeId, mediaId, server), + REDIS_TTL, + ) + : await sflix.fetchEpisodeSources(episodeId, mediaId, server); + + reply.status(200).send(res); + } catch (err) { + reply + .status(500) + .send({ message: 'Something went wrong. Please try again later.' }); + } + }); + + fastify.get('/servers', async (request: FastifyRequest, reply: FastifyReply) => { + const episodeId = (request.query as { episodeId: string }).episodeId; + const mediaId = (request.query as { mediaId: string }).mediaId; + + if (typeof episodeId === 'undefined') + return reply.status(400).send({ message: 'episodeId is required' }); + if (typeof mediaId === 'undefined') + return reply.status(400).send({ message: 'mediaId is required' }); + + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `sflix:servers:${episodeId}:${mediaId}`, + async () => await sflix.fetchEpisodeServers(episodeId, mediaId), + REDIS_TTL, + ) + : await sflix.fetchEpisodeServers(episodeId, mediaId); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); + + fastify.get( + '/country/:country', + async (request: FastifyRequest, reply: FastifyReply) => { + const country = (request.params as { country: string }).country; + const page = (request.query as { page: number }).page ?? 1; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `sflix:country:${country}:${page}`, + async () => await sflix.fetchByCountry(country, page), + REDIS_TTL, + ) + : await sflix.fetchByCountry(country, page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }, + ); + + fastify.get('/genre/:genre', async (request: FastifyRequest, reply: FastifyReply) => { + const genre = (request.params as { genre: string }).genre; + const page = (request.query as { page: number }).page ?? 1; + try { + let res = redis + ? await cache.fetch( + redis as Redis, + `sflix:genre:${genre}:${page}`, + async () => await sflix.fetchByGenre(genre, page), + REDIS_TTL, + ) + : await sflix.fetchByGenre(genre, page); + + reply.status(200).send(res); + } catch (error) { + reply.status(500).send({ + message: + 'Something went wrong. Please try again later. or contact the developers.', + }); + } + }); +}; +export default routes; diff --git a/src/routes/news/ann.ts b/src/routes/news/ann.ts new file mode 100644 index 000000000..d17aa5f2c --- /dev/null +++ b/src/routes/news/ann.ts @@ -0,0 +1,48 @@ +import { NEWS, Topics } from '@consumet/extensions'; +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + const ann = new NEWS.ANN(); + + fastify.get('/', (_, rp) => { + rp.status(200).send({ + intro: + "Welcome to the Anime News Network provider: check out the provider's website @ https://www.animenewsnetwork.com/", + routes: ['/recent-feeds', '/info'], + documentation: 'https://docs.consumet.org/#tag/animenewsnetwork', + }); + }); + + fastify.get('/recent-feeds', async (req: FastifyRequest, reply: FastifyReply) => { + let { topic } = req.query as { topic?: Topics }; + + try { + const feeds = await ann.fetchNewsFeeds(topic); + reply.status(200).send(feeds); + } catch (e) { + reply.status(500).send({ + message: (e as Error).message, + }); + } + }); + + fastify.get('/info', async (req: FastifyRequest, reply: FastifyReply) => { + const { id } = req.query as { id: string }; + + if (typeof id === 'undefined') + return reply.status(400).send({ + message: 'id is required', + }); + + try { + const info = await ann.fetchNewsInfo(id); + reply.status(200).send(info); + } catch (error) { + reply.status(500).send({ + message: (error as Error).message, + }); + } + }); +}; + +export default routes; diff --git a/src/routes/news/index.ts b/src/routes/news/index.ts new file mode 100644 index 000000000..3e0026b9b --- /dev/null +++ b/src/routes/news/index.ts @@ -0,0 +1,13 @@ +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; + +import ann from './ann'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + fastify.register(ann, { prefix: '/ann' }); + + fastify.get('/', async (_request: FastifyRequest, reply: FastifyReply) => { + reply.status(200).send('Welcome to Consumet News'); + }); +}; + +export default routes; diff --git a/src/utils/cache.ts b/src/utils/cache.ts new file mode 100644 index 000000000..ac984aec3 --- /dev/null +++ b/src/utils/cache.ts @@ -0,0 +1,29 @@ +import { Redis } from 'ioredis'; + +const fetch = async (redis: Redis, key: string, fetcher: () => T, expires: number) => { + const existing = await get(redis, key); + if (existing !== null) return existing; + + return set(redis, key, fetcher, expires); +}; + +const get = async (redis: Redis, key: string): Promise => { + console.log('GET: ' + key); + const value = await redis.get(key); + if (value === null) return null as any; + + return JSON.parse(value); +}; + +const set = async (redis: Redis, key: string, fetcher: () => T, expires: number) => { + console.log(`SET: ${key}, EXP: ${expires}`); + const value = await fetcher(); + await redis.set(key, JSON.stringify(value), 'EX', expires); + return value; +}; + +const del = async (redis: Redis, key: string) => { + await redis.del(key); +}; + +export default { fetch, set, get, del }; diff --git a/src/utils/index.ts b/src/utils/index.ts index 5e1c0f059..0dc0ead15 100644 --- a/src/utils/index.ts +++ b/src/utils/index.ts @@ -1 +1,13 @@ -// utils.ts +import { FastifyInstance, RegisterOptions } from 'fastify'; + +import Providers from './providers'; + +const routes = async (fastify: FastifyInstance, options: RegisterOptions) => { + await fastify.register(new Providers().getProviders); + + fastify.get('/', async (request: any, reply: any) => { + reply.status(200).send('Welcome to Consumet Utils!'); + }); +}; + +export default routes; diff --git a/src/utils/providers.ts b/src/utils/providers.ts new file mode 100644 index 000000000..0130a5e0b --- /dev/null +++ b/src/utils/providers.ts @@ -0,0 +1,44 @@ +import { PROVIDERS_LIST } from '@consumet/extensions'; +import { FastifyRequest, FastifyReply, FastifyInstance, RegisterOptions } from 'fastify'; + +type ProvidersRequest = FastifyRequest<{ + Querystring: { type: keyof typeof PROVIDERS_LIST }; +}>; + +export default class Providers { + public getProviders = async (fastify: FastifyInstance, options: RegisterOptions) => { + fastify.get( + '/providers', + { + preValidation: (request, reply, done) => { + const { type } = request.query; + + const providerTypes = Object.keys(PROVIDERS_LIST).map((element) => element); + + if (type === undefined) { + reply.status(400); + done( + new Error( + 'Type must not be empty. Available types: ' + providerTypes.toString(), + ), + ); + } + + if (!providerTypes.includes(type)) { + reply.status(400); + done(new Error('Type must be either: ' + providerTypes.toString())); + } + + done(undefined); + }, + }, + async (request: ProvidersRequest, reply: FastifyReply) => { + const { type } = request.query; + const providers = Object.values(PROVIDERS_LIST[type]).sort((one, two) => + one.name.localeCompare(two.name), + ); + reply.status(200).send(providers.map((element) => element.toString)); + }, + ); + }; +} diff --git a/tsconfig.json b/tsconfig.json index 663c44c67..ddfca68a0 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,71 +1,19 @@ { "compilerOptions": { - /* Visit https://aka.ms/tsconfig.json to read more about this file */ - - /* Projects */ - // "incremental": true, /* Enable incremental compilation */ - // "composite": true, /* Enable constraints that allow a TypeScript project to be used with project references. */ - // "tsBuildInfoFile": "./", /* Specify the folder for .tsbuildinfo incremental compilation files. */ - // "disableSourceOfProjectReferenceRedirect": true, /* Disable preferring source files instead of declaration files when referencing composite projects */ - // "disableSolutionSearching": true, /* Opt a project out of multi-project reference checking when editing. */ - // "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */ - /* Language and Environment */ "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, - // "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */ - // "jsx": "preserve", /* Specify what JSX code is generated. */ - // "experimentalDecorators": true, /* Enable experimental support for TC39 stage 2 draft decorators. */ - // "emitDecoratorMetadata": true, /* Emit design-type metadata for decorated declarations in source files. */ - // "jsxFactory": "", /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h' */ - // "jsxFragmentFactory": "", /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */ - // "jsxImportSource": "", /* Specify module specifier used to import the JSX factory functions when using `jsx: react-jsx*`.` */ - // "reactNamespace": "", /* Specify the object invoked for `createElement`. This only applies when targeting `react` JSX emit. */ - // "noLib": true, /* Disable including any library files, including the default lib.d.ts. */ - // "useDefineForClassFields": true, /* Emit ECMAScript-standard-compliant class fields. */ /* Modules */ "module": "commonjs" /* Specify what module code is generated. */, // "rootDir": "./", /* Specify the root folder within your source files. */ // "moduleResolution": "node", /* Specify how TypeScript looks up a file from a given module specifier. */ // "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */ - // "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */ - // "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */ - // "typeRoots": [], /* Specify multiple folders that act like `./node_modules/@types`. */ - // "types": [], /* Specify type package names to be included without being referenced in a source file. */ - // "allowUmdGlobalAccess": true, /* Allow accessing UMD globals from modules. */ - // "resolveJsonModule": true, /* Enable importing .json files */ - // "noResolve": true, /* Disallow `import`s, `require`s or ``s from expanding the number of files TypeScript should add to a project. */ - - /* JavaScript Support */ - // "allowJs": true, /* Allow JavaScript files to be a part of your program. Use the `checkJS` option to get errors from these files. */ - // "checkJs": true, /* Enable error reporting in type-checked JavaScript files. */ - // "maxNodeModuleJsDepth": 1, /* Specify the maximum folder depth used for checking JavaScript files from `node_modules`. Only applicable with `allowJs`. */ - + "paths": { + "*": ["./node_modules/*", "./src/types/*"] + }, /* Emit */ - // "declaration": true, /* Generate .d.ts files from TypeScript and JavaScript files in your project. */ - // "declarationMap": true, /* Create sourcemaps for d.ts files. */ - // "emitDeclarationOnly": true, /* Only output d.ts files and not JavaScript files. */ - // "sourceMap": true, /* Create source map files for emitted JavaScript files. */ - // "outFile": "./", /* Specify a file that bundles all outputs into one JavaScript file. If `declaration` is true, also designates a file that bundles all .d.ts output. */ - // "outDir": "./", /* Specify an output folder for all emitted files. */ - // "removeComments": true, /* Disable emitting comments. */ - // "noEmit": true, /* Disable emitting files from a compilation. */ - // "importHelpers": true, /* Allow importing helper functions from tslib once per project, instead of including them per-file. */ - // "importsNotUsedAsValues": "remove", /* Specify emit/checking behavior for imports that are only used for types */ - // "downlevelIteration": true, /* Emit more compliant, but verbose and less performant JavaScript for iteration. */ - // "sourceRoot": "", /* Specify the root path for debuggers to find the reference source code. */ - // "mapRoot": "", /* Specify the location where debugger should locate map files instead of generated locations. */ - // "inlineSourceMap": true, /* Include sourcemap files inside the emitted JavaScript. */ - // "inlineSources": true, /* Include source code in the sourcemaps inside the emitted JavaScript. */ - // "emitBOM": true, /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */ - // "newLine": "crlf", /* Set the newline character for emitting files. */ - // "stripInternal": true, /* Disable emitting declarations that have `@internal` in their JSDoc comments. */ - // "noEmitHelpers": true, /* Disable generating custom helper functions like `__extends` in compiled output. */ - // "noEmitOnError": true, /* Disable emitting files if any type checking errors are reported. */ - // "preserveConstEnums": true, /* Disable erasing `const enum` declarations in generated code. */ - // "declarationDir": "./", /* Specify the output directory for generated declaration files. */ - // "preserveValueImports": true, /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */ - + + "outDir": "dist", /* Specify an output folder for all emitted files. */ /* Interop Constraints */ //"isolatedModules": true /* Ensure that each file can be safely transpiled without relying on other imports. */, // "allowSyntheticDefaultImports": true, /* Allow 'import x from y' when a module doesn't have a default export. */ @@ -75,27 +23,17 @@ /* Type Checking */ "strict": true /* Enable all strict type-checking options. */, - // "noImplicitAny": true, /* Enable error reporting for expressions and declarations with an implied `any` type.. */ - // "strictNullChecks": true, /* When type checking, take into account `null` and `undefined`. */ - // "strictFunctionTypes": true, /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */ - // "strictBindCallApply": true, /* Check that the arguments for `bind`, `call`, and `apply` methods match the original function. */ - // "strictPropertyInitialization": true, /* Check for class properties that are declared but not set in the constructor. */ - // "noImplicitThis": true, /* Enable error reporting when `this` is given the type `any`. */ - // "useUnknownInCatchVariables": true, /* Type catch clause variables as 'unknown' instead of 'any'. */ - // "alwaysStrict": true, /* Ensure 'use strict' is always emitted. */ - // "noUnusedLocals": true, /* Enable error reporting when a local variables aren't read. */ - // "noUnusedParameters": true, /* Raise an error when a function parameter isn't read */ - // "exactOptionalPropertyTypes": true, /* Interpret optional property types as written, rather than adding 'undefined'. */ - // "noImplicitReturns": true, /* Enable error reporting for codepaths that do not explicitly return in a function. */ - // "noFallthroughCasesInSwitch": true, /* Enable error reporting for fallthrough cases in switch statements. */ - // "noUncheckedIndexedAccess": true, /* Include 'undefined' in index signature results */ - // "noImplicitOverride": true, /* Ensure overriding members in derived classes are marked with an override modifier. */ - // "noPropertyAccessFromIndexSignature": true, /* Enforces using indexed accessors for keys declared using an indexed type */ - // "allowUnusedLabels": true, /* Disable error reporting for unused labels. */ - // "allowUnreachableCode": true, /* Disable error reporting for unreachable code. */ - /* Completeness */ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ - "skipLibCheck": true /* Skip type checking all .d.ts files. */ - } + "skipLibCheck": true, + + }, + "include": [ + "src/**/*.ts", + ], + "exclude": [ + "node_modules", + "/**", + "bin/**" + ] } diff --git a/vercel.json b/vercel.json new file mode 100644 index 000000000..3eb18b960 --- /dev/null +++ b/vercel.json @@ -0,0 +1,15 @@ +{ + "version": 2, + "builds": [ + { + "src": "/src/main.ts", + "use": "@vercel/node" + } + ], + "routes": [ + { + "src": "/(.*)", + "dest": "/src/main.ts" + } + ] + } diff --git a/yarn.lock b/yarn.lock deleted file mode 100644 index 04680643a..000000000 --- a/yarn.lock +++ /dev/null @@ -1,913 +0,0 @@ -# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. -# yarn lockfile v1 - - -"@consumet/extensions@https://github.com/consumet/consumet.ts.git": - version "1.0.6" - resolved "https://github.com/consumet/consumet.ts.git#8104059e68724a88841e34ef7da21cd2f4b56bfd" - dependencies: - ascii-url-encoder "^1.2.0" - axios "^0.27.2" - cheerio "^1.0.0-rc.11" - crypto-js "^4.1.1" - form-data "^4.0.0" - -"@cspotcode/source-map-support@^0.8.0": - version "0.8.1" - resolved "https://registry.yarnpkg.com/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz#00629c35a688e05a88b1cda684fb9d5e73f000a1" - integrity sha512-IchNf6dN4tHoMFIn/7OE8LWZ19Y6q/67Bmf6vnGREv8RSbBVb9LPJxEcnwrcwX6ixSvaiGoomAUvu4YSxXrVgw== - dependencies: - "@jridgewell/trace-mapping" "0.3.9" - -"@fastify/ajv-compiler@^3.1.1": - version "3.1.2" - resolved "https://registry.yarnpkg.com/@fastify/ajv-compiler/-/ajv-compiler-3.1.2.tgz#9b3c4ae0f5feeb2a90ee797cff6dc26e1831795b" - integrity sha512-m2nzzQJeuVmeGOB9rnII9sZiY8AZ02a9WMQfMBfK1jxdFnxm3FPYKGbYpPjODj4halNogwpolyugbTNpnDCi0A== - dependencies: - ajv "^8.10.0" - ajv-formats "^2.1.1" - fast-uri "^2.0.0" - -"@fastify/cors@^8.0.0": - version "8.0.0" - resolved "https://registry.yarnpkg.com/@fastify/cors/-/cors-8.0.0.tgz#0b1f6559dad4b4291a4413ffb5b7ace760aad19d" - integrity sha512-mB2GsA7aVwq7XG6B2OM1FMpcaiXY69ZbM1h/xDJxLEVu5ITGcs5XYrBIYTMNU2dQtzO6mzXhGd2dEKaCnB7UgQ== - dependencies: - fastify-plugin "^3.0.0" - vary "^1.1.2" - -"@fastify/deepmerge@^1.0.0": - version "1.1.0" - resolved "https://registry.yarnpkg.com/@fastify/deepmerge/-/deepmerge-1.1.0.tgz#91f0a5a27034ff76b7bece63a5906894940ace82" - integrity sha512-E8Hfdvs1bG6u0N4vN5Nty6JONUfTdOciyD5rn8KnEsLKIenvOVcr210BQR9t34PRkNyjqnMLGk3e0BsaxRdL+g== - -"@fastify/error@^3.0.0": - version "3.0.0" - resolved "https://registry.yarnpkg.com/@fastify/error/-/error-3.0.0.tgz#bfcb7b33cec0196413083a91ef2edc7b2c88455b" - integrity sha512-dPRyT40GiHRzSCll3/Jn2nPe25+E1VXc9tDwRAIKwFCxd5Np5wzgz1tmooWG3sV0qKgrBibihVoCna2ru4SEFg== - -"@fastify/fast-json-stringify-compiler@^4.0.0": - version "4.0.0" - resolved "https://registry.yarnpkg.com/@fastify/fast-json-stringify-compiler/-/fast-json-stringify-compiler-4.0.0.tgz#444139d0a12b3e3a8fcdda29da7e9a6c72c8e404" - integrity sha512-9pCi6c6tmGt/qfuf2koZQuSIG6ckP9q3mz+JoMmAq9eQ4EtA92sWoK7E0LJUn2FFTS/hp5kag+4+dWsV5ZfcXg== - dependencies: - fast-json-stringify "^5.0.0" - -"@jridgewell/resolve-uri@^3.0.3": - version "3.1.0" - resolved "https://registry.yarnpkg.com/@jridgewell/resolve-uri/-/resolve-uri-3.1.0.tgz#2203b118c157721addfe69d47b70465463066d78" - integrity sha512-F2msla3tad+Mfht5cJq7LSXcdudKTWCVYUgw6pLFOOHSTtZlj6SWNYAp+AhuqLmWdBO2X5hPrLcu8cVP8fy28w== - -"@jridgewell/sourcemap-codec@^1.4.10": - version "1.4.14" - resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" - integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw== - -"@jridgewell/trace-mapping@0.3.9": - version "0.3.9" - resolved "https://registry.yarnpkg.com/@jridgewell/trace-mapping/-/trace-mapping-0.3.9.tgz#6534fd5933a53ba7cbf3a17615e273a0d1273ff9" - integrity sha512-3Belt6tdc8bPgAtbcmdtNJlirVoTmEb5e2gC94PnkwEW9jI6CAHUeoG85tjWP5WquqfavoMtMwiG4P926ZKKuQ== - dependencies: - "@jridgewell/resolve-uri" "^3.0.3" - "@jridgewell/sourcemap-codec" "^1.4.10" - -"@tsconfig/node10@^1.0.7": - version "1.0.9" - resolved "https://registry.yarnpkg.com/@tsconfig/node10/-/node10-1.0.9.tgz#df4907fc07a886922637b15e02d4cebc4c0021b2" - integrity sha512-jNsYVVxU8v5g43Erja32laIDHXeoNvFEpX33OK4d6hljo3jDhCBDhx5dhCCTMWUojscpAagGiRkBKxpdl9fxqA== - -"@tsconfig/node12@^1.0.7": - version "1.0.11" - resolved "https://registry.yarnpkg.com/@tsconfig/node12/-/node12-1.0.11.tgz#ee3def1f27d9ed66dac6e46a295cffb0152e058d" - integrity sha512-cqefuRsh12pWyGsIoBKJA9luFu3mRxCA+ORZvA4ktLSzIuCUtWVxGIuXigEwO5/ywWFMZ2QEGKWvkZG1zDMTag== - -"@tsconfig/node14@^1.0.0": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@tsconfig/node14/-/node14-1.0.3.tgz#e4386316284f00b98435bf40f72f75a09dabf6c1" - integrity sha512-ysT8mhdixWK6Hw3i1V2AeRqZ5WfXg1G43mqoYlM2nc6388Fq5jcXyr5mRsqViLx/GJYdoL0bfXD8nmF+Zn/Iow== - -"@tsconfig/node16@^1.0.2": - version "1.0.3" - resolved "https://registry.yarnpkg.com/@tsconfig/node16/-/node16-1.0.3.tgz#472eaab5f15c1ffdd7f8628bd4c4f753995ec79e" - integrity sha512-yOlFc+7UtL/89t2ZhjPvvB/DeAr3r+Dq58IgzsFkOAvVC6NMJXmCGjbptdXdR9qsX7pKcTL+s87FtYREi2dEEQ== - -"@types/fastify-cors@^2.1.0": - version "2.1.0" - resolved "https://registry.yarnpkg.com/@types/fastify-cors/-/fastify-cors-2.1.0.tgz#cf09d8f2726c23a6eca8149de26ab19f80bfcbb4" - integrity sha512-o01k3tVq/6kNDv2Q+STSHOsgRPD1jEL5kzhBp6RFu0VSHdyUW6WnOctuS1gC9mdlZyuldGR0Eo8vdkP8ZrPa8g== - dependencies: - fastify-cors "*" - -"@types/node@^18.0.2": - version "18.0.6" - resolved "https://registry.yarnpkg.com/@types/node/-/node-18.0.6.tgz#0ba49ac517ad69abe7a1508bc9b3a5483df9d5d7" - integrity sha512-/xUq6H2aQm261exT6iZTMifUySEt4GR5KX8eYyY+C4MSNPqSh9oNIP7tz2GLKTlFaiBbgZNxffoR3CVRG+cljw== - -abbrev@1: - version "1.1.1" - resolved "https://registry.yarnpkg.com/abbrev/-/abbrev-1.1.1.tgz#f8f2c887ad10bf67f634f005b6987fed3179aac8" - integrity sha512-nne9/IiQ/hzIhY6pdDnbBtz7DjPTKrY00P/zvPSm5pOFkl6xuGrGnXn/VtTNNfNtAfZ9/1RtehkszU9qcTii0Q== - -abort-controller@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/abort-controller/-/abort-controller-3.0.0.tgz#eaf54d53b62bae4138e809ca225c8439a6efb392" - integrity sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg== - dependencies: - event-target-shim "^5.0.0" - -abstract-logging@^2.0.1: - version "2.0.1" - resolved "https://registry.yarnpkg.com/abstract-logging/-/abstract-logging-2.0.1.tgz#6b0c371df212db7129b57d2e7fcf282b8bf1c839" - integrity sha512-2BjRTZxTPvheOvGbBslFSYOUkr+SjPtOnrLP33f+VIWLzezQpZcqVg7ja3L4dBXmzzgwT+a029jRx5PCi3JuiA== - -acorn-walk@^8.1.1: - version "8.2.0" - resolved "https://registry.yarnpkg.com/acorn-walk/-/acorn-walk-8.2.0.tgz#741210f2e2426454508853a2f44d0ab83b7f69c1" - integrity sha512-k+iyHEuPgSw6SbuDpGQM+06HQUa04DZ3o+F6CSzXMvvI5KMvnaEqXe+YVe555R9nn6GPt404fos4wcgpw12SDA== - -acorn@^8.4.1: - version "8.7.1" - resolved "https://registry.yarnpkg.com/acorn/-/acorn-8.7.1.tgz#0197122c843d1bf6d0a5e83220a788f278f63c30" - integrity sha512-Xx54uLJQZ19lKygFXOWsscKUbsBZW0CPykPhVQdhIeIwrbPmJzqeASDInc8nKBnp/JT6igTs82qPXz069H8I/A== - -ajv-formats@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/ajv-formats/-/ajv-formats-2.1.1.tgz#6e669400659eb74973bbf2e33327180a0996b520" - integrity sha512-Wx0Kx52hxE7C18hkMEggYlEifqWZtYaRgouJor+WMdPnQyEK13vgEWyVNup7SoeeoLMsr4kf5h6dOW11I15MUA== - dependencies: - ajv "^8.0.0" - -ajv@^8.0.0, ajv@^8.10.0: - version "8.11.0" - resolved "https://registry.yarnpkg.com/ajv/-/ajv-8.11.0.tgz#977e91dd96ca669f54a11e23e378e33b884a565f" - integrity sha512-wGgprdCvMalC0BztXvitD2hC04YffAvtsUn93JbGXYLAtCUO4xd17mCCZQxUOItiBwZvJScWo8NIvQMQ71rdpg== - dependencies: - fast-deep-equal "^3.1.1" - json-schema-traverse "^1.0.0" - require-from-string "^2.0.2" - uri-js "^4.2.2" - -anymatch@~3.1.2: - version "3.1.2" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.2.tgz#c0557c096af32f106198f4f4e2a383537e378716" - integrity sha512-P43ePfOAIupkguHUycrc4qJ9kz8ZiuOUijaETwX7THt0Y/GNK7v0aa8rY816xWjZ7rJdA5XdMcpVFTKMq+RvWg== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - -archy@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40" - integrity sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw== - -arg@^4.1.0: - version "4.1.3" - resolved "https://registry.yarnpkg.com/arg/-/arg-4.1.3.tgz#269fc7ad5b8e42cb63c896d5666017261c144089" - integrity sha512-58S9QDqG0Xx27YwPSt9fJxivjYl432YCwfDMfZ+71RAqUrZef7LrKQZ3LHLOwCS4FLNBplP533Zx895SeOCHvA== - -ascii-url-encoder@^1.2.0: - version "1.2.0" - resolved "https://registry.yarnpkg.com/ascii-url-encoder/-/ascii-url-encoder-1.2.0.tgz#0a49fe3ccdfc63a24d0f0585517d4cdc80c403de" - integrity sha512-jRQMrz1ZqL7gnK60Xbu1S8kDi01UN+lHBnhvXZZqjd7nms7t4jOv4o9nE8bbfDh1Ts/KEtW2nXGR5CmydDBmlw== - -asynckit@^0.4.0: - version "0.4.0" - resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" - integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q== - -atomic-sleep@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/atomic-sleep/-/atomic-sleep-1.0.0.tgz#eb85b77a601fc932cfe432c5acd364a9e2c9075b" - integrity sha512-kNOjDqAh7px0XWNI+4QbzoiR/nTkHAWNud2uvnJquD1/x5a7EQZMJT0AczqK0Qn67oY/TTQ1LbUKajZpp3I9tQ== - -avvio@^8.1.3: - version "8.2.0" - resolved "https://registry.yarnpkg.com/avvio/-/avvio-8.2.0.tgz#aff28b0266617bf07ffc1c2d5f4220c3663ce1c2" - integrity sha512-bbCQdg7bpEv6kGH41RO/3B2/GMMmJSo2iBK+X8AWN9mujtfUipMDfIjsgHCfpnKqoGEQrrmCDKSa5OQ19+fDmg== - dependencies: - archy "^1.0.0" - debug "^4.0.0" - fastq "^1.6.1" - -axios@^0.27.2: - version "0.27.2" - resolved "https://registry.yarnpkg.com/axios/-/axios-0.27.2.tgz#207658cc8621606e586c85db4b41a750e756d972" - integrity sha512-t+yRIyySRTp/wua5xEr+z1q60QmLq8ABsS5O9Me1AsE5dfKqgnCFzwiCZZ/cGNd1lq4/7akDWMxdhVlucjmnOQ== - dependencies: - follow-redirects "^1.14.9" - form-data "^4.0.0" - -balanced-match@^1.0.0: - version "1.0.2" - resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee" - integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw== - -binary-extensions@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" - integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== - -boolbase@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/boolbase/-/boolbase-1.0.0.tgz#68dff5fbe60c51eb37725ea9e3ed310dcc1e776e" - integrity sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww== - -brace-expansion@^1.1.7: - version "1.1.11" - resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd" - integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA== - dependencies: - balanced-match "^1.0.0" - concat-map "0.0.1" - -braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -cheerio-select@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/cheerio-select/-/cheerio-select-2.1.0.tgz#4d8673286b8126ca2a8e42740d5e3c4884ae21b4" - integrity sha512-9v9kG0LvzrlcungtnJtpGNxY+fzECQKhK4EGJX2vByejiMX84MFNQw4UxPJl3bFbTMw+Dfs37XaIkCwTZfLh4g== - dependencies: - boolbase "^1.0.0" - css-select "^5.1.0" - css-what "^6.1.0" - domelementtype "^2.3.0" - domhandler "^5.0.3" - domutils "^3.0.1" - -cheerio@^1.0.0-rc.11: - version "1.0.0-rc.12" - resolved "https://registry.yarnpkg.com/cheerio/-/cheerio-1.0.0-rc.12.tgz#788bf7466506b1c6bf5fae51d24a2c4d62e47683" - integrity sha512-VqR8m68vM46BNnuZ5NtnGBKIE/DfN0cRIzg9n40EIq9NOv90ayxLBXA8fXC5gquFRGJSTRqBq25Jt2ECLR431Q== - dependencies: - cheerio-select "^2.1.0" - dom-serializer "^2.0.0" - domhandler "^5.0.3" - domutils "^3.0.1" - htmlparser2 "^8.0.1" - parse5 "^7.0.0" - parse5-htmlparser2-tree-adapter "^7.0.0" - -chokidar@^3.5.2: - version "3.5.3" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" - integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - -combined-stream@^1.0.8: - version "1.0.8" - resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" - integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg== - dependencies: - delayed-stream "~1.0.0" - -concat-map@0.0.1: - version "0.0.1" - resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b" - integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg== - -cookie@^0.5.0: - version "0.5.0" - resolved "https://registry.yarnpkg.com/cookie/-/cookie-0.5.0.tgz#d1f5d71adec6558c58f389987c366aa47e994f8b" - integrity sha512-YZ3GUyn/o8gfKJlnlX7g7xq4gyO6OSuhGPKaaGssGB2qgDUS0gPgtTvoyZLTt9Ab6dC4hfc9dV5arkvc/OCmrw== - -create-require@^1.1.0: - version "1.1.1" - resolved "https://registry.yarnpkg.com/create-require/-/create-require-1.1.1.tgz#c1d7e8f1e5f6cfc9ff65f9cd352d37348756c333" - integrity sha512-dcKFX3jn0MpIaXjisoRvexIJVEKzaq7z2rZKxf+MSr9TkdmHmsU4m2lcLojrj/FHl8mk5VxMmYA+ftRkP/3oKQ== - -crypto-js@^4.1.1: - version "4.1.1" - resolved "https://registry.yarnpkg.com/crypto-js/-/crypto-js-4.1.1.tgz#9e485bcf03521041bd85844786b83fb7619736cf" - integrity sha512-o2JlM7ydqd3Qk9CA0L4NL6mTzU2sdx96a+oOfPu8Mkl/PK51vSyoi8/rQ8NknZtk44vq15lmhAj9CIAGwgeWKw== - -css-select@^5.1.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/css-select/-/css-select-5.1.0.tgz#b8ebd6554c3637ccc76688804ad3f6a6fdaea8a6" - integrity sha512-nwoRF1rvRRnnCqqY7updORDsuqKzqYJ28+oSMaJMMgOauh3fvwHqMS7EZpIPqK8GL+g9mKxF1vP/ZjSeNjEVHg== - dependencies: - boolbase "^1.0.0" - css-what "^6.1.0" - domhandler "^5.0.2" - domutils "^3.0.1" - nth-check "^2.0.1" - -css-what@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/css-what/-/css-what-6.1.0.tgz#fb5effcf76f1ddea2c81bdfaa4de44e79bac70f4" - integrity sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw== - -debug@^3.2.7: - version "3.2.7" - resolved "https://registry.yarnpkg.com/debug/-/debug-3.2.7.tgz#72580b7e9145fb39b6676f9c5e5fb100b934179a" - integrity sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ== - dependencies: - ms "^2.1.1" - -debug@^4.0.0: - version "4.3.4" - resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865" - integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ== - dependencies: - ms "2.1.2" - -delayed-stream@~1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" - integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== - -diff@^4.0.1: - version "4.0.2" - resolved "https://registry.yarnpkg.com/diff/-/diff-4.0.2.tgz#60f3aecb89d5fae520c11aa19efc2bb982aade7d" - integrity sha512-58lmxKSA4BNyLz+HHMUzlOEpg09FV+ev6ZMe3vJihgdxzgcwZ8VoEEPmALCZG9LmqfVoNMMKpttIYTVG6uDY7A== - -dom-serializer@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/dom-serializer/-/dom-serializer-2.0.0.tgz#e41b802e1eedf9f6cae183ce5e622d789d7d8e53" - integrity sha512-wIkAryiqt/nV5EQKqQpo3SToSOV9J0DnbJqwK7Wv/Trc92zIAYZ4FlMu+JPFW1DfGFt81ZTCGgDEabffXeLyJg== - dependencies: - domelementtype "^2.3.0" - domhandler "^5.0.2" - entities "^4.2.0" - -domelementtype@^2.3.0: - version "2.3.0" - resolved "https://registry.yarnpkg.com/domelementtype/-/domelementtype-2.3.0.tgz#5c45e8e869952626331d7aab326d01daf65d589d" - integrity sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw== - -domhandler@^5.0.1, domhandler@^5.0.2, domhandler@^5.0.3: - version "5.0.3" - resolved "https://registry.yarnpkg.com/domhandler/-/domhandler-5.0.3.tgz#cc385f7f751f1d1fc650c21374804254538c7d31" - integrity sha512-cgwlv/1iFQiFnU96XXgROh8xTeetsnJiDsTc7TYCLFd9+/WNkIqPTxiM/8pSd8VIrhXGTf1Ny1q1hquVqDJB5w== - dependencies: - domelementtype "^2.3.0" - -domutils@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/domutils/-/domutils-3.0.1.tgz#696b3875238338cb186b6c0612bd4901c89a4f1c" - integrity sha512-z08c1l761iKhDFtfXO04C7kTdPBLi41zwOZl00WS8b5eiaebNpY00HKbztwBq+e3vyqWNwWF3mP9YLUeqIrF+Q== - dependencies: - dom-serializer "^2.0.0" - domelementtype "^2.3.0" - domhandler "^5.0.1" - -dotenv@^16.0.1: - version "16.0.1" - resolved "https://registry.yarnpkg.com/dotenv/-/dotenv-16.0.1.tgz#8f8f9d94876c35dac989876a5d3a82a267fdce1d" - integrity sha512-1K6hR6wtk2FviQ4kEiSjFiH5rpzEVi8WW0x96aztHVMhEspNpc4DVOUTEHtEva5VThQ8IaBX1Pe4gSzpVVUsKQ== - -entities@^4.2.0, entities@^4.3.0: - version "4.3.1" - resolved "https://registry.yarnpkg.com/entities/-/entities-4.3.1.tgz#c34062a94c865c322f9d67b4384e4169bcede6a4" - integrity sha512-o4q/dYJlmyjP2zfnaWDUC6A3BQFmVTX+tZPezK7k0GLSU9QYCauscf5Y+qcEPzKL+EixVouYDgLQK5H9GrLpkg== - -event-target-shim@^5.0.0: - version "5.0.1" - resolved "https://registry.yarnpkg.com/event-target-shim/-/event-target-shim-5.0.1.tgz#5d4d3ebdf9583d63a5333ce2deb7480ab2b05789" - integrity sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ== - -fast-deep-equal@^3.1.1, fast-deep-equal@^3.1.3: - version "3.1.3" - resolved "https://registry.yarnpkg.com/fast-deep-equal/-/fast-deep-equal-3.1.3.tgz#3a7d56b559d6cbc3eb512325244e619a65c6c525" - integrity sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q== - -fast-json-stringify@^5.0.0: - version "5.1.0" - resolved "https://registry.yarnpkg.com/fast-json-stringify/-/fast-json-stringify-5.1.0.tgz#dc184049d7eed4f61e34f65e97c0763fd043977f" - integrity sha512-IybGfbUc1DQgyrp9Myhwlr1Z5vjV37mBkdgcbuvsvUxv5fayG+cHlTQQpXH9nMwUPgp+5Y3RT7QDgx5zJ9NS3A== - dependencies: - "@fastify/deepmerge" "^1.0.0" - ajv "^8.10.0" - ajv-formats "^2.1.1" - fast-uri "^2.1.0" - rfdc "^1.2.0" - -fast-redact@^3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/fast-redact/-/fast-redact-3.1.1.tgz#790fcff8f808c2e12fabbfb2be5cb2deda448fa0" - integrity sha512-odVmjC8x8jNeMZ3C+rPMESzXVSEU8tSWSHv9HFxP2mm89G/1WwqhrerJDQm9Zus8X6aoRgQDThKqptdNA6bt+A== - -fast-uri@^2.0.0, fast-uri@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/fast-uri/-/fast-uri-2.1.0.tgz#9279432d6b53675c90116b947ed2bbba582d6fb5" - integrity sha512-qKRta6N7BWEFVlyonVY/V+BMLgFqktCUV0QjT259ekAIlbVrMaFnFLxJ4s/JPl4tou56S1BzPufI60bLe29fHA== - -"fastify-cors-deprecated@npm:fastify-cors@6.0.3": - version "6.0.3" - resolved "https://registry.yarnpkg.com/fastify-cors/-/fastify-cors-6.0.3.tgz#1907f92c3f855a18ef6fb6213186c73cf0bbf9e4" - integrity sha512-fMbXubKKyBHHCfSBtsCi3+7VyVRdhJQmGes5gM+eGKkRErCdm0NaYO0ozd31BQBL1ycoTIjbqOZhJo4RTF/Vlg== - dependencies: - fastify-plugin "^3.0.0" - vary "^1.1.2" - -fastify-cors@*, fastify-cors@^6.1.0: - version "6.1.0" - resolved "https://registry.yarnpkg.com/fastify-cors/-/fastify-cors-6.1.0.tgz#b47bd7faf29113a884e59413ee198a9c323cf180" - integrity sha512-QBKz32IoY/iuT74CunRY1XOSpjSTIOh9E3FxulXIBhd0D2vdgG0kDvy0eG6HA/88sRfWHeba43LkGEXPz0Rh8g== - dependencies: - fastify-cors-deprecated "npm:fastify-cors@6.0.3" - process-warning "^1.0.0" - -fastify-plugin@^3.0.0: - version "3.0.1" - resolved "https://registry.yarnpkg.com/fastify-plugin/-/fastify-plugin-3.0.1.tgz#79e84c29f401020f38b524f59f2402103fd21ed2" - integrity sha512-qKcDXmuZadJqdTm6vlCqioEbyewF60b/0LOFCcYN1B6BIZGlYJumWWOYs70SFYLDAH4YqdE1cxH/RKMG7rFxgA== - -fastify@^4.2.0: - version "4.2.1" - resolved "https://registry.yarnpkg.com/fastify/-/fastify-4.2.1.tgz#44bc04dde3f769527851950da46c8ee32227233c" - integrity sha512-eyAWHN9+8IPTnhvGz+leseASGV/JZ75Y+jXXV7tid4awUjCMInY1gazZXuTD95xUW+Ve5vfgLjQ2i1i0/XJjdw== - dependencies: - "@fastify/ajv-compiler" "^3.1.1" - "@fastify/error" "^3.0.0" - "@fastify/fast-json-stringify-compiler" "^4.0.0" - abstract-logging "^2.0.1" - avvio "^8.1.3" - find-my-way "^7.0.0" - light-my-request "^5.0.0" - pino "^8.0.0" - process-warning "^2.0.0" - proxy-addr "^2.0.7" - rfdc "^1.3.0" - secure-json-parse "^2.4.0" - semver "^7.3.7" - tiny-lru "^8.0.2" - -fastq@^1.6.1: - version "1.13.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.13.0.tgz#616760f88a7526bdfc596b7cab8c18938c36b98c" - integrity sha512-YpkpUnK8od0o1hmeSc7UUs/eB/vIPWJYjKck2QKIzAf71Vm1AAQ3EbuZB3g2JIy+pg+ERD0vqI79KyZiB2e2Nw== - dependencies: - reusify "^1.0.4" - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - -find-my-way@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/find-my-way/-/find-my-way-7.0.0.tgz#8e79fde2606624af61775e3d097da4f1872e58d9" - integrity sha512-NHVohYPYRXgj6jxXVRwm4iMQjA2ggJpyewHz7Nq7hvBnHoYJJIyHuxNzs8QLPTLQfoqxZzls2g6Zm79XMbhXjA== - dependencies: - fast-deep-equal "^3.1.3" - safe-regex2 "^2.0.0" - -follow-redirects@^1.14.9: - version "1.15.1" - resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.1.tgz#0ca6a452306c9b276e4d3127483e29575e207ad5" - integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA== - -form-data@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/form-data/-/form-data-4.0.0.tgz#93919daeaf361ee529584b9b31664dc12c9fa452" - integrity sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww== - dependencies: - asynckit "^0.4.0" - combined-stream "^1.0.8" - mime-types "^2.1.12" - -forwarded@0.2.0: - version "0.2.0" - resolved "https://registry.yarnpkg.com/forwarded/-/forwarded-0.2.0.tgz#2269936428aad4c15c7ebe9779a84bf0b2a81811" - integrity sha512-buRG0fpBtRHSTCOASe6hD258tEubFoRLb4ZNA6NxMVHNw2gOcwHo9wyablzMzOA5z9xA9L1KNjk/Nt6MT9aYow== - -fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - -glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -has-flag@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-3.0.0.tgz#b5d454dc2199ae225699f3467e5a07f3b955bafd" - integrity sha512-sKJf1+ceQBr4SMkvQnBDNDtf4TXpVhVGateu0t918bl30FnbE2m4vNLX+VWe/dpjlb+HugGYzW7uQXH98HPEYw== - -htmlparser2@^8.0.1: - version "8.0.1" - resolved "https://registry.yarnpkg.com/htmlparser2/-/htmlparser2-8.0.1.tgz#abaa985474fcefe269bc761a779b544d7196d010" - integrity sha512-4lVbmc1diZC7GUJQtRQ5yBAeUCL1exyMwmForWkRLnwyzWBFxN633SALPMGYaWZvKe9j1pRZJpauvmxENSp/EA== - dependencies: - domelementtype "^2.3.0" - domhandler "^5.0.2" - domutils "^3.0.1" - entities "^4.3.0" - -ignore-by-default@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/ignore-by-default/-/ignore-by-default-1.0.1.tgz#48ca6d72f6c6a3af00a9ad4ae6876be3889e2b09" - integrity sha512-Ius2VYcGNk7T90CppJqcIkS5ooHUZyIQK+ClZfMfMNFEF9VSE73Fq+906u/CWu92x4gzZMWOwfFYckPObzdEbA== - -ipaddr.js@1.9.1: - version "1.9.1" - resolved "https://registry.yarnpkg.com/ipaddr.js/-/ipaddr.js-1.9.1.tgz#bff38543eeb8984825079ff3a2a8e6cbd46781b3" - integrity sha512-0KI/607xoxSToH7GjN1FfSbLoU0+btTicjsQSWQlh/hZykN8KpmMf7uYwPW3R+akZ6R/w18ZlXSHBYXiYUPO3g== - -is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== - -is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== - dependencies: - is-extglob "^2.1.1" - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - -json-schema-traverse@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/json-schema-traverse/-/json-schema-traverse-1.0.0.tgz#ae7bcb3656ab77a73ba5c49bf654f38e6b6860e2" - integrity sha512-NM8/P9n3XjXhIZn1lLhkFaACTOURQXjWhV4BA/RnOv8xvgqtqpAX9IO4mRQxSx1Rlo4tqzeqb0sOlruaOy3dug== - -light-my-request@^5.0.0: - version "5.2.0" - resolved "https://registry.yarnpkg.com/light-my-request/-/light-my-request-5.2.0.tgz#b3927b63ae570726fcef755145b4ac0f6eb8c359" - integrity sha512-U5Dga8U59VKydIAnHt2XvPVyDfaHsDIpoO+/FPrm4Qnn1tHeczNnLrGjI1bko6BFWgFwTXjTiQN6PkohWiwwcA== - dependencies: - cookie "^0.5.0" - process-warning "^2.0.0" - set-cookie-parser "^2.4.1" - -lru-cache@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94" - integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA== - dependencies: - yallist "^4.0.0" - -make-error@^1.1.1: - version "1.3.6" - resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2" - integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw== - -mime-db@1.52.0: - version "1.52.0" - resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" - integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg== - -mime-types@^2.1.12: - version "2.1.35" - resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a" - integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw== - dependencies: - mime-db "1.52.0" - -minimatch@^3.0.4: - version "3.1.2" - resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b" - integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw== - dependencies: - brace-expansion "^1.1.7" - -ms@2.1.2: - version "2.1.2" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009" - integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w== - -ms@^2.1.1: - version "2.1.3" - resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2" - integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA== - -nodemon@^2.0.19: - version "2.0.19" - resolved "https://registry.yarnpkg.com/nodemon/-/nodemon-2.0.19.tgz#cac175f74b9cb8b57e770d47841995eebe4488bd" - integrity sha512-4pv1f2bMDj0Eeg/MhGqxrtveeQ5/G/UVe9iO6uTZzjnRluSA4PVWf8CW99LUPwGB3eNIA7zUFoP77YuI7hOc0A== - dependencies: - chokidar "^3.5.2" - debug "^3.2.7" - ignore-by-default "^1.0.1" - minimatch "^3.0.4" - pstree.remy "^1.1.8" - semver "^5.7.1" - simple-update-notifier "^1.0.7" - supports-color "^5.5.0" - touch "^3.1.0" - undefsafe "^2.0.5" - -nopt@~1.0.10: - version "1.0.10" - resolved "https://registry.yarnpkg.com/nopt/-/nopt-1.0.10.tgz#6ddd21bd2a31417b92727dd585f8a6f37608ebee" - integrity sha512-NWmpvLSqUrgrAC9HCuxEvb+PSloHpqVu+FqcO4eeF2h5qYRhA7ev6KvelyQAKtegUbC6RypJnlEOhd8vloNKYg== - dependencies: - abbrev "1" - -normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - -nth-check@^2.0.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/nth-check/-/nth-check-2.1.1.tgz#c9eab428effce36cd6b92c924bdb000ef1f1ed1d" - integrity sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w== - dependencies: - boolbase "^1.0.0" - -on-exit-leak-free@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/on-exit-leak-free/-/on-exit-leak-free-2.1.0.tgz#5c703c968f7e7f851885f6459bf8a8a57edc9cc4" - integrity sha512-VuCaZZAjReZ3vUwgOB8LxAosIurDiAW0s13rI1YwmaP++jvcxP77AWoQvenZebpCA2m8WC1/EosPYPMjnRAp/w== - -parse5-htmlparser2-tree-adapter@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/parse5-htmlparser2-tree-adapter/-/parse5-htmlparser2-tree-adapter-7.0.0.tgz#23c2cc233bcf09bb7beba8b8a69d46b08c62c2f1" - integrity sha512-B77tOZrqqfUfnVcOrUvfdLbz4pu4RopLD/4vmu3HUPswwTA8OH0EMW9BlWR2B0RCoiZRAHEUu7IxeP1Pd1UU+g== - dependencies: - domhandler "^5.0.2" - parse5 "^7.0.0" - -parse5@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/parse5/-/parse5-7.0.0.tgz#51f74a5257f5fcc536389e8c2d0b3802e1bfa91a" - integrity sha512-y/t8IXSPWTuRZqXc0ajH/UwDj4mnqLEbSttNbThcFhGrZuOyoyvNBO85PBp2jQa55wY9d07PBNjsK8ZP3K5U6g== - dependencies: - entities "^4.3.0" - -picomatch@^2.0.4, picomatch@^2.2.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - -pino-abstract-transport@v1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/pino-abstract-transport/-/pino-abstract-transport-1.0.0.tgz#cc0d6955fffcadb91b7b49ef220a6cc111d48bb3" - integrity sha512-c7vo5OpW4wIS42hUVcT5REsL8ZljsUfBjqV/e2sFxmFEFZiq1XLUp5EYLtuDH6PEHq9W1egWqRbnLUP5FuZmOA== - dependencies: - readable-stream "^4.0.0" - split2 "^4.0.0" - -pino-std-serializers@^6.0.0: - version "6.0.0" - resolved "https://registry.yarnpkg.com/pino-std-serializers/-/pino-std-serializers-6.0.0.tgz#4c20928a1bafca122fdc2a7a4a171ca1c5f9c526" - integrity sha512-mMMOwSKrmyl+Y12Ri2xhH1lbzQxwwpuru9VjyJpgFIH4asSj88F2csdMwN6+M5g1Ll4rmsYghHLQJw81tgZ7LQ== - -pino@^8.0.0: - version "8.2.0" - resolved "https://registry.yarnpkg.com/pino/-/pino-8.2.0.tgz#8e4b49becab5bcc6ab683ad1e6fc71293776cb31" - integrity sha512-HS7+vUpOYEJcNZkyb2ujN2sSayXLyz5XEvDZw4vrxlxHDe34qIDiNf2s+0dD/q/eqEubfxwAItYhY6zCNVZBVw== - dependencies: - atomic-sleep "^1.0.0" - fast-redact "^3.1.1" - on-exit-leak-free "^2.1.0" - pino-abstract-transport v1.0.0 - pino-std-serializers "^6.0.0" - process-warning "^2.0.0" - quick-format-unescaped "^4.0.3" - real-require "^0.1.0" - safe-stable-stringify "^2.3.1" - sonic-boom "^3.0.0" - thread-stream "^2.0.0" - -process-warning@^1.0.0: - version "1.0.0" - resolved "https://registry.yarnpkg.com/process-warning/-/process-warning-1.0.0.tgz#980a0b25dc38cd6034181be4b7726d89066b4616" - integrity sha512-du4wfLyj4yCZq1VupnVSZmRsPJsNuxoDQFdCFHLaYiEbFBD7QE0a+I4D7hOxrVnh78QE/YipFAj9lXHiXocV+Q== - -process-warning@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/process-warning/-/process-warning-2.0.0.tgz#341dbeaac985b90a04ebcd844d50097c7737b2ee" - integrity sha512-+MmoAXoUX+VTHAlwns0h+kFUWFs/3FZy+ZuchkgjyOu3oioLAo2LB5aCfKPh2+P9O18i3m43tUEv3YqttSy0Ww== - -proxy-addr@^2.0.7: - version "2.0.7" - resolved "https://registry.yarnpkg.com/proxy-addr/-/proxy-addr-2.0.7.tgz#f19fe69ceab311eeb94b42e70e8c2070f9ba1025" - integrity sha512-llQsMLSUDUPT44jdrU/O37qlnifitDP+ZwrmmZcoSKyLKvtZxpyV0n2/bD/N4tBAAZ/gJEdZU7KMraoK1+XYAg== - dependencies: - forwarded "0.2.0" - ipaddr.js "1.9.1" - -pstree.remy@^1.1.8: - version "1.1.8" - resolved "https://registry.yarnpkg.com/pstree.remy/-/pstree.remy-1.1.8.tgz#c242224f4a67c21f686839bbdb4ac282b8373d3a" - integrity sha512-77DZwxQmxKnu3aR542U+X8FypNzbfJ+C5XQDk3uWjWxn6151aIMGthWYRXTqT1E5oJvg+ljaa2OJi+VfvCOQ8w== - -punycode@^2.1.0: - version "2.1.1" - resolved "https://registry.yarnpkg.com/punycode/-/punycode-2.1.1.tgz#b58b010ac40c22c5657616c8d2c2c02c7bf479ec" - integrity sha512-XRsRjdf+j5ml+y/6GKHPZbrF/8p2Yga0JPtdqTIY2Xe5ohJPD9saDJJLPvp9+NSBprVvevdXZybnj2cv8OEd0A== - -quick-format-unescaped@^4.0.3: - version "4.0.4" - resolved "https://registry.yarnpkg.com/quick-format-unescaped/-/quick-format-unescaped-4.0.4.tgz#93ef6dd8d3453cbc7970dd614fad4c5954d6b5a7" - integrity sha512-tYC1Q1hgyRuHgloV/YXs2w15unPVh8qfu/qCTfhTYamaw7fyhumKa2yGpdSo87vY32rIclj+4fWYQXUMs9EHvg== - -readable-stream@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-4.1.0.tgz#280d0a29f559d3fb684a277254e02b6f61ae0631" - integrity sha512-sVisi3+P2lJ2t0BPbpK629j8wRW06yKGJUcaLAGXPAUhyUxVJm7VsCTit1PFgT4JHUDMrGNR+ZjSKpzGaRF3zw== - dependencies: - abort-controller "^3.0.0" - -readdirp@~3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" - integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== - dependencies: - picomatch "^2.2.1" - -real-require@^0.1.0: - version "0.1.0" - resolved "https://registry.yarnpkg.com/real-require/-/real-require-0.1.0.tgz#736ac214caa20632847b7ca8c1056a0767df9381" - integrity sha512-r/H9MzAWtrv8aSVjPCMFpDMl5q66GqtmmRkRjpHTsp4zBAa+snZyiQNlMONiUmEJcsnaw0wCauJ2GWODr/aFkg== - -require-from-string@^2.0.2: - version "2.0.2" - resolved "https://registry.yarnpkg.com/require-from-string/-/require-from-string-2.0.2.tgz#89a7fdd938261267318eafe14f9c32e598c36909" - integrity sha512-Xf0nWe6RseziFMu+Ap9biiUbmplq6S9/p+7w7YXP/JBHhrUDDUhwa+vANyubuqfZWTveU//DYVGsDG7RKL/vEw== - -ret@~0.2.0: - version "0.2.2" - resolved "https://registry.yarnpkg.com/ret/-/ret-0.2.2.tgz#b6861782a1f4762dce43402a71eb7a283f44573c" - integrity sha512-M0b3YWQs7R3Z917WRQy1HHA7Ba7D8hvZg6UE5mLykJxQVE2ju0IXbGlaHPPlkY+WN7wFP+wUMXmBFA0aV6vYGQ== - -reusify@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" - integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== - -rfdc@^1.2.0, rfdc@^1.3.0: - version "1.3.0" - resolved "https://registry.yarnpkg.com/rfdc/-/rfdc-1.3.0.tgz#d0b7c441ab2720d05dc4cf26e01c89631d9da08b" - integrity sha512-V2hovdzFbOi77/WajaSMXk2OLm+xNIeQdMMuB7icj7bk6zi2F8GGAxigcnDFpJHbNyNcgyJDiP+8nOrY5cZGrA== - -safe-regex2@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/safe-regex2/-/safe-regex2-2.0.0.tgz#b287524c397c7a2994470367e0185e1916b1f5b9" - integrity sha512-PaUSFsUaNNuKwkBijoAPHAK6/eM6VirvyPWlZ7BAQy4D+hCvh4B6lIG+nPdhbFfIbP+gTGBcrdsOaUs0F+ZBOQ== - dependencies: - ret "~0.2.0" - -safe-stable-stringify@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/safe-stable-stringify/-/safe-stable-stringify-2.3.1.tgz#ab67cbe1fe7d40603ca641c5e765cb942d04fc73" - integrity sha512-kYBSfT+troD9cDA85VDnHZ1rpHC50O0g1e6WlGHVCz/g+JS+9WKLj+XwFYyR8UbrZN8ll9HUpDAAddY58MGisg== - -secure-json-parse@^2.4.0: - version "2.4.0" - resolved "https://registry.yarnpkg.com/secure-json-parse/-/secure-json-parse-2.4.0.tgz#5aaeaaef85c7a417f76271a4f5b0cc3315ddca85" - integrity sha512-Q5Z/97nbON5t/L/sH6mY2EacfjVGwrCcSi5D3btRO2GZ8pf1K1UN7Z9H5J57hjVU2Qzxr1xO+FmBhOvEkzCMmg== - -semver@^5.7.1: - version "5.7.1" - resolved "https://registry.yarnpkg.com/semver/-/semver-5.7.1.tgz#a954f931aeba508d307bbf069eff0c01c96116f7" - integrity sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ== - -semver@^7.3.7: - version "7.3.7" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.7.tgz#12c5b649afdbf9049707796e22a4028814ce523f" - integrity sha512-QlYTucUYOews+WeEujDoEGziz4K6c47V/Bd+LjSSYcA94p+DmINdf7ncaUinThfvZyu13lN9OY1XDxt8C0Tw0g== - dependencies: - lru-cache "^6.0.0" - -semver@~7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/semver/-/semver-7.0.0.tgz#5f3ca35761e47e05b206c6daff2cf814f0316b8e" - integrity sha512-+GB6zVA9LWh6zovYQLALHwv5rb2PHGlJi3lfiqIHxR0uuwCgefcOJc59v9fv1w8GbStwxuuqqAjI9NMAOOgq1A== - -set-cookie-parser@^2.4.1: - version "2.5.0" - resolved "https://registry.yarnpkg.com/set-cookie-parser/-/set-cookie-parser-2.5.0.tgz#96b59525e1362c94335c3c761100bb6e8f2da4b0" - integrity sha512-cHMAtSXilfyBePduZEBVPTCftTQWz6ehWJD5YNUg4mqvRosrrjKbo4WS8JkB0/RxonMoohHm7cOGH60mDkRQ9w== - -simple-update-notifier@^1.0.7: - version "1.0.7" - resolved "https://registry.yarnpkg.com/simple-update-notifier/-/simple-update-notifier-1.0.7.tgz#7edf75c5bdd04f88828d632f762b2bc32996a9cc" - integrity sha512-BBKgR84BJQJm6WjWFMHgLVuo61FBDSj1z/xSFUIozqO6wO7ii0JxCqlIud7Enr/+LhlbNI0whErq96P2qHNWew== - dependencies: - semver "~7.0.0" - -sonic-boom@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/sonic-boom/-/sonic-boom-3.0.0.tgz#235119a6606e2646919a27d83ef687f2ba6c0fba" - integrity sha512-p5DiZOZHbJ2ZO5MADczp5qrfOd3W5Vr2vHxfCpe7G4AzPwVOweIjbfgku8wSQUuk+Y5Yuo8W7JqRe6XKmKistg== - dependencies: - atomic-sleep "^1.0.0" - -split2@^4.0.0: - version "4.1.0" - resolved "https://registry.yarnpkg.com/split2/-/split2-4.1.0.tgz#101907a24370f85bb782f08adaabe4e281ecf809" - integrity sha512-VBiJxFkxiXRlUIeyMQi8s4hgvKCSjtknJv/LVYbrgALPwf5zSKmEwV9Lst25AkvMDnvxODugjdl6KZgwKM1WYQ== - -supports-color@^5.5.0: - version "5.5.0" - resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-5.5.0.tgz#e2e69a44ac8772f78a1ec0b35b689df6530efc8f" - integrity sha512-QjVjwdXIt408MIiAqCX4oUKsgU2EqAGzs2Ppkm4aQYbjm+ZEWEcW4SfFNTr4uMNZma0ey4f5lgLrkB0aX0QMow== - dependencies: - has-flag "^3.0.0" - -thread-stream@^2.0.0: - version "2.0.0" - resolved "https://registry.yarnpkg.com/thread-stream/-/thread-stream-2.0.0.tgz#1ecb450324ebb1bb284d4398b8af15cb6905028c" - integrity sha512-tnbzCbIrA4Khq5SJt/Fyz5DlE8pUnPR3//nWv+cqdRktvAl2NuC9O08HHq2Ifa10bhkvHLuzcesNjaH15EgTXA== - dependencies: - real-require "^0.1.0" - -tiny-lru@^8.0.2: - version "8.0.2" - resolved "https://registry.yarnpkg.com/tiny-lru/-/tiny-lru-8.0.2.tgz#812fccbe6e622ded552e3ff8a4c3b5ff34a85e4c" - integrity sha512-ApGvZ6vVvTNdsmt676grvCkUCGwzG9IqXma5Z07xJgiC5L7akUMof5U8G2JTI9Rz/ovtVhJBlY6mNhEvtjzOIg== - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -touch@^3.1.0: - version "3.1.0" - resolved "https://registry.yarnpkg.com/touch/-/touch-3.1.0.tgz#fe365f5f75ec9ed4e56825e0bb76d24ab74af83b" - integrity sha512-WBx8Uy5TLtOSRtIq+M03/sKDrXCLHxwDcquSP2c43Le03/9serjQBIztjRz6FkJez9D/hleyAXTBGLwwZUw9lA== - dependencies: - nopt "~1.0.10" - -ts-node@^10.9.1: - version "10.9.1" - resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-10.9.1.tgz#e73de9102958af9e1f0b168a6ff320e25adcff4b" - integrity sha512-NtVysVPkxxrwFGUUxGYhfux8k78pQB3JqYBXlLRZgdGUqTO5wU/UyHop5p70iEbGhB7q5KmiZiU0Y3KlJrScEw== - dependencies: - "@cspotcode/source-map-support" "^0.8.0" - "@tsconfig/node10" "^1.0.7" - "@tsconfig/node12" "^1.0.7" - "@tsconfig/node14" "^1.0.0" - "@tsconfig/node16" "^1.0.2" - acorn "^8.4.1" - acorn-walk "^8.1.1" - arg "^4.1.0" - create-require "^1.1.0" - diff "^4.0.1" - make-error "^1.1.1" - v8-compile-cache-lib "^3.0.1" - yn "3.1.1" - -typescript@4.7.4: - version "4.7.4" - resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.7.4.tgz#1a88596d1cf47d59507a1bcdfb5b9dfe4d488235" - integrity sha512-C0WQT0gezHuw6AdY1M2jxUO83Rjf0HP7Sk1DtXj6j1EwkQNZrHAg2XPWlq62oqEhYvONq5pkC2Y9oPljWToLmQ== - -undefsafe@^2.0.5: - version "2.0.5" - resolved "https://registry.yarnpkg.com/undefsafe/-/undefsafe-2.0.5.tgz#38733b9327bdcd226db889fb723a6efd162e6e2c" - integrity sha512-WxONCrssBM8TSPRqN5EmsjVrsv4A8X12J4ArBiiayv3DyyG3ZlIg6yysuuSYdZsVz3TKcTg2fd//Ujd4CHV1iA== - -uri-js@^4.2.2: - version "4.4.1" - resolved "https://registry.yarnpkg.com/uri-js/-/uri-js-4.4.1.tgz#9b1a52595225859e55f669d928f88c6c57f2a77e" - integrity sha512-7rKUyy33Q1yc98pQ1DAmLtwX109F7TIfWlW1Ydo8Wl1ii1SeHieeh0HHfPeL2fMXK6z0s8ecKs9frCuLJvndBg== - dependencies: - punycode "^2.1.0" - -v8-compile-cache-lib@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/v8-compile-cache-lib/-/v8-compile-cache-lib-3.0.1.tgz#6336e8d71965cb3d35a1bbb7868445a7c05264bf" - integrity sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg== - -vary@^1.1.2: - version "1.1.2" - resolved "https://registry.yarnpkg.com/vary/-/vary-1.1.2.tgz#2299f02c6ded30d4a5961b0b9f74524a18f634fc" - integrity sha512-BNGbWLfd0eUPabhkXUVm0j8uuvREyTh5ovRa/dyow/BqAbZJyC+5fU+IzQOzmAKzYqYRAISoRhdQr3eIZ/PXqg== - -yallist@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72" - integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A== - -yn@3.1.1: - version "3.1.1" - resolved "https://registry.yarnpkg.com/yn/-/yn-3.1.1.tgz#1e87401a09d767c1d5eab26a6e4c185182d2eb50" - integrity sha512-Ux4ygGWsu2c7isFWe8Yu1YluJmqVhxqK2cLXNQA5AcC3QfbGNpM7fu0Y8b/z16pXLnFxZYvWhd3fhBY9DLmC6Q==