From 008185bdec6b4426dc33832b02342ef218172c81 Mon Sep 17 00:00:00 2001 From: zapolnoch Date: Thu, 11 Sep 2025 00:39:35 +0300 Subject: [PATCH 1/7] refactor: packages --- .env.example | 15 + .gitignore | 1 + .npmrc | 2 + LICENCE.txt | 674 ----------------- README.md | 52 +- docker-compose.yml | 19 + package-lock.json | 1766 ++++++++++++++++++++++++++++++++++++++++++-- package.json | 51 +- tsconfig.json | 13 +- 9 files changed, 1804 insertions(+), 789 deletions(-) create mode 100644 .env.example create mode 100644 .npmrc delete mode 100644 LICENCE.txt create mode 100644 docker-compose.yml diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..740b9f8 --- /dev/null +++ b/.env.example @@ -0,0 +1,15 @@ +BOT_TOKEN="your_telegram_bot_token_here" +API_BASE_URL=http://localhost:5005 +API_AUTH_TOKEN=API_AUTH_TOKEN="your_api_token_here" + +ENV=dev +DAILY_LIMIT_MB=1024 + +DOMAIN="https://example.ngrok-free.app" +PORT=3000 +WEBHOOK_PATH="/telegram/webhook" +GOOGLE_SCRIPT_URL="https://script.google.com/macros/s/id/exec" +FEEDBACK_SECRET_TOKEN="token" +ADMIN_CHAT_ID="id" + +DATABASE_URL="postgresql://postgres:password@localhost:5432/bot?schema=public" diff --git a/.gitignore b/.gitignore index 33097c8..3c1a94e 100644 --- a/.gitignore +++ b/.gitignore @@ -4,3 +4,4 @@ node_modules .DS_Store /src/generated/prisma +data/ diff --git a/.npmrc b/.npmrc new file mode 100644 index 0000000..7833b32 --- /dev/null +++ b/.npmrc @@ -0,0 +1,2 @@ +save-exact=true +fund=false diff --git a/LICENCE.txt b/LICENCE.txt deleted file mode 100644 index f288702..0000000 --- a/LICENCE.txt +++ /dev/null @@ -1,674 +0,0 @@ - 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/README.md b/README.md index b0b358b..50f322b 100644 --- a/README.md +++ b/README.md @@ -1,48 +1,18 @@ -# VPN Telegram Bot +# FRKN VPN Telegram Bot -A Telegram bot for managing VPN connections, implemented in TypeScript. -Description +This bot allows users to create and retrieve VPN configurations (VlessGrpc, VlessXtls, Vmess, Wireguard, etc.) via interactive commands and inline buttons. It communicates with a backend [API server](https://github.com/frkn-dev/pony) that manages users, nodes, and connections. -This bot allows users to create and retrieve VPN configurations (VlessGrpc, VlessXtls, Vmess, Wireguard, etc.) via interactive commands and inline buttons. It communicates with a backend API server that manages users, nodes, and connections. -Features, works with https://github.com/frkn-dev/pony +## Dev-mode -### Installation & Running - -Clone the repository: - -```git clone https://github.com/yourusername/vpn-telegram-bot.git -cd vpn-telegram-bot -``` - -Install dependencies: - -`npm install` - -Create a .env file with your environment variables: - -``` -API_BASE_URL=https://your-api-server.com/api -API_AUTH_TOKEN=your_api_token_here -BOT_TOKEN=your_telegram_bot_token_here +```sh +cp .env.example .env +docker-compose up -d +prisma db push +npm run dev +ngrok http 3000 ``` -Start the bot: - - npm run start - -## Bot Commands - - /start — Start interacting with the bot - - /connect — Select VPN protocol and server - - /sub — Get VPN subscription/configuration - - /stat — View traffic statistics - - /delete — Delete (deactivate) user - -### License +### Requirements -GNU GENERAL PUBLIC LICENSE Version 3 +[Node.js LTS](https://nodejs.org) and [pnpm](https://pnpm.io/installation#using-npm). IDE with [TypeScript](https://code.visualstudio.com/docs/languages/typescript) and [Biome](https://biomejs.dev/guides/integrate-in-editor/) support. diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3958da7 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,19 @@ +version: "3.8" + +services: + db: + image: postgres:latest + container_name: postgres-container + environment: + POSTGRES_PASSWORD: password + + volumes: + - ./data:/var/lib/postgresql/data + ports: + - "127.0.0.1:5432:5432" + networks: + - pony-network + +networks: + pony-network: + driver: bridge diff --git a/package-lock.json b/package-lock.json index 2319906..9e5b8d1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,32 +1,33 @@ { - "name": "vpn-bot", + "name": "frkn-vpn-bot", "version": "1.0.0", "lockfileVersion": 3, "requires": true, "packages": { "": { - "name": "vpn-bot", + "name": "frkn-vpn-bot", "version": "1.0.0", - "license": "ISC", + "hasInstallScript": true, "dependencies": { - "@prisma/client": "^6.13.0", - "async-mutex": "^0.5.0", - "axios": "^1.10.0", - "dotenv": "^16.5.0", - "express": "^5.1.0", + "@prisma/client": "6.13.0", + "async-mutex": "0.5.0", + "axios": "1.10.0", + "dotenv": "16.5.0", + "express": "5.1.0", "js-sha3": "0.9.3", - "qr-image": "^3.2.0", - "qrcode": "^1.5.4", - "telegraf": "^4.16.3" + "qr-image": "3.2.0", + "qrcode": "1.5.4", + "telegraf": "4.16.3", + "typescript": "5.8.3" }, "devDependencies": { - "@types/express": "^5.0.3", - "@types/qr-image": "^3.2.9", - "@types/qrcode": "^1.5.5", - "nodemon": "^3.1.10", - "prisma": "^6.13.0", - "ts-node": "^10.9.2", - "typescript": "^5.8.3" + "@types/express": "5.0.3", + "@types/qr-image": "3.2.9", + "@types/qrcode": "1.5.5", + "nodemon": "3.1.10", + "npm-run-all": "4.1.5", + "prisma": "6.13.0", + "ts-node": "10.9.2" } }, "node_modules/@babel/code-frame": { @@ -472,6 +473,55 @@ "dev": true, "license": "MIT" }, + "node_modules/array-buffer-byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/array-buffer-byte-length/-/array-buffer-byte-length-1.0.2.tgz", + "integrity": "sha512-LHE+8BuR7RYGDKvnrmcuSq3tDcKv9OFEXQt/HpbZhY7V6h0zlUXutnAD82GiFx9rdieCMjkvtcsPqBwgUl1Iiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "is-array-buffer": "^3.0.5" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/arraybuffer.prototype.slice": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/arraybuffer.prototype.slice/-/arraybuffer.prototype.slice-1.0.4.tgz", + "integrity": "sha512-BNoCY6SXXPQ7gF2opIP4GBE+Xw7U+pHMYKuzjgCN3GwiaIR09UUeKfheyIry77QtrCBlC0KK0q5/TER/tYh3PQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-buffer-byte-length": "^1.0.1", + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.5", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6", + "is-array-buffer": "^3.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/async-function": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/async-function/-/async-function-1.0.0.tgz", + "integrity": "sha512-hsU18Ae8CDTR6Kgu9DYf0EbCr/a5iGL0rytQDobUcdpYOKokk8LEjVphnXkDkgpi0wYVsqrXuP0bZxJaTqdgoA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/async-mutex": { "version": "0.5.0", "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.5.0.tgz", @@ -487,6 +537,22 @@ "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==", "license": "MIT" }, + "node_modules/available-typed-arrays": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/available-typed-arrays/-/available-typed-arrays-1.0.7.tgz", + "integrity": "sha512-wvUjBtSGN7+7SjNpq/9M2Tg350UZD3q62IFZLbRAR1bSMlCo1ZaeW+BJ+D090e4hIIZLBcTDWe4Mh4jvUDajzQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "possible-typed-array-names": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/axios": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/axios/-/axios-1.10.0.tgz", @@ -638,6 +704,19 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/c12/node_modules/dotenv": { + "version": "16.6.1", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", + "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "devOptional": true, + "license": "BSD-2-Clause", + "engines": { + "node": ">=12" + }, + "funding": { + "url": "https://dotenvx.com" + } + }, "node_modules/c12/node_modules/readdirp": { "version": "4.1.2", "resolved": "https://registry.npmjs.org/readdirp/-/readdirp-4.1.2.tgz", @@ -652,6 +731,25 @@ "url": "https://paulmillr.com/funding/" } }, + "node_modules/call-bind": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.8.tgz", + "integrity": "sha512-oKlSFMcMwpUg2ednkhQ454wfWiU/ul3CkJe/PEHcTKuiX6RpbehUiFMXu13HalGZxfUwCQzZG747YXBn1im9ww==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind-apply-helpers": "^1.0.0", + "es-define-property": "^1.0.0", + "get-intrinsic": "^1.2.4", + "set-function-length": "^1.2.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/call-bind-apply-helpers": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/call-bind-apply-helpers/-/call-bind-apply-helpers-1.0.2.tgz", @@ -690,6 +788,51 @@ "node": ">=6" } }, + "node_modules/chalk": { + "version": "2.4.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", + "integrity": "sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^3.2.1", + "escape-string-regexp": "^1.0.5", + "supports-color": "^5.3.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/chalk/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/chalk/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true, + "license": "MIT" + }, "node_modules/chokidar": { "version": "3.6.0", "resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.6.0.tgz", @@ -836,6 +979,87 @@ "dev": true, "license": "MIT" }, + "node_modules/cross-spawn": { + "version": "6.0.6", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-6.0.6.tgz", + "integrity": "sha512-VqCUuhcd1iB+dsv8gxPttb5iZh/D0iubSP21g36KXdEuf6I5JiioesUVjpCdHV9MZRUfVFlvwtIUyPfxo5trtw==", + "dev": true, + "license": "MIT", + "dependencies": { + "nice-try": "^1.0.4", + "path-key": "^2.0.1", + "semver": "^5.5.0", + "shebang-command": "^1.2.0", + "which": "^1.2.9" + }, + "engines": { + "node": ">=4.8" + } + }, + "node_modules/cross-spawn/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver" + } + }, + "node_modules/data-view-buffer": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/data-view-buffer/-/data-view-buffer-1.0.2.tgz", + "integrity": "sha512-EmKO5V3OLXh1rtK2wgXRansaK1/mtVdTUEiEI0W8RkvgT05kfxaH29PliLnpLP73yYO6142Q72QNa8Wx/A5CqQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/data-view-byte-length": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/data-view-byte-length/-/data-view-byte-length-1.0.2.tgz", + "integrity": "sha512-tuhGbE6CfTM9+5ANGf+oQb72Ky/0+s3xKUpHvShfiz2RxMFgFPjsXuRLBVMtvMs15awe45SRb83D6wH4ew6wlQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/inspect-js" + } + }, + "node_modules/data-view-byte-offset": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/data-view-byte-offset/-/data-view-byte-offset-1.0.1.tgz", + "integrity": "sha512-BS8PfmtDGnrgYdOonGZQdLZslWIeCGFP9tpan0hi1Co2Zr2NKADsvGYA8XxuG/4UWgJ6Cjtv+YJnB6MM69QGlQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-data-view": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/debug": { "version": "4.4.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.4.1.tgz", @@ -872,6 +1096,42 @@ "node": ">=16.0.0" } }, + "node_modules/define-data-property": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/define-data-property/-/define-data-property-1.1.4.tgz", + "integrity": "sha512-rBMvIzlpA8v6E+SJZoo++HAYqsLrkg7MSfIinMPFhmkorw7X+dOXVJQs+QT69zGkzMyfDnIMN2Wid1+NbL3T+A==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0", + "es-errors": "^1.3.0", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/define-properties": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.2.1.tgz", + "integrity": "sha512-8QmQKqEASLd5nx0U1B1okLElbUuuttJ/AnYmRXbbbGDWh6uS208EjD4Xqq/I9wK7u0v6O08XhTWnt5XtEbR6Dg==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.0.1", + "has-property-descriptors": "^1.0.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/defu": { "version": "6.1.4", "resolved": "https://registry.npmjs.org/defu/-/defu-6.1.4.tgz", @@ -921,9 +1181,9 @@ "license": "MIT" }, "node_modules/dotenv": { - "version": "16.6.1", - "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.6.1.tgz", - "integrity": "sha512-uBq4egWHTcTt33a72vpSG0z3HnPuIl6NqYcTrKEg2azoEyl2hpW0zqlxysq2pK9HlDIHyHyakeYaYnSAwd8bow==", + "version": "16.5.0", + "resolved": "https://registry.npmjs.org/dotenv/-/dotenv-16.5.0.tgz", + "integrity": "sha512-m/C+AwOAr9/W1UOIZUo232ejMNnJAJtYQjUbHoNTBNTJSvqzzDh7vnrei3o3r3m9blf6ZoDkvcw0VmozNRFJxg==", "license": "BSD-2-Clause", "engines": { "node": ">=12" @@ -978,6 +1238,85 @@ "node": ">= 0.8" } }, + "node_modules/error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-arrayish": "^0.2.1" + } + }, + "node_modules/es-abstract": { + "version": "1.24.0", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.24.0.tgz", + "integrity": "sha512-WSzPgsdLtTcQwm4CROfS5ju2Wa1QQcVeT37jFjYzdFz1r9ahadC8B8/a4qxJxM+09F18iumCdRmlr96ZYkQvEg==", + "dev": true, + "license": "MIT", + "dependencies": { + "array-buffer-byte-length": "^1.0.2", + "arraybuffer.prototype.slice": "^1.0.4", + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "data-view-buffer": "^1.0.2", + "data-view-byte-length": "^1.0.2", + "data-view-byte-offset": "^1.0.1", + "es-define-property": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.1.1", + "es-set-tostringtag": "^2.1.0", + "es-to-primitive": "^1.3.0", + "function.prototype.name": "^1.1.8", + "get-intrinsic": "^1.3.0", + "get-proto": "^1.0.1", + "get-symbol-description": "^1.1.0", + "globalthis": "^1.0.4", + "gopd": "^1.2.0", + "has-property-descriptors": "^1.0.2", + "has-proto": "^1.2.0", + "has-symbols": "^1.1.0", + "hasown": "^2.0.2", + "internal-slot": "^1.1.0", + "is-array-buffer": "^3.0.5", + "is-callable": "^1.2.7", + "is-data-view": "^1.0.2", + "is-negative-zero": "^2.0.3", + "is-regex": "^1.2.1", + "is-set": "^2.0.3", + "is-shared-array-buffer": "^1.0.4", + "is-string": "^1.1.1", + "is-typed-array": "^1.1.15", + "is-weakref": "^1.1.1", + "math-intrinsics": "^1.1.0", + "object-inspect": "^1.13.4", + "object-keys": "^1.1.1", + "object.assign": "^4.1.7", + "own-keys": "^1.0.1", + "regexp.prototype.flags": "^1.5.4", + "safe-array-concat": "^1.1.3", + "safe-push-apply": "^1.0.0", + "safe-regex-test": "^1.1.0", + "set-proto": "^1.0.0", + "stop-iteration-iterator": "^1.1.0", + "string.prototype.trim": "^1.2.10", + "string.prototype.trimend": "^1.0.9", + "string.prototype.trimstart": "^1.0.8", + "typed-array-buffer": "^1.0.3", + "typed-array-byte-length": "^1.0.3", + "typed-array-byte-offset": "^1.0.4", + "typed-array-length": "^1.0.7", + "unbox-primitive": "^1.1.0", + "which-typed-array": "^1.1.19" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/es-define-property": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/es-define-property/-/es-define-property-1.0.1.tgz", @@ -1023,12 +1362,40 @@ "node": ">= 0.4" } }, + "node_modules/es-to-primitive": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.3.0.tgz", + "integrity": "sha512-w+5mJ3GuFL+NjVtJlvydShqE1eN3h3PbI7/5LAsYJP/2qtuMXjfL2LpHSRqo4b4eSF5K/DH1JXKUAHSB2UW50g==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-callable": "^1.2.7", + "is-date-object": "^1.0.5", + "is-symbol": "^1.0.4" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", "integrity": "sha512-NiSupZ4OeuGwr68lGIeym/ksIZMJodUGOSCZ/FSnTxcrekbvqrgdUxlJOMpijaKZVjAJrWrGs/6Jy8OMuyj9ow==", "license": "MIT" }, + "node_modules/escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha512-vbRorB5FUQWvla16U8R/qgaFIya2qGzwDrNmCZuYKrbdSUMG6I1ZCGQRefkRVhuOkIGVne7BQ35DSfo1qvJqFg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.8.0" + } + }, "node_modules/etag": { "version": "1.8.1", "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", @@ -1216,6 +1583,22 @@ } } }, + "node_modules/for-each": { + "version": "0.3.5", + "resolved": "https://registry.npmjs.org/for-each/-/for-each-0.3.5.tgz", + "integrity": "sha512-dKx12eRCVIzqCxFGplyFKJMPvLEWgmNtUrpTiJIR5u97zEhRG8ySrtboPHZXx7daLxQVrl643cTzbab2tkQjxg==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-callable": "^1.2.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/form-data": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/form-data/-/form-data-4.0.4.tgz", @@ -1274,6 +1657,37 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/function.prototype.name": { + "version": "1.1.8", + "resolved": "https://registry.npmjs.org/function.prototype.name/-/function.prototype.name-1.1.8.tgz", + "integrity": "sha512-e5iwyodOHhbMr/yNrc7fDYG4qlbIvI5gajyzPnb5TCwyhjApznQh1BMFou9b30SevY43gCJKXycoCBjMbsuW0Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "functions-have-names": "^1.2.3", + "hasown": "^2.0.2", + "is-callable": "^1.2.7" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/functions-have-names": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/functions-have-names/-/functions-have-names-1.2.3.tgz", + "integrity": "sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==", + "dev": true, + "license": "MIT", + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", @@ -1320,16 +1734,34 @@ "node": ">= 0.4" } }, - "node_modules/giget": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/giget/-/giget-2.0.0.tgz", - "integrity": "sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA==", - "devOptional": true, + "node_modules/get-symbol-description": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.1.0.tgz", + "integrity": "sha512-w9UMqWwJxHNOvoNzSJ2oPF5wvYcvP7jUvYzhp67yEhTi17ZDBBC1z9pTdGuzjD+EFIqLSYRweZjqfiPzQ06Ebg==", + "dev": true, "license": "MIT", "dependencies": { - "citty": "^0.1.6", - "consola": "^3.4.0", - "defu": "^6.1.4", + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/giget": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/giget/-/giget-2.0.0.tgz", + "integrity": "sha512-L5bGsVkxJbJgdnwyuheIunkGatUF/zssUoxxjACCseZYAVbaqdh9Tsmmlkl8vYan09H7sbvKt4pS8GqKLBrEzA==", + "devOptional": true, + "license": "MIT", + "dependencies": { + "citty": "^0.1.6", + "consola": "^3.4.0", + "defu": "^6.1.4", "node-fetch-native": "^1.6.6", "nypm": "^0.6.0", "pathe": "^2.0.3" @@ -1351,6 +1783,23 @@ "node": ">= 6" } }, + "node_modules/globalthis": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/globalthis/-/globalthis-1.0.4.tgz", + "integrity": "sha512-DpLKbNU4WylpxJykQujfCcwYWiV/Jhm50Goo0wrVILAv5jOr9d+H+UR3PhSCD2rCCEIg0uc+G+muBTwD54JhDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-properties": "^1.2.1", + "gopd": "^1.0.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/gopd": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/gopd/-/gopd-1.2.0.tgz", @@ -1363,6 +1812,26 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/graceful-fs": { + "version": "4.2.11", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.11.tgz", + "integrity": "sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==", + "dev": true, + "license": "ISC" + }, + "node_modules/has-bigints": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.1.0.tgz", + "integrity": "sha512-R3pbpkcIqv2Pm3dUwgjclDRVmWpTJW2DcMzcIhEXEx1oh/CEMObMm3KLmRJOdvhM7o4uQBnwr8pzRK2sJWIqfg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/has-flag": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", @@ -1373,6 +1842,35 @@ "node": ">=4" } }, + "node_modules/has-property-descriptors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-property-descriptors/-/has-property-descriptors-1.0.2.tgz", + "integrity": "sha512-55JNKuIW+vq4Ke1BjOTjM2YctQIvCT7GFzHwmfZPGo5wnrgkid0YQtnAleFSqumZm4az3n2BS+erby5ipJdgrg==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-define-property": "^1.0.0" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/has-proto": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/has-proto/-/has-proto-1.2.0.tgz", + "integrity": "sha512-KIL7eQPfHQRC8+XluaIw7BHUwwqL19bQn4hzNgdr+1wXoU0KKj6rufu47lhY7KbJR2C6T6+PfyN0Ea7wkSS+qQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/has-symbols": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.1.0.tgz", @@ -1488,6 +1986,21 @@ "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==", "license": "ISC" }, + "node_modules/internal-slot": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.1.0.tgz", + "integrity": "sha512-4gd7VpWNQNB4UKKCFFVcp1AVv+FMOgs9NKzjHKusc8jTMhd5eL1NqQqOpE0KzMds804/yHlglp3uxgluOqAPLw==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "hasown": "^2.0.2", + "side-channel": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/ipaddr.js": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.1.tgz", @@ -1497,6 +2010,67 @@ "node": ">= 0.10" } }, + "node_modules/is-array-buffer": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/is-array-buffer/-/is-array-buffer-3.0.5.tgz", + "integrity": "sha512-DDfANUiiG2wC1qawP66qlTugJeL5HyzMpfr8lLK+jMQirGzNod0B12cFB/9q838Ru27sBwfw78/rdoU7RERz6A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha512-zz06S8t0ozoDXMG+ube26zeCTNXcKIPJZJi8hBrF4idCLms4CG9QtK7qBl1boi5ODzFpjswb5JPmHCbMpjaYzg==", + "dev": true, + "license": "MIT" + }, + "node_modules/is-async-function": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-async-function/-/is-async-function-2.1.1.tgz", + "integrity": "sha512-9dgM/cZBnNvjzaMYHVoxxfPj2QXt22Ev7SuuPrs+xav0ukGB0S6d4ydZdEiM48kLx5kDV+QBPrpVnFyefL8kkQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "async-function": "^1.0.0", + "call-bound": "^1.0.3", + "get-proto": "^1.0.1", + "has-tostringtag": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-bigint": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.1.0.tgz", + "integrity": "sha512-n4ZT37wG78iz03xPRKJrHTdZbe3IicyucEtdRsV5yglwc3GyUfbAfpSeD0FJ41NbUNSt5wbhqfp1fS+BgnvDFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "has-bigints": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-binary-path": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz", @@ -1510,6 +2084,87 @@ "node": ">=8" } }, + "node_modules/is-boolean-object": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.2.2.tgz", + "integrity": "sha512-wa56o2/ElJMYqjCjGkXri7it5FbebW5usLw/nPmCMs5DeZ7eziSYZhSmPRn0txqeW4LnAmQQU7FgqLpsEFKM4A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-callable": { + "version": "1.2.7", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.7.tgz", + "integrity": "sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-core-module": { + "version": "2.16.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.16.1.tgz", + "integrity": "sha512-UfoeMA6fIJ8wTYFEUjelnaGI67v6+N7qXJEvQuIGa99l4xsCruSYOVSQ0uPANn4dAzm8lkYPaKLrrijLq7x23w==", + "dev": true, + "license": "MIT", + "dependencies": { + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-data-view": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-data-view/-/is-data-view-1.0.2.tgz", + "integrity": "sha512-RKtWF8pGmS87i2D6gqQu/l7EYRlVdfzemCJN/P3UOs//x1QE7mfhvzHIApBTRf7axvT6DMGwSwBXYCT0nfB9xw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "get-intrinsic": "^1.2.6", + "is-typed-array": "^1.1.13" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-date-object": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-date-object/-/is-date-object-1.1.0.tgz", + "integrity": "sha512-PwwhEakHVKTdRNVOw+/Gyh0+MzlCl4R6qKvkhuvLtPMggI1WAHt9sOwZxQLSGpUaDnrdyDsomoRgNnCfKNSXXg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-extglob": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", @@ -1520,6 +2175,22 @@ "node": ">=0.10.0" } }, + "node_modules/is-finalizationregistry": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-finalizationregistry/-/is-finalizationregistry-1.1.1.tgz", + "integrity": "sha512-1pC6N8qWJbWoPtEjgcL2xyhQOP491EQjeUo3qTKcmV8YSDDJrOepfG8pcC7h/QgnQHYSv0mJ3Z/ZWxmatVrysg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", @@ -1529,6 +2200,25 @@ "node": ">=8" } }, + "node_modules/is-generator-function": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-generator-function/-/is-generator-function-1.1.0.tgz", + "integrity": "sha512-nPUB5km40q9e8UfN/Zc24eLlzdSf9OfKByBw9CIdw4H1giPMeA0OIJvbchsCu4npfI2QcMVBsGEBHKZ7wLTWmQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "get-proto": "^1.0.0", + "has-tostringtag": "^1.0.2", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/is-glob": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", @@ -1536,28 +2226,230 @@ "dev": true, "license": "MIT", "dependencies": { - "is-extglob": "^2.1.1" + "is-extglob": "^2.1.1" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/is-map": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-map/-/is-map-2.0.3.tgz", + "integrity": "sha512-1Qed0/Hr2m+YqxnM09CjA2d/i6YZNfF6R2oRAOj36eUdS6qIV/huPJNSEpKbupewFs+ZsJlxsjjPbc0/afW6Lw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-negative-zero": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.3.tgz", + "integrity": "sha512-5KoIu2Ngpyek75jXodFvnafB6DJgr3u8uuK0LEZJjrU19DrMD3EVERaR8sjz8CCGgpZvxPl9SuE1GMVPFHx1mw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-number": { + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", + "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.12.0" + } + }, + "node_modules/is-number-object": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.1.1.tgz", + "integrity": "sha512-lZhclumE1G6VYD8VHe35wFaIif+CTy5SJIi5+3y4psDgWu4wPDoBhF8NxUOinEc7pHgiTsT6MaBb92rKhhD+Xw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-promise": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", + "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", + "license": "MIT" + }, + "node_modules/is-regex": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.2.1.tgz", + "integrity": "sha512-MjYsKHO5O7mCsmRGxWcLWheFqN9DJ/2TmngvjKXihe6efViPqc274+Fx/4fYj/r03+ESvBdTXK0V6tA3rgez1g==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2", + "hasown": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-set": { + "version": "2.0.3", + "resolved": "https://registry.npmjs.org/is-set/-/is-set-2.0.3.tgz", + "integrity": "sha512-iPAjerrse27/ygGLxw+EBR9agv9Y6uLeYVJMu+QNCoouJ1/1ri0mGrcWpfCqFZuzzx3WjtwxG098X+n4OuRkPg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-shared-array-buffer": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.4.tgz", + "integrity": "sha512-ISWac8drv4ZGfwKl5slpHG9OwPNty4jOWPRIhBpxOoD+hqITiwuipOQ2bNthAzwA3B4fIjO4Nln74N0S9byq8A==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-string": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.1.1.tgz", + "integrity": "sha512-BtEeSsoaQjlSPBemMQIrY1MY0uM6vnS1g5fmufYOtnxLGUZM2178PKbhsk7Ffv58IX+ZtcvoGwccYsh0PglkAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-symbol": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.1.1.tgz", + "integrity": "sha512-9gGx6GTtCQM73BgmHQXfDmLtfjjTUDSyoxTCbp5WtoixAhfgsDirWIcVQ/IHpvI5Vgd5i/J5F7B9cN/WlVbC/w==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "has-symbols": "^1.1.0", + "safe-regex-test": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-typed-array": { + "version": "1.1.15", + "resolved": "https://registry.npmjs.org/is-typed-array/-/is-typed-array-1.1.15.tgz", + "integrity": "sha512-p3EcsicXjit7SaskXHs1hA91QxgTw46Fv6EFKKGS5DRFLD8yKnohjF3hxoju94b/OcMZoQukzpPpBE9uLVKzgQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "which-typed-array": "^1.1.16" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakmap": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-weakmap/-/is-weakmap-2.0.2.tgz", + "integrity": "sha512-K5pXYOm9wqY1RgjpL3YTkF39tni1XajUIkawTLUo9EZEVUFga5gSQJF8nNS7ZwJQ02y+1YCNYcMh+HIf1ZqE+w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakref": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.1.1.tgz", + "integrity": "sha512-6i9mGWSlqzNMEqpCp93KwRS1uUOodk2OJ6b+sq7ZPDSy2WuI5NFIxp/254TytR8ftefexkWn5xNiHUNpPOfSew==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/is-weakset": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/is-weakset/-/is-weakset-2.0.4.tgz", + "integrity": "sha512-mfcwb6IzQyOKTs84CQMrOwW4gQcaTOAWJ0zzJCl2WSPDrWk/OzDaImWFH3djXhb24g4eudZfLRozAvPGw4d9hQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "get-intrinsic": "^1.2.6" }, "engines": { - "node": ">=0.10.0" + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" } }, - "node_modules/is-number": { - "version": "7.0.0", - "resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz", - "integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==", + "node_modules/isarray": { + "version": "2.0.5", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-2.0.5.tgz", + "integrity": "sha512-xHjhDr3cNBK0BzdUJSPXZntQUx/mwMS5Rw4A7lPJ90XGAO6ISP/ePDNuo0vhqOZU+UD5JoodwCAAoZQd3FeAKw==", "dev": true, - "license": "MIT", - "engines": { - "node": ">=0.12.0" - } - }, - "node_modules/is-promise": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-4.0.0.tgz", - "integrity": "sha512-hvpoI6korhJMnej285dSg6nu1+e6uxs7zG3BYAm5byqDsgJNWwxzM6z6iZiAgQR4TJ30JmBTOwqZUw3WlyH3AQ==", "license": "MIT" }, + "node_modules/isexe": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", + "integrity": "sha512-RHxMLp9lnKHGHRng9QFhRCMbYAcVpn69smSGcq3f36xjgVVWThj4qqLbTLlq7Ssj8B+fIQ1EuCEGI2lKsyQeIw==", + "dev": true, + "license": "ISC" + }, "node_modules/jiti": { "version": "2.5.1", "resolved": "https://registry.npmjs.org/jiti/-/jiti-2.5.1.tgz", @@ -1581,6 +2473,43 @@ "devOptional": true, "license": "MIT" }, + "node_modules/json-parse-better-errors": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", + "dev": true, + "license": "MIT" + }, + "node_modules/load-json-file": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-4.0.0.tgz", + "integrity": "sha512-Kx8hMakjX03tiGTLAIdJ+lL0htKnXjEZN6hk/tozf/WOuYGdZBJrZ+rCJRbVCugsjB3jMLn9746NsQIf5VjBMw==", + "dev": true, + "license": "MIT", + "dependencies": { + "graceful-fs": "^4.1.2", + "parse-json": "^4.0.0", + "pify": "^3.0.0", + "strip-bom": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/load-json-file/node_modules/parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha512-aOIos8bujGN93/8Ox/jPLh7RwVnPEysynVFE+fQZyg6jKELEHwzgKdLRFHUgXJL6kylijVSBC4BvN9OmsB48Rw==", + "dev": true, + "license": "MIT", + "dependencies": { + "error-ex": "^1.3.1", + "json-parse-better-errors": "^1.0.1" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/locate-path": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", @@ -1625,6 +2554,15 @@ "node": ">= 0.8" } }, + "node_modules/memorystream": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/memorystream/-/memorystream-0.3.1.tgz", + "integrity": "sha512-S3UwM3yj5mtUSEfP41UZmt/0SCoVYUcU1rkXv+BQ5Ig8ndL4sPoJNBUJERafdPb5jjHJGuMgytgKvKIf58XNBw==", + "dev": true, + "engines": { + "node": ">= 0.10.0" + } + }, "node_modules/merge-descriptors": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-2.0.0.tgz", @@ -1695,6 +2633,13 @@ "node": ">= 0.6" } }, + "node_modules/nice-try": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", + "integrity": "sha512-1nh45deeb5olNY7eX82BkPO7SSxR5SSYJiPTrTdFUVYwAl8CKMA5N9PjTYkHiRjisVcxcQ1HXdLhx2qxxJzLNQ==", + "dev": true, + "license": "MIT" + }, "node_modules/node-fetch": { "version": "2.7.0", "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.7.0.tgz", @@ -1776,6 +2721,107 @@ "node": ">=0.10.0" } }, + "node_modules/npm-run-all": { + "version": "4.1.5", + "resolved": "https://registry.npmjs.org/npm-run-all/-/npm-run-all-4.1.5.tgz", + "integrity": "sha512-Oo82gJDAVcaMdi3nuoKFavkIHBRVqQ1qvMb+9LHk/cF4P6B2m8aP04hGf7oL6wZ9BuGwX1onlLhpuoofSyoQDQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "ansi-styles": "^3.2.1", + "chalk": "^2.4.1", + "cross-spawn": "^6.0.5", + "memorystream": "^0.3.1", + "minimatch": "^3.0.4", + "pidtree": "^0.3.0", + "read-pkg": "^3.0.0", + "shell-quote": "^1.6.1", + "string.prototype.padend": "^3.0.0" + }, + "bin": { + "npm-run-all": "bin/npm-run-all/index.js", + "run-p": "bin/run-p/index.js", + "run-s": "bin/run-s/index.js" + }, + "engines": { + "node": ">= 4" + } + }, + "node_modules/npm-run-all/node_modules/ansi-styles": { + "version": "3.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.1.tgz", + "integrity": "sha512-VT0ZI6kZRdTh8YyJw3SMbYm/u+NqfsAxEpWO0Pf9sq8/e94WxxOpPKx9FR1FlyCtOVDNOQ+8ntlqFxiRc+r5qA==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-convert": "^1.9.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/npm-run-all/node_modules/color-convert": { + "version": "1.9.3", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.3.tgz", + "integrity": "sha512-QfAUtd+vFdAtFQcC8CCyYt1fYWxSqAiK2cSD6zDB8N3cpsEBAvRxp9zOGg6G/SHHJYAT88/az/IuDGALsNVbGg==", + "dev": true, + "license": "MIT", + "dependencies": { + "color-name": "1.1.3" + } + }, + "node_modules/npm-run-all/node_modules/color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha512-72fSenhMw2HZMTVHeCA9KCmpEIbzWiQsjN+BHcBbS9vr1mtt+vJjPdksIBNUmKAW8TFUDPJK5SUU3QhE9NEXDw==", + "dev": true, + "license": "MIT" + }, + "node_modules/npm-run-all/node_modules/hosted-git-info": { + "version": "2.8.9", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.9.tgz", + "integrity": "sha512-mxIDAb9Lsm6DoOJ7xH+5+X4y1LU/4Hi50L9C5sIswK3JzULS4bwk1FvjdBgvYR4bzT4tuUQiC15FE2f5HbLvYw==", + "dev": true, + "license": "ISC" + }, + "node_modules/npm-run-all/node_modules/normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "license": "BSD-2-Clause", + "dependencies": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + } + }, + "node_modules/npm-run-all/node_modules/read-pkg": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-3.0.0.tgz", + "integrity": "sha512-BLq/cCO9two+lBgiTYNqD6GdtK8s4NpaWrl6/rCO9w0TUS8oJl7cmToOZfRYllKTISY6nt1U7jQ53brmKqY6BA==", + "dev": true, + "license": "MIT", + "dependencies": { + "load-json-file": "^4.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, + "node_modules/npm-run-all/node_modules/semver": { + "version": "5.7.2", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.2.tgz", + "integrity": "sha512-cBznnQ9KjJqU67B52RMC65CMarK2600WFnbkcaiwWq3xy/5haFJlshgnpjovMVJ+Hff49d8GEn0b87C5pDQ10g==", + "dev": true, + "license": "ISC", + "bin": { + "semver": "bin/semver" + } + }, "node_modules/nypm": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/nypm/-/nypm-0.6.1.tgz", @@ -1808,6 +2854,37 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/object-keys": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", + "integrity": "sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/object.assign": { + "version": "4.1.7", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.7.tgz", + "integrity": "sha512-nK28WOo+QIjBkDduTINE4JkF/UJJKyf2EJxvJKfblDpyg0Q+pkOHNTL0Qwy6NP6FhE/EnzV73BxxqcJaXY9anw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.3", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0", + "has-symbols": "^1.1.0", + "object-keys": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/ohash": { "version": "2.0.11", "resolved": "https://registry.npmjs.org/ohash/-/ohash-2.0.11.tgz", @@ -1836,6 +2913,24 @@ "wrappy": "1" } }, + "node_modules/own-keys": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/own-keys/-/own-keys-1.0.1.tgz", + "integrity": "sha512-qFOyK5PjiWZd+QQIh+1jhdb9LpxTF0qs7Pm8o5QHYZ0M3vKqSqzsZaEB6oWlxZ+q2sJBMI/Ktgd2N5ZwQoRHfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "get-intrinsic": "^1.2.6", + "object-keys": "^1.1.1", + "safe-push-apply": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/p-limit": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", @@ -1917,6 +3012,23 @@ "node": ">=8" } }, + "node_modules/path-key": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", + "integrity": "sha512-fEHGKCSmUSDPv4uoj8AlD+joPlq3peND+HRYyxFz4KPw4z926S/b8rIuFs2FYJg3BwsxJf6A9/3eIdLaYC+9Dw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, + "node_modules/path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true, + "license": "MIT" + }, "node_modules/path-to-regexp": { "version": "8.2.0", "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-8.2.0.tgz", @@ -1926,6 +3038,19 @@ "node": ">=16" } }, + "node_modules/path-type": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-3.0.0.tgz", + "integrity": "sha512-T2ZUsdZFHgA3u4e5PfPbjd7HDDpxPnQb5jN0SrDsjNSuVXHJqtwTnWqG0B1jZrgmJ/7lj1EmVIByWt1gxGkWvg==", + "dev": true, + "license": "MIT", + "dependencies": { + "pify": "^3.0.0" + }, + "engines": { + "node": ">=4" + } + }, "node_modules/pathe": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/pathe/-/pathe-2.0.3.tgz", @@ -1960,6 +3085,29 @@ "url": "https://github.com/sponsors/jonschlinkert" } }, + "node_modules/pidtree": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/pidtree/-/pidtree-0.3.1.tgz", + "integrity": "sha512-qQbW94hLHEqCg7nhby4yRC7G2+jYHY4Rguc2bjw7Uug4GIJuu1tvf2uHaZv5Q8zdt+WKJ6qK1FOI6amaWUo5FA==", + "dev": true, + "license": "MIT", + "bin": { + "pidtree": "bin/pidtree.js" + }, + "engines": { + "node": ">=0.10" + } + }, + "node_modules/pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha512-C3FsVNH1udSEX48gGX1xfvwTWfsYWj5U+8/uK15BGzIGrKoUpghX8hWZwa/OFnakBiiVNmBvemTJR5mcy7iPcg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/pkg-types": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/pkg-types/-/pkg-types-2.2.0.tgz", @@ -1981,6 +3129,16 @@ "node": ">=10.13.0" } }, + "node_modules/possible-typed-array-names": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/possible-typed-array-names/-/possible-typed-array-names-1.1.0.tgz", + "integrity": "sha512-/+5VFTchJDoVj3bhoqi6UeymcD00DAwb1nJwamzPvHEszJ4FpF6SNNbUbOS8yI56qHzdV8eK0qEfOSiodkTdxg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + } + }, "node_modules/prisma": { "version": "6.13.0", "resolved": "https://registry.npmjs.org/prisma/-/prisma-6.13.0.tgz", @@ -2174,6 +3332,50 @@ "node": ">=8.10.0" } }, + "node_modules/reflect.getprototypeof": { + "version": "1.0.10", + "resolved": "https://registry.npmjs.org/reflect.getprototypeof/-/reflect.getprototypeof-1.0.10.tgz", + "integrity": "sha512-00o4I+DVrefhv+nX0ulyi3biSHCPDe+yLv5o/p6d/UVlirijB8E16FtfwSAi4g3tcqrQ4lRAqQSoFEZJehYEcw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.9", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0", + "get-intrinsic": "^1.2.7", + "get-proto": "^1.0.1", + "which-builtin-type": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/regexp.prototype.flags": { + "version": "1.5.4", + "resolved": "https://registry.npmjs.org/regexp.prototype.flags/-/regexp.prototype.flags-1.5.4.tgz", + "integrity": "sha512-dYqgNSZbDwkaJ2ceRd9ojCGjBq+mOm9LmtXnAnEGyHhN/5R7iDW2TRw3h+o/jCFxus3P2LfWIIiwowAjANm7IA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "define-properties": "^1.2.1", + "es-errors": "^1.3.0", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "set-function-name": "^2.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/require-directory": { "version": "2.1.1", "resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz", @@ -2189,6 +3391,27 @@ "integrity": "sha512-NKN5kMDylKuldxYLSUfrbo5Tuzh4hd+2E8NPPX02mZtn1VuREQToYe/ZdlJy+J3uCpfaiGF05e7B8W0iXbQHmg==", "license": "ISC" }, + "node_modules/resolve": { + "version": "1.22.10", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.10.tgz", + "integrity": "sha512-NPRy+/ncIMeDlTAsuqwKIiferiawhefFJtkNSW0qZJEqMEb+qBt/77B/jGeeek+F0uOeN05CDa6HXbbIgtVX4w==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-core-module": "^2.16.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" + }, + "bin": { + "resolve": "bin/resolve" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/router": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/router/-/router-2.2.0.tgz", @@ -2205,6 +3428,26 @@ "node": ">= 18" } }, + "node_modules/safe-array-concat": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/safe-array-concat/-/safe-array-concat-1.1.3.tgz", + "integrity": "sha512-AURm5f0jYEOydBj7VQlVvDrjeFgthDdEF5H1dP+6mNpoXOMo1quQqJ4wvJDyRZ9+pO3kGWoOdmV08cSv2aJV6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.2", + "get-intrinsic": "^1.2.6", + "has-symbols": "^1.1.0", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">=0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/safe-buffer": { "version": "5.2.1", "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz", @@ -2234,6 +3477,41 @@ "buffer-alloc": "^1.2.0" } }, + "node_modules/safe-push-apply": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/safe-push-apply/-/safe-push-apply-1.0.0.tgz", + "integrity": "sha512-iKE9w/Z7xCzUMIZqdBsp6pEQvwuEebH4vdpjcDWnyzaI6yl6O9FHvVpmGelvEHNsoY6wGblkxR6Zty/h00WiSA==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "isarray": "^2.0.5" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/safe-regex-test": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/safe-regex-test/-/safe-regex-test-1.1.0.tgz", + "integrity": "sha512-x/+Cz4YrimQxQccJf5mKEbIa1NzeCRNI5Ecl/ekmlYaampdNLPalVyIcCZNNH3MvmqBugV5TMYZXv0ljslUlaw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "es-errors": "^1.3.0", + "is-regex": "^1.2.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", @@ -2326,12 +3604,97 @@ "integrity": "sha512-KiKBS8AnWGEyLzofFfmvKwpdPzqiy16LvQfK3yv/fVH7Bj13/wl3JSR1J+rfgRE9q7xUJK4qvgS8raSOeLUehw==", "license": "ISC" }, + "node_modules/set-function-length": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/set-function-length/-/set-function-length-1.2.2.tgz", + "integrity": "sha512-pgRc4hJ4/sNjWCSS9AmnS40x3bNMDTknHgL5UaMBTMyJnU90EgWh1Rz+MC9eFu4BuN/UwZjKQuY/1v3rM7HMfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "function-bind": "^1.1.2", + "get-intrinsic": "^1.2.4", + "gopd": "^1.0.1", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-function-name": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/set-function-name/-/set-function-name-2.0.2.tgz", + "integrity": "sha512-7PGFlmtwsEADb0WYyvCMa1t+yke6daIG4Wirafur5kcf+MhUnPms1UeR0CKQdTZD81yESwMHbtn+TR+dMviakQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "define-data-property": "^1.1.4", + "es-errors": "^1.3.0", + "functions-have-names": "^1.2.3", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/set-proto": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/set-proto/-/set-proto-1.0.0.tgz", + "integrity": "sha512-RJRdvCo6IAnPdsvP/7m6bsQqNnn1FCBX5ZNtFL98MmFF/4xAIJTIg1YbHW5DC2W5SKZanrC6i4HsJqlajw/dZw==", + "dev": true, + "license": "MIT", + "dependencies": { + "dunder-proto": "^1.0.1", + "es-errors": "^1.3.0", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/setprototypeof": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.2.0.tgz", "integrity": "sha512-E5LDX7Wrp85Kil5bhZv46j8jOeboKq5JMmYM3gVGdGH8xFpPWXUMsNrlODCrkoxMEeNi/XZIwuRvY4XNwYMJpw==", "license": "ISC" }, + "node_modules/shebang-command": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", + "integrity": "sha512-EV3L1+UQWGor21OmnvojK36mhg+TyIKDh3iFBKBohr5xeXIhNBcx8oWdgkTEEQ+BEFFYdLRuqMfd5L84N1V5Vg==", + "dev": true, + "license": "MIT", + "dependencies": { + "shebang-regex": "^1.0.0" + }, + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/shebang-regex": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", + "integrity": "sha512-wpoSFAxys6b2a2wHZ1XpDSgD7N9iVjg29Ph9uV/uaP9Ex/KXlkTZTeddxDPSYQpgvzKLGJke2UU0AzoGCjNIvQ==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=0.10.0" + } + }, + "node_modules/shell-quote": { + "version": "1.8.3", + "resolved": "https://registry.npmjs.org/shell-quote/-/shell-quote-1.8.3.tgz", + "integrity": "sha512-ObmnIF4hXNg1BqhnHmgbDETF8dLPCggZWBjkQfhZpbszZnYur5DUljTcCHii5LC3J5E0yeO/1LIMyH+UvHQgyw==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/side-channel": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.1.0.tgz", @@ -2462,6 +3825,20 @@ "node": ">= 0.8" } }, + "node_modules/stop-iteration-iterator": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/stop-iteration-iterator/-/stop-iteration-iterator-1.1.0.tgz", + "integrity": "sha512-eLoXW/DHyl62zxY4SCaIgnRhuMr6ri4juEYARS8E6sCEqzKpOiE521Ucofdx+KnDZl5xmvGYaaKCk5FEOxJCoQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "es-errors": "^1.3.0", + "internal-slot": "^1.1.0" + }, + "engines": { + "node": ">= 0.4" + } + }, "node_modules/string-width": { "version": "4.2.3", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz", @@ -2476,6 +3853,84 @@ "node": ">=8" } }, + "node_modules/string.prototype.padend": { + "version": "3.1.6", + "resolved": "https://registry.npmjs.org/string.prototype.padend/-/string.prototype.padend-3.1.6.tgz", + "integrity": "sha512-XZpspuSB7vJWhvJc9DLSlrXl1mcA2BdoY5jjnS135ydXqLoqhs96JjDtCkjJEQHvfqZIp9hBuBMgI589peyx9Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.2", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trim": { + "version": "1.2.10", + "resolved": "https://registry.npmjs.org/string.prototype.trim/-/string.prototype.trim-1.2.10.tgz", + "integrity": "sha512-Rs66F0P/1kedk5lyYyH9uBzuiI/kNRmwJAR9quK6VOtIpZ2G+hMZd+HQbbv25MgCA6gEffoMZYxlTod4WcdrKA==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.2", + "define-data-property": "^1.1.4", + "define-properties": "^1.2.1", + "es-abstract": "^1.23.5", + "es-object-atoms": "^1.0.0", + "has-property-descriptors": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimend": { + "version": "1.0.9", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.9.tgz", + "integrity": "sha512-G7Ok5C6E/j4SGfyLCloXTrngQIQU3PWtXGst3yM7Bea9FRURf1S42ZHlZZtsNque2FN2PoUhfZXYLNWwEr4dLQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "call-bound": "^1.0.2", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/string.prototype.trimstart": { + "version": "1.0.8", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.8.tgz", + "integrity": "sha512-UXSH262CSZY1tfu3G3Secr6uGLCFVPMhIqHjlgCUtCCcgihYc/xKs9djMTMUOb2j1mVSeU8EU6NWc/iQKU6Gfg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "define-properties": "^1.2.1", + "es-object-atoms": "^1.0.0" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/strip-ansi": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz", @@ -2488,6 +3943,16 @@ "node": ">=8" } }, + "node_modules/strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">=4" + } + }, "node_modules/supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -2501,6 +3966,19 @@ "node": ">=4" } }, + "node_modules/supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/telegraf": { "version": "4.16.3", "resolved": "https://registry.npmjs.org/telegraf/-/telegraf-4.16.3.tgz", @@ -2666,11 +4144,88 @@ "node": ">= 0.6" } }, + "node_modules/typed-array-buffer": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/typed-array-buffer/-/typed-array-buffer-1.0.3.tgz", + "integrity": "sha512-nAYYwfY3qnzX30IkA6AQZjVbtK6duGontcQm1WSG1MD94YLqK0515GNApXkoxKOWMusVssAHWLh9SeaoefYFGw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "es-errors": "^1.3.0", + "is-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + } + }, + "node_modules/typed-array-byte-length": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/typed-array-byte-length/-/typed-array-byte-length-1.0.3.tgz", + "integrity": "sha512-BaXgOuIxz8n8pIq3e7Atg/7s+DpiYrxn4vdot3w9KbnBhcRQq6o3xemQdIfynqSeXeDrF32x+WvfzmOjPiY9lg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.8", + "for-each": "^0.3.3", + "gopd": "^1.2.0", + "has-proto": "^1.2.0", + "is-typed-array": "^1.1.14" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-byte-offset": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/typed-array-byte-offset/-/typed-array-byte-offset-1.0.4.tgz", + "integrity": "sha512-bTlAFB/FBYMcuX81gbL4OcpH5PmlFHqlCCpAl8AlEzMz5k53oNDvN8p1PNOWLEmI2x4orp3raOFB51tv9X+MFQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "for-each": "^0.3.3", + "gopd": "^1.2.0", + "has-proto": "^1.2.0", + "is-typed-array": "^1.1.15", + "reflect.getprototypeof": "^1.0.9" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/typed-array-length": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/typed-array-length/-/typed-array-length-1.0.7.tgz", + "integrity": "sha512-3KS2b+kL7fsuk/eJZ7EQdnEmQoaho/r6KUef7hxvltNA5DR8NAUM+8wJMbJyZ4G9/7i3v5zPBIMN5aybAh2/Jg==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bind": "^1.0.7", + "for-each": "^0.3.3", + "gopd": "^1.0.1", + "is-typed-array": "^1.1.13", + "possible-typed-array-names": "^1.0.0", + "reflect.getprototypeof": "^1.0.6" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/typescript": { "version": "5.8.3", "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.8.3.tgz", "integrity": "sha512-p1diW6TqL9L07nNxvRMM7hMMw4c5XOo/1ibL4aAIGmSAt9slTE1Xgw5KWuof2uTOvCg9BY7ZRi+GaF+7sfgPeQ==", - "devOptional": true, "license": "Apache-2.0", "bin": { "tsc": "bin/tsc", @@ -2680,6 +4235,25 @@ "node": ">=14.17" } }, + "node_modules/unbox-primitive": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.1.0.tgz", + "integrity": "sha512-nWJ91DjeOkej/TA8pXQ3myruKpKEYgqvpw9lz4OPHj/NWFNluYrjbz9j01CJ8yKQd2g4jFoOkINCTW2I5LEEyw==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.3", + "has-bigints": "^1.0.2", + "has-symbols": "^1.1.0", + "which-boxed-primitive": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/undefsafe": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/undefsafe/-/undefsafe-2.0.5.tgz", @@ -2759,12 +4333,114 @@ "webidl-conversions": "^3.0.0" } }, + "node_modules/which": { + "version": "1.3.1", + "resolved": "https://registry.npmjs.org/which/-/which-1.3.1.tgz", + "integrity": "sha512-HxJdYWq1MTIQbJ3nw0cqssHoTNU267KlrDuGZ1WYlxDStUtKUhOaJmh112/TZmHxxUfuJqPXSOm7tDyas0OSIQ==", + "dev": true, + "license": "ISC", + "dependencies": { + "isexe": "^2.0.0" + }, + "bin": { + "which": "bin/which" + } + }, + "node_modules/which-boxed-primitive": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.1.1.tgz", + "integrity": "sha512-TbX3mj8n0odCBFVlY8AxkqcHASw3L60jIuF8jFP78az3C2YhmGvqbHBpAjTRH2/xqYunrJ9g1jSyjCjpoWzIAA==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-bigint": "^1.1.0", + "is-boolean-object": "^1.2.1", + "is-number-object": "^1.1.1", + "is-string": "^1.1.1", + "is-symbol": "^1.1.1" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-builtin-type": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/which-builtin-type/-/which-builtin-type-1.2.1.tgz", + "integrity": "sha512-6iBczoX+kDQ7a3+YJBnh3T+KZRxM/iYNPXicqk66/Qfm1b93iu+yOImkg0zHbj5LNOcNv1TEADiZ0xa34B4q6Q==", + "dev": true, + "license": "MIT", + "dependencies": { + "call-bound": "^1.0.2", + "function.prototype.name": "^1.1.6", + "has-tostringtag": "^1.0.2", + "is-async-function": "^2.0.0", + "is-date-object": "^1.1.0", + "is-finalizationregistry": "^1.1.0", + "is-generator-function": "^1.0.10", + "is-regex": "^1.2.1", + "is-weakref": "^1.0.2", + "isarray": "^2.0.5", + "which-boxed-primitive": "^1.1.0", + "which-collection": "^1.0.2", + "which-typed-array": "^1.1.16" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, + "node_modules/which-collection": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-collection/-/which-collection-1.0.2.tgz", + "integrity": "sha512-K4jVyjnBdgvc86Y6BkaLZEN933SwYOuBFkdmBu9ZfkcAbdVbpITnDmjvZ/aQjRXQrv5EPkTnD1s39GiiqbngCw==", + "dev": true, + "license": "MIT", + "dependencies": { + "is-map": "^2.0.3", + "is-set": "^2.0.3", + "is-weakmap": "^2.0.2", + "is-weakset": "^2.0.3" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/which-module": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.1.tgz", "integrity": "sha512-iBdZ57RDvnOR9AGBhML2vFZf7h8vmBjhoaZqODJBFWHVtKkDmKuHai3cx5PgVMrX5YDNp27AofYbAwctSS+vhQ==", "license": "ISC" }, + "node_modules/which-typed-array": { + "version": "1.1.19", + "resolved": "https://registry.npmjs.org/which-typed-array/-/which-typed-array-1.1.19.tgz", + "integrity": "sha512-rEvr90Bck4WZt9HHFC4DJMsjvu7x+r6bImz0/BrbWb7A2djJ8hnZMrWnHo9F8ssv0OMErasDhftrfROTyqSDrw==", + "dev": true, + "license": "MIT", + "dependencies": { + "available-typed-arrays": "^1.0.7", + "call-bind": "^1.0.8", + "call-bound": "^1.0.4", + "for-each": "^0.3.5", + "get-proto": "^1.0.1", + "gopd": "^1.2.0", + "has-tostringtag": "^1.0.2" + }, + "engines": { + "node": ">= 0.4" + }, + "funding": { + "url": "https://github.com/sponsors/ljharb" + } + }, "node_modules/wrap-ansi": { "version": "6.2.0", "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", diff --git a/package.json b/package.json index 4d879fb..66525e5 100644 --- a/package.json +++ b/package.json @@ -1,35 +1,40 @@ { - "name": "vpn-bot", + "name": "frkn-vpn-bot", "version": "1.0.0", - "description": "", + "private": true, "main": "index.js", + "type": "commonjs", + "engines": { + "node": "22.x" + }, "scripts": { - "dev": "nodemon src/bot.ts", + "postinstall": "prisma generate", "start": "ts-node src/bot.ts", - "build": "tsc" + "dev": "nodemon src/bot.ts", + "build": "tsc", + "test": "npm-run-all test:*", + "test:audit": "npm audit", + "test:types": "tsc --noEmit --incremental false" }, - "keywords": [], - "author": "", - "license": "ISC", - "type": "commonjs", "devDependencies": { - "@types/express": "^5.0.3", - "@types/qr-image": "^3.2.9", - "@types/qrcode": "^1.5.5", - "nodemon": "^3.1.10", - "prisma": "^6.13.0", - "ts-node": "^10.9.2", - "typescript": "^5.8.3" + "@types/express": "5.0.3", + "@types/qr-image": "3.2.9", + "@types/qrcode": "1.5.5", + "nodemon": "3.1.10", + "npm-run-all": "4.1.5", + "prisma": "6.13.0", + "ts-node": "10.9.2" }, "dependencies": { - "@prisma/client": "^6.13.0", - "async-mutex": "^0.5.0", - "axios": "^1.10.0", - "dotenv": "^16.5.0", - "express": "^5.1.0", + "@prisma/client": "6.13.0", + "async-mutex": "0.5.0", + "axios": "1.10.0", + "dotenv": "16.5.0", + "express": "5.1.0", "js-sha3": "0.9.3", - "qr-image": "^3.2.0", - "qrcode": "^1.5.4", - "telegraf": "^4.16.3" + "qr-image": "3.2.0", + "qrcode": "1.5.4", + "telegraf": "4.16.3", + "typescript": "5.8.3" } } diff --git a/tsconfig.json b/tsconfig.json index faeea55..9dfa813 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,12 +1,13 @@ { "compilerOptions": { "outDir": "dist", - "target": "es2016" /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */, - "module": "commonjs" /* Specify what module code is generated. */, - "esModuleInterop": true /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */, - "forceConsistentCasingInFileNames": true /* Ensure that casing is correct in imports. */, - "strict": true /* Enable all strict type-checking options. */, - "skipLibCheck": true /* Skip type checking all .d.ts files. */ + "target": "es2016", + "module": "commonjs", + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "strict": true, + "noUncheckedIndexedAccess": true, + "skipLibCheck": true }, "include": ["src"] } From d208c275ce5914dc37946c509e694daeca115688 Mon Sep 17 00:00:00 2001 From: zapolnoch Date: Thu, 11 Sep 2025 01:34:59 +0300 Subject: [PATCH 2/7] refactor: add biome --- .vscode/settings.json | 14 ++++ biome.jsonc | 36 +++++++++ package-lock.json | 173 +++++++++++++++++++++++++++++++++++++++++- package.json | 4 +- 4 files changed, 223 insertions(+), 4 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 biome.jsonc diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..c7b310b --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,14 @@ +{ + "[typescript]": { + "editor.defaultFormatter": "biomejs.biome" + }, + "[typescriptreact]": { + "editor.defaultFormatter": "biomejs.biome" + }, + "editor.formatOnSave": true, + "editor.defaultFormatter": "biomejs.biome", + "editor.codeActionsOnSave": { + "source.organizeImports.biome": "explicit" + }, + "typescript.tsdk": "node_modules/typescript/lib" +} diff --git a/biome.jsonc b/biome.jsonc new file mode 100644 index 0000000..e21a1a1 --- /dev/null +++ b/biome.jsonc @@ -0,0 +1,36 @@ +{ + "$schema": "https://biomejs.dev/schemas/2.2.4/schema.json", + "formatter": { + "enabled": true, + "indentStyle": "space" + }, + "linter": { + "enabled": true, + "rules": { + "recommended": true, + "style": { + "noNonNullAssertion": "info", + "useCollapsedElseIf": "error", + "useForOf": "error" + }, + "complexity": { + "noExcessiveCognitiveComplexity": { + "level": "error", + "options": { + "maxAllowedComplexity": 15 + } + }, + "noVoid": "error" + }, + "correctness": { + "noUnusedVariables": "warn" + }, + "suspicious": { + "noEmptyBlockStatements": "error", + "noExplicitAny": "warn", + "noArrayIndexKey": "warn", + "noUselessEscapeInString": "off" + } + } + } +} diff --git a/package-lock.json b/package-lock.json index 9e5b8d1..235caab 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "typescript": "5.8.3" }, "devDependencies": { + "@biomejs/biome": "2.2.4", "@types/express": "5.0.3", "@types/qr-image": "3.2.9", "@types/qrcode": "1.5.5", @@ -28,6 +29,9 @@ "npm-run-all": "4.1.5", "prisma": "6.13.0", "ts-node": "10.9.2" + }, + "engines": { + "node": "22.x" } }, "node_modules/@babel/code-frame": { @@ -55,6 +59,169 @@ "node": ">=6.9.0" } }, + "node_modules/@biomejs/biome": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@biomejs/biome/-/biome-2.2.4.tgz", + "integrity": "sha512-TBHU5bUy/Ok6m8c0y3pZiuO/BZoY/OcGxoLlrfQof5s8ISVwbVBdFINPQZyFfKwil8XibYWb7JMwnT8wT4WVPg==", + "dev": true, + "license": "MIT OR Apache-2.0", + "bin": { + "biome": "bin/biome" + }, + "engines": { + "node": ">=14.21.3" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/biome" + }, + "optionalDependencies": { + "@biomejs/cli-darwin-arm64": "2.2.4", + "@biomejs/cli-darwin-x64": "2.2.4", + "@biomejs/cli-linux-arm64": "2.2.4", + "@biomejs/cli-linux-arm64-musl": "2.2.4", + "@biomejs/cli-linux-x64": "2.2.4", + "@biomejs/cli-linux-x64-musl": "2.2.4", + "@biomejs/cli-win32-arm64": "2.2.4", + "@biomejs/cli-win32-x64": "2.2.4" + } + }, + "node_modules/@biomejs/cli-darwin-arm64": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-arm64/-/cli-darwin-arm64-2.2.4.tgz", + "integrity": "sha512-RJe2uiyaloN4hne4d2+qVj3d3gFJFbmrr5PYtkkjei1O9c+BjGXgpUPVbi8Pl8syumhzJjFsSIYkcLt2VlVLMA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-darwin-x64": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-darwin-x64/-/cli-darwin-x64-2.2.4.tgz", + "integrity": "sha512-cFsdB4ePanVWfTnPVaUX+yr8qV8ifxjBKMkZwN7gKb20qXPxd/PmwqUH8mY5wnM9+U0QwM76CxFyBRJhC9tQwg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "darwin" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64/-/cli-linux-arm64-2.2.4.tgz", + "integrity": "sha512-M/Iz48p4NAzMXOuH+tsn5BvG/Jb07KOMTdSVwJpicmhN309BeEyRyQX+n1XDF0JVSlu28+hiTQ2L4rZPvu7nMw==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-arm64-musl": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-arm64-musl/-/cli-linux-arm64-musl-2.2.4.tgz", + "integrity": "sha512-7TNPkMQEWfjvJDaZRSkDCPT/2r5ESFPKx+TEev+I2BXDGIjfCZk2+b88FOhnJNHtksbOZv8ZWnxrA5gyTYhSsQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64/-/cli-linux-x64-2.2.4.tgz", + "integrity": "sha512-orr3nnf2Dpb2ssl6aihQtvcKtLySLta4E2UcXdp7+RTa7mfJjBgIsbS0B9GC8gVu0hjOu021aU8b3/I1tn+pVQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-linux-x64-musl": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-linux-x64-musl/-/cli-linux-x64-musl-2.2.4.tgz", + "integrity": "sha512-m41nFDS0ksXK2gwXL6W6yZTYPMH0LughqbsxInSKetoH6morVj43szqKx79Iudkp8WRT5SxSh7qVb8KCUiewGg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "linux" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-arm64": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-arm64/-/cli-win32-arm64-2.2.4.tgz", + "integrity": "sha512-NXnfTeKHDFUWfxAefa57DiGmu9VyKi0cDqFpdI+1hJWQjGJhJutHPX0b5m+eXvTKOaf+brU+P0JrQAZMb5yYaQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, + "node_modules/@biomejs/cli-win32-x64": { + "version": "2.2.4", + "resolved": "https://registry.npmjs.org/@biomejs/cli-win32-x64/-/cli-win32-x64-2.2.4.tgz", + "integrity": "sha512-3Y4V4zVRarVh/B/eSHczR4LYoSVyv3Dfuvm3cWs5w/HScccS0+Wt/lHOcDTRYeHjQmMYVC3rIRWqyN2EI52+zg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT OR Apache-2.0", + "optional": true, + "os": [ + "win32" + ], + "engines": { + "node": ">=14.21.3" + } + }, "node_modules/@cspotcode/source-map-support": { "version": "0.8.1", "resolved": "https://registry.npmjs.org/@cspotcode/source-map-support/-/source-map-support-0.8.1.tgz", @@ -79,9 +246,9 @@ } }, "node_modules/@jridgewell/sourcemap-codec": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.0.tgz", - "integrity": "sha512-gv3ZRaISU3fjPAgNsriBRqGWQL6quFx04YMPW/zD8XMLsU32mhCCbfbO6KZFLjvYpCZ8zyDEgqsgf+PwPaM7GQ==", + "version": "1.5.5", + "resolved": "https://registry.npmjs.org/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.5.5.tgz", + "integrity": "sha512-cYQ9310grqxueWbl+WuIUIaiUaDcj7WOq5fVhEljNVgRfOUhY9fy2zTvfoqWsnebh8Sl70VScFbICvJnLKB0Og==", "dev": true, "license": "MIT" }, diff --git a/package.json b/package.json index 66525e5..4387b1b 100644 --- a/package.json +++ b/package.json @@ -14,9 +14,11 @@ "build": "tsc", "test": "npm-run-all test:*", "test:audit": "npm audit", - "test:types": "tsc --noEmit --incremental false" + "test:types": "tsc --noEmit --incremental false", + "test:lint": "biome lint . --diagnostic-level=error" }, "devDependencies": { + "@biomejs/biome": "2.2.4", "@types/express": "5.0.3", "@types/qr-image": "3.2.9", "@types/qrcode": "1.5.5", From f477a2da809ee427efc7a9ed1537cb2d9d7648bf Mon Sep 17 00:00:00 2001 From: zapolnoch Date: Thu, 11 Sep 2025 01:38:39 +0300 Subject: [PATCH 3/7] refactor: biome fix --- src/bot.ts | 8 +- src/handlers/callback/clash.ts | 86 ++++---- src/handlers/callback/sub.ts | 86 ++++---- src/handlers/clash.ts | 42 ++-- src/handlers/delete.ts | 4 +- src/handlers/feedback.ts | 373 ++++++++++++++++----------------- src/handlers/index.ts | 4 +- src/handlers/score.ts | 130 ++++++------ src/handlers/site.ts | 4 +- src/handlers/start.ts | 5 +- src/handlers/stat.ts | 88 ++++---- src/handlers/sub.ts | 6 +- src/site/index.ts | 8 +- src/state.ts | 10 +- src/types/conn.ts | 68 +++--- src/types/stat.ts | 26 +-- src/utils.ts | 2 +- 17 files changed, 471 insertions(+), 479 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index da65bfc..444f521 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -5,11 +5,11 @@ import { awaitingMnemonic, siteHandler, statHandler, - subPlainHandler, subClashHandler, + subPlainHandler, } from "./handlers"; -import { handleSubscriptionCallback } from "./handlers/callback/sub"; import { handleSubscriptionClashCallback } from "./handlers/callback/clash"; +import { handleSubscriptionCallback } from "./handlers/callback/sub"; import { deleteHandler } from "./handlers/delete"; import { feedbackHandler, @@ -18,8 +18,8 @@ import { } from "./handlers/feedback"; import { scoreHandler } from "./handlers/score"; import { startHandler } from "./handlers/start"; -import { BotState } from "./state"; import { connectWithMnemonic } from "./site"; +import { BotState } from "./state"; dotenv.config(); @@ -160,6 +160,7 @@ process.on("SIGTERM", () => gracefulShutdown("SIGTERM")); console.error("Ошибка в siteHandler:", err); await ctx.reply("Ошибка при обработке фразы."); } finally { + // biome-ignore lint/correctness/noUnsafeFinally: TODO return; } } @@ -181,6 +182,7 @@ process.on("SIGTERM", () => gracefulShutdown("SIGTERM")); }); // Callback query handler + // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO bot.on("callback_query", async (ctx) => { try { const callbackQuery = ctx.callbackQuery; diff --git a/src/handlers/callback/clash.ts b/src/handlers/callback/clash.ts index de20f8d..ac1265f 100644 --- a/src/handlers/callback/clash.ts +++ b/src/handlers/callback/clash.ts @@ -1,48 +1,48 @@ import QRCode from "qrcode"; -import { Context } from "telegraf"; -import { BotState } from "../../state"; +import type { Context } from "telegraf"; +import type { BotState } from "../../state"; export async function handleSubscriptionClashCallback( - ctx: Context, - botState: BotState, + ctx: Context, + botState: BotState, ) { - const callbackQuery = ctx.callbackQuery; - - if (!callbackQuery || !("data" in callbackQuery)) { - return await ctx.answerCbQuery(); - } - - const data = callbackQuery.data; - if (!data) { - return await ctx.answerCbQuery(); - } - - const user = ctx.from; - if (!user || !user.username) { - return ctx.answerCbQuery("Не удалось определить пользователя."); - } - - const userEntry = await botState.findUserByTelegramId(user.id); - if (!userEntry || userEntry.is_deleted) { - return ctx.answerCbQuery("Для начала используйте /start"); - } - - const subLink = botState.getSubLink(userEntry.id, "clash"); - - const qrBuffer = await QRCode.toBuffer(subLink, { - errorCorrectionLevel: "H", - type: "png", - margin: 8, - scale: 6, - }); - - await ctx.editMessageText( - `*Нажмите на ссылку, чтобы скопировать* \n\`\`\`\n${subLink}\n\`\`\``, - { parse_mode: "MarkdownV2" }, - ); - - await ctx.replyWithPhoto( - { source: qrBuffer }, - { caption: `QR-код для VPN Clash подписки 🧷` }, - ); + const callbackQuery = ctx.callbackQuery; + + if (!callbackQuery || !("data" in callbackQuery)) { + return await ctx.answerCbQuery(); + } + + const data = callbackQuery.data; + if (!data) { + return await ctx.answerCbQuery(); + } + + const user = ctx.from; + if (!user || !user.username) { + return ctx.answerCbQuery("Не удалось определить пользователя."); + } + + const userEntry = await botState.findUserByTelegramId(user.id); + if (!userEntry || userEntry.is_deleted) { + return ctx.answerCbQuery("Для начала используйте /start"); + } + + const subLink = botState.getSubLink(userEntry.id, "clash"); + + const qrBuffer = await QRCode.toBuffer(subLink, { + errorCorrectionLevel: "H", + type: "png", + margin: 8, + scale: 6, + }); + + await ctx.editMessageText( + `*Нажмите на ссылку, чтобы скопировать* \n\`\`\`\n${subLink}\n\`\`\``, + { parse_mode: "MarkdownV2" }, + ); + + await ctx.replyWithPhoto( + { source: qrBuffer }, + { caption: `QR-код для VPN Clash подписки 🧷` }, + ); } diff --git a/src/handlers/callback/sub.ts b/src/handlers/callback/sub.ts index bab4e73..e0a8634 100644 --- a/src/handlers/callback/sub.ts +++ b/src/handlers/callback/sub.ts @@ -1,48 +1,48 @@ import QRCode from "qrcode"; -import { Context } from "telegraf"; -import { BotState } from "../../state"; +import type { Context } from "telegraf"; +import type { BotState } from "../../state"; export async function handleSubscriptionCallback( - ctx: Context, - botState: BotState, + ctx: Context, + botState: BotState, ) { - const callbackQuery = ctx.callbackQuery; - - if (!callbackQuery || !("data" in callbackQuery)) { - return await ctx.answerCbQuery(); - } - - const data = callbackQuery.data; - if (!data) { - return await ctx.answerCbQuery(); - } - - const user = ctx.from; - if (!user || !user.username) { - return ctx.answerCbQuery("Не удалось определить пользователя."); - } - - const userEntry = await botState.findUserByTelegramId(user.id); - if (!userEntry || userEntry.is_deleted) { - return ctx.answerCbQuery("Для начала используйте /start"); - } - - const subLink = botState.getSubLink(userEntry.id, "plain"); - - const qrBuffer = await QRCode.toBuffer(subLink, { - errorCorrectionLevel: "H", - type: "png", - margin: 8, - scale: 6, - }); - - await ctx.editMessageText( - `*Нажмите на ссылку, чтобы скопировать* \n\`\`\`\n${subLink}\n\`\`\``, - { parse_mode: "MarkdownV2" }, - ); - - await ctx.replyWithPhoto( - { source: qrBuffer }, - { caption: `QR-код для VPN подписки 🧷` }, - ); + const callbackQuery = ctx.callbackQuery; + + if (!callbackQuery || !("data" in callbackQuery)) { + return await ctx.answerCbQuery(); + } + + const data = callbackQuery.data; + if (!data) { + return await ctx.answerCbQuery(); + } + + const user = ctx.from; + if (!user || !user.username) { + return ctx.answerCbQuery("Не удалось определить пользователя."); + } + + const userEntry = await botState.findUserByTelegramId(user.id); + if (!userEntry || userEntry.is_deleted) { + return ctx.answerCbQuery("Для начала используйте /start"); + } + + const subLink = botState.getSubLink(userEntry.id, "plain"); + + const qrBuffer = await QRCode.toBuffer(subLink, { + errorCorrectionLevel: "H", + type: "png", + margin: 8, + scale: 6, + }); + + await ctx.editMessageText( + `*Нажмите на ссылку, чтобы скопировать* \n\`\`\`\n${subLink}\n\`\`\``, + { parse_mode: "MarkdownV2" }, + ); + + await ctx.replyWithPhoto( + { source: qrBuffer }, + { caption: `QR-код для VPN подписки 🧷` }, + ); } diff --git a/src/handlers/clash.ts b/src/handlers/clash.ts index 85b642c..b21a02d 100644 --- a/src/handlers/clash.ts +++ b/src/handlers/clash.ts @@ -1,29 +1,29 @@ -import { Context } from "telegraf"; -import { InlineKeyboardMarkup } from "telegraf/types"; +import type { Context } from "telegraf"; +import type { InlineKeyboardMarkup } from "telegraf/types"; import { buildSubClashKeyboard } from "../keyboards"; -import { BotState } from "../state"; +import type { BotState } from "../state"; export const subClashHandler = async (ctx: Context, botState: BotState) => { - const user = ctx.from; + const user = ctx.from; - if (!user) { - return ctx.reply("/start для начала"); - } + if (!user) { + return ctx.reply("/start для начала"); + } - const userEntry = await botState.findUserByTelegramId(user.id); + const userEntry = await botState.findUserByTelegramId(user.id); - if (!userEntry || userEntry.is_deleted) { - return ctx.reply("Для начала /start"); - } - console.log("User: ", userEntry); - const keyboard: InlineKeyboardMarkup = await buildSubClashKeyboard(); + if (!userEntry || userEntry.is_deleted) { + return ctx.reply("Для начала /start"); + } + console.log("User: ", userEntry); + const keyboard: InlineKeyboardMarkup = await buildSubClashKeyboard(); - return ctx.reply( - "▫️ Подходит для: Clash Verge, Clash Meta, Stash \\(iOS\\), ShadowRocket и других" + - " \n\n*Нажмите на кнопку, чтобы получить ссылку*", - { - reply_markup: keyboard, - parse_mode: "MarkdownV2", - }, - ); + return ctx.reply( + "▫️ Подходит для: Clash Verge, Clash Meta, Stash \\(iOS\\), ShadowRocket и других" + + " \n\n*Нажмите на кнопку, чтобы получить ссылку*", + { + reply_markup: keyboard, + parse_mode: "MarkdownV2", + }, + ); }; diff --git a/src/handlers/delete.ts b/src/handlers/delete.ts index af7445c..a143de4 100644 --- a/src/handlers/delete.ts +++ b/src/handlers/delete.ts @@ -1,5 +1,5 @@ -import { Context } from "telegraf"; -import { BotState } from "../state"; +import type { Context } from "telegraf"; +import type { BotState } from "../state"; export const deleteHandler = async (ctx: Context, botState: BotState) => { const user = ctx.from; diff --git a/src/handlers/feedback.ts b/src/handlers/feedback.ts index efa3bf2..4ace8ef 100644 --- a/src/handlers/feedback.ts +++ b/src/handlers/feedback.ts @@ -1,210 +1,203 @@ // handlers/feedback.ts - Secure version for VPN service -import { Context } from "telegraf"; -import { BotState } from "../state"; +import type { Context } from "telegraf"; +import type { BotState } from "../state"; interface FeedbackData { - token: string; - username?: string; - user_id: number; - message: string; - rating?: string; - date: string; + token: string; + username?: string; + user_id: number; + message: string; + rating?: string; + date: string; } // Rate limiting: user_id -> last message time const userLastMessage = new Map(); const userFeedbackState = new Map< - number, - { rating?: string; awaitingMessage: boolean } + number, + { rating?: string; awaitingMessage: boolean } >(); export const feedbackHandler = async (ctx: Context, botState: BotState) => { - const userId = ctx.from?.id; - if (!userId) return; - - // Check rate limiting (5 minutes between feedback) - const now = Date.now(); - const lastMessageTime = userLastMessage.get(userId) || 0; - const fiveMinutes = 5 * 60 * 1000; - - if (now - lastMessageTime < fiveMinutes) { - const remainingTime = Math.ceil( - (fiveMinutes - (now - lastMessageTime)) / 60000, - ); - await ctx.reply( - `⏱️ Пожалуйста, подождите ${remainingTime} мин. перед отправкой следующего отзыва.`, - ); - return; - } - - const keyboard = { - inline_keyboard: [ - [ - { text: "⭐", callback_data: "feedback_rate_1" }, - { text: "⭐⭐", callback_data: "feedback_rate_2" }, - { text: "⭐⭐⭐", callback_data: "feedback_rate_3" }, - ], - [ - { text: "⭐⭐⭐⭐", callback_data: "feedback_rate_4" }, - { text: "⭐⭐⭐⭐⭐", callback_data: "feedback_rate_5" }, - ], - ], - }; - - await ctx.reply( - "📝 Сообщить о проблеме или оставить отзыв о нашем VPN сервисе!\n\nСначала оцените ваш опыт:", - { reply_markup: keyboard }, - ); + const userId = ctx.from?.id; + if (!userId) return; + + // Check rate limiting (5 minutes between feedback) + const now = Date.now(); + const lastMessageTime = userLastMessage.get(userId) || 0; + const fiveMinutes = 5 * 60 * 1000; + + if (now - lastMessageTime < fiveMinutes) { + const remainingTime = Math.ceil( + (fiveMinutes - (now - lastMessageTime)) / 60000, + ); + await ctx.reply( + `⏱️ Пожалуйста, подождите ${remainingTime} мин. перед отправкой следующего отзыва.`, + ); + return; + } + + const keyboard = { + inline_keyboard: [ + [ + { text: "⭐", callback_data: "feedback_rate_1" }, + { text: "⭐⭐", callback_data: "feedback_rate_2" }, + { text: "⭐⭐⭐", callback_data: "feedback_rate_3" }, + ], + [ + { text: "⭐⭐⭐⭐", callback_data: "feedback_rate_4" }, + { text: "⭐⭐⭐⭐⭐", callback_data: "feedback_rate_5" }, + ], + ], + }; + + await ctx.reply( + "📝 Сообщить о проблеме или оставить отзыв о нашем VPN сервисе!\n\nСначала оцените ваш опыт:", + { reply_markup: keyboard }, + ); }; export const handleFeedbackCallback = async ( - ctx: Context, - botState: BotState, + ctx: Context, + botState: BotState, ) => { - const callbackQuery = ctx.callbackQuery; - if (!callbackQuery || !("data" in callbackQuery)) return; - - const data = callbackQuery.data; - if (!data?.startsWith("feedback_rate_")) return; - - const rating = data.replace("feedback_rate_", ""); - const userId = ctx.from?.id; - - if (!userId) return; - - // Rating validation - if (!["1", "2", "3", "4", "5"].includes(rating)) { - await ctx.answerCbQuery("Неверная оценка"); - return; - } - - userFeedbackState.set(userId, { rating, awaitingMessage: true }); - - const stars = "⭐".repeat(parseInt(rating)); - await ctx.editMessageText( - `Спасибо за оценку ${stars}!\n\n💬 Теперь опишите вашу проблему или отзыв. Для быстрого решения укажите:\n\n` + - ` 📱 Тип устройства (iPhone, Android, Windows и т.д.)\n` + - ` 🌍 Ваше местоположение/город/провайдер\n` + - ` 📡 Тип соединения (протокол/к какому серверу/стране подключаетесь)\n` + - `\n ` + - ` 🔧 Если есть — Ваш Id с сайта frkn.org в виде XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX#cluster_nameN\n` + - `\nСпасибо\nМаксимум 1000 символов:`, - ); + const callbackQuery = ctx.callbackQuery; + if (!callbackQuery || !("data" in callbackQuery)) return; + + const data = callbackQuery.data; + if (!data?.startsWith("feedback_rate_")) return; + + const rating = data.replace("feedback_rate_", ""); + const userId = ctx.from?.id; + + if (!userId) return; + + // Rating validation + if (!["1", "2", "3", "4", "5"].includes(rating)) { + await ctx.answerCbQuery("Неверная оценка"); + return; + } + + userFeedbackState.set(userId, { rating, awaitingMessage: true }); + + const stars = "⭐".repeat(parseInt(rating)); + await ctx.editMessageText( + `Спасибо за оценку ${stars}!\n\n💬 Теперь опишите вашу проблему или отзыв. Для быстрого решения укажите:\n\n` + + ` 📱 Тип устройства (iPhone, Android, Windows и т.д.)\n` + + ` 🌍 Ваше местоположение/город/провайдер\n` + + ` 📡 Тип соединения (протокол/к какому серверу/стране подключаетесь)\n` + + `\n ` + + ` 🔧 Если есть — Ваш Id с сайта frkn.org в виде XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX#cluster_nameN\n` + + `\nСпасибо\nМаксимум 1000 символов:`, + ); }; export const handleFeedbackMessage = async ( - ctx: Context, - botState: BotState, + ctx: Context, + botState: BotState, + // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO ): Promise => { - const userId = ctx.from?.id; - const message = - ctx.message && "text" in ctx.message ? ctx.message.text : ""; - - if (!userId || !message) return false; - - const userState = userFeedbackState.get(userId); - if (!userState?.awaitingMessage) return false; - - // Message validation - if (message.length > 1000) { - await ctx.reply( - "❌ Сообщение слишком длинное. Максимум 1000 символов.", - ); - return true; - } - - // Filter suspicious content - const cleanMessage = message - .replace(/<[^>]*>/g, "[HTML удален]") // Remove HTML - .replace(/javascript:/gi, "[JS удален]") // Remove JS - .replace(/script/gi, "[СКРИПТ удален]"); // Remove script - - // Simple spam check - const spamWords = [ - "казино", - "нажмите здесь", - "advertisement", - "casino", - "click here", - ]; - const isSpam = spamWords.some((word) => - cleanMessage.toLowerCase().includes(word), - ); - - if (isSpam) { - await ctx.reply("❌ Сообщение содержит запрещенный контент."); - userFeedbackState.delete(userId); - return true; - } - - const feedbackData: FeedbackData = { - token: botState.getGoogleScriptToken(), - username: - ctx.from?.username || - `${ctx.from?.first_name} ${ctx.from?.last_name}`.trim(), - user_id: userId, - message: cleanMessage, - rating: userState.rating, - date: new Date().toISOString(), - }; - - try { - const response = await fetch(botState.getGoogleScriptUrl(), { - method: "POST", - headers: { - "Content-Type": "application/json", - }, - body: JSON.stringify(feedbackData), - // Add timeout - signal: AbortSignal.timeout(10000), // 10 seconds - }); - - const result = await response.json().catch(() => ({ status: "error" })); - - if (response.ok && result.status === "success") { - await ctx.reply( - "✅ Спасибо за ваш отзыв! Мы рассмотрим его и поработаем над улучшениями или свяжемся с вами напрямую.", - ); - - // Update last message time - userLastMessage.set(userId, Date.now()); - - // Send admin notification - if (botState.getAdminChatId()) { - const adminMessage = - `🔔 Новый отзыв/сообщение о проблеме VPN!\n\n` + - `👤 От: @${feedbackData.username} (ID: ${feedbackData.user_id})\n` + - `⭐ Оценка: ${feedbackData.rating}/5\n` + - `💬 Сообщение: ${feedbackData.message}`; - - try { - await ctx.telegram.sendMessage( - botState.getAdminChatId(), - adminMessage, - ); - } catch (adminError) { - console.error( - "Failed to send admin notification:", - adminError, - ); - } - } - } else if (result.message === "Rate limit exceeded") { - await ctx.reply("⏱️ Слишком много сообщений. Попробуйте позже."); - } else { - throw new Error(`Server responded: ${result.message}`); - } - } catch (error) { - console.error("Error sending feedback:", error); - if (error instanceof Error && error.name === "TimeoutError") { - await ctx.reply("⏱️ Превышено время ожидания. Попробуйте позже."); - } else { - await ctx.reply( - "❌ Ошибка сохранения сообщения. Попробуйте позже.", - ); - } - } - - userFeedbackState.delete(userId); - return true; + const userId = ctx.from?.id; + const message = ctx.message && "text" in ctx.message ? ctx.message.text : ""; + + if (!userId || !message) return false; + + const userState = userFeedbackState.get(userId); + if (!userState?.awaitingMessage) return false; + + // Message validation + if (message.length > 1000) { + await ctx.reply("❌ Сообщение слишком длинное. Максимум 1000 символов."); + return true; + } + + // Filter suspicious content + const cleanMessage = message + .replace(/<[^>]*>/g, "[HTML удален]") // Remove HTML + .replace(/javascript:/gi, "[JS удален]") // Remove JS + .replace(/script/gi, "[СКРИПТ удален]"); // Remove script + + // Simple spam check + const spamWords = [ + "казино", + "нажмите здесь", + "advertisement", + "casino", + "click here", + ]; + const isSpam = spamWords.some((word) => + cleanMessage.toLowerCase().includes(word), + ); + + if (isSpam) { + await ctx.reply("❌ Сообщение содержит запрещенный контент."); + userFeedbackState.delete(userId); + return true; + } + + const feedbackData: FeedbackData = { + token: botState.getGoogleScriptToken(), + username: + ctx.from?.username || + `${ctx.from?.first_name} ${ctx.from?.last_name}`.trim(), + user_id: userId, + message: cleanMessage, + rating: userState.rating, + date: new Date().toISOString(), + }; + + try { + const response = await fetch(botState.getGoogleScriptUrl(), { + method: "POST", + headers: { + "Content-Type": "application/json", + }, + body: JSON.stringify(feedbackData), + // Add timeout + signal: AbortSignal.timeout(10000), // 10 seconds + }); + + const result = await response.json().catch(() => ({ status: "error" })); + + if (response.ok && result.status === "success") { + await ctx.reply( + "✅ Спасибо за ваш отзыв! Мы рассмотрим его и поработаем над улучшениями или свяжемся с вами напрямую.", + ); + + // Update last message time + userLastMessage.set(userId, Date.now()); + + // Send admin notification + if (botState.getAdminChatId()) { + const adminMessage = + `🔔 Новый отзыв/сообщение о проблеме VPN!\n\n` + + `👤 От: @${feedbackData.username} (ID: ${feedbackData.user_id})\n` + + `⭐ Оценка: ${feedbackData.rating}/5\n` + + `💬 Сообщение: ${feedbackData.message}`; + + try { + await ctx.telegram.sendMessage( + botState.getAdminChatId(), + adminMessage, + ); + } catch (adminError) { + console.error("Failed to send admin notification:", adminError); + } + } + } else if (result.message === "Rate limit exceeded") { + await ctx.reply("⏱️ Слишком много сообщений. Попробуйте позже."); + } else { + throw new Error(`Server responded: ${result.message}`); + } + } catch (error) { + console.error("Error sending feedback:", error); + if (error instanceof Error && error.name === "TimeoutError") { + await ctx.reply("⏱️ Превышено время ожидания. Попробуйте позже."); + } else { + await ctx.reply("❌ Ошибка сохранения сообщения. Попробуйте позже."); + } + } + + userFeedbackState.delete(userId); + return true; }; diff --git a/src/handlers/index.ts b/src/handlers/index.ts index 78361bd..ed7c122 100644 --- a/src/handlers/index.ts +++ b/src/handlers/index.ts @@ -1,5 +1,5 @@ -export * from "./start"; +export * from "./clash"; export * from "./site"; +export * from "./start"; export * from "./stat"; export * from "./sub"; -export * from "./clash"; diff --git a/src/handlers/score.ts b/src/handlers/score.ts index e9bbfc4..b70c9ab 100644 --- a/src/handlers/score.ts +++ b/src/handlers/score.ts @@ -1,82 +1,78 @@ -import { BotState } from "../state"; -import { Context } from "telegraf"; +import type { Context } from "telegraf"; +import type { BotState } from "../state"; export const scoreHandler = async (ctx: Context, botState: BotState) => { - const user = ctx.from; - if (!user) return ctx.reply("/start для начала"); + const user = ctx.from; + if (!user) return ctx.reply("/start для начала"); - const userEntry = await botState.findUserByTelegramId(user.id); - if (!userEntry || userEntry.is_deleted) - return ctx.reply("Для начала /start"); + const userEntry = await botState.findUserByTelegramId(user.id); + if (!userEntry || userEntry.is_deleted) return ctx.reply("Для начала /start"); - await ctx.reply("⚙️ Считаю метрики, подожди..."); + await ctx.reply("⚙️ Считаю метрики, подожди..."); - try { - const env = botState.getEnv(); - const nodes = await botState.getNodes(env); - if (!nodes || nodes.length === 0) { - return ctx.reply("❌ Нет доступных нод для оценки"); - } + try { + const env = botState.getEnv(); + const nodes = await botState.getNodes(env); + if (!nodes || nodes.length === 0) { + return ctx.reply("❌ Нет доступных нод для оценки"); + } - const scores = await Promise.all( - nodes.map(async (node) => { - const score = await botState.getNodeScore(node.uuid); + const scores = await Promise.all( + nodes.map(async (node) => { + const score = await botState.getNodeScore(node.uuid); - return { - hostname: node.hostname, - env: node.env, - label: node.label, - score: score?.score ?? null, - details: score?.details ?? null, - max_band: node.max_bandwidth_bps, - status: node.status, - }; - }), - ); + return { + hostname: node.hostname, + env: node.env, + label: node.label, + score: score?.score ?? null, + details: score?.details ?? null, + max_band: node.max_bandwidth_bps, + status: node.status, + }; + }), + ); - const header = - "📊 Статус серверов (чем ниже нагрузка, тем лучше):\n" + - "🟢 — низкая нагрузка\n" + - "🟡 — средняя нагрузка\n" + - "🔴 — высокая нагрузка\n\n"; + const header = + "📊 Статус серверов (чем ниже нагрузка, тем лучше):\n" + + "🟢 — низкая нагрузка\n" + + "🟡 — средняя нагрузка\n" + + "🔴 — высокая нагрузка\n\n"; - const formatted = scores - .sort((a, b) => { - if (a.score === null) return 1; - if (b.score === null) return -1; - return b.score - a.score; - }) - .map((s) => { - if (s.status === "Offline") { - return `🔴 Offline - ${s.label} (${s.env})\n⛔ Нода недоступна\n`; - } + const formatted = scores + .sort((a, b) => { + if (a.score === null) return 1; + if (b.score === null) return -1; + return b.score - a.score; + }) + .map((s) => { + if (s.status === "Offline") { + return `🔴 Offline - ${s.label} (${s.env})\n⛔ Нода недоступна\n`; + } - if (s.score) { - const score = s.score; - const emoji = - score < 0.4 ? "🟢" : score < 0.75 ? "🟡" : "🔴"; + if (s.score) { + const score = s.score; + const emoji = score < 0.4 ? "🟢" : score < 0.75 ? "🟡" : "🔴"; - const bandwidthCurrentMbps = ( - (s.details?.bandwidth ?? 0) / 1_000_000 - ).toFixed(1); - const bandwidthMaxMbps = (s.max_band / 1_000_000).toFixed( - 1, - ); + const bandwidthCurrentMbps = ( + (s.details?.bandwidth ?? 0) / 1_000_000 + ).toFixed(1); + const bandwidthMaxMbps = (s.max_band / 1_000_000).toFixed(1); - return `${emoji} ${s.status} - ${s.label} (${s.env}) \nИспользуется: ${bandwidthCurrentMbps}/${bandwidthMaxMbps} Mbps \nНагрузка: ${(score * 100).toFixed(1)} / 100%\n`; - } else { - return `🟡 Online - ${s.label} (${s.env})\nСтатистика сервера недоступна\n\n`; - } - }) - .join("\n"); + return `${emoji} ${s.status} - ${s.label} (${s.env}) \nИспользуется: ${bandwidthCurrentMbps}/${bandwidthMaxMbps} Mbps \nНагрузка: ${(score * 100).toFixed(1)} / 100%\n`; + } else { + return `🟡 Online - ${s.label} (${s.env})\nСтатистика сервера недоступна\n\n`; + } + }) + .join("\n"); - if (!formatted) { - return ctx.reply("❌ Не удалось получить скор ни для одной ноды"); - } + if (!formatted) { + return ctx.reply("❌ Не удалось получить скор ни для одной ноды"); + } - return ctx.replyWithHTML(header + formatted); - } catch (err) { - console.error("❌ Ошибка при обработке scoreHandler:", err); - return ctx.reply("❌ Не удалось получить метрики"); - } + return ctx.replyWithHTML(header + formatted); + } catch (err) { + console.error("❌ Ошибка при обработке scoreHandler:", err); + return ctx.reply("❌ Не удалось получить метрики"); + } }; diff --git a/src/handlers/site.ts b/src/handlers/site.ts index 80be199..3b75ccb 100644 --- a/src/handlers/site.ts +++ b/src/handlers/site.ts @@ -1,5 +1,5 @@ -import { Context } from "telegraf"; -import { BotState } from "../state"; +import type { Context } from "telegraf"; +import type { BotState } from "../state"; export const awaitingMnemonic: Record = {}; diff --git a/src/handlers/start.ts b/src/handlers/start.ts index 6218398..edadf08 100644 --- a/src/handlers/start.ts +++ b/src/handlers/start.ts @@ -1,5 +1,5 @@ -import { Context } from "telegraf"; -import { BotState } from "../state"; +import type { Context } from "telegraf"; +import type { BotState } from "../state"; import { generateUsername } from "../utils"; export const startHandler = async (ctx: Context, botState: BotState) => { @@ -39,6 +39,7 @@ export const startHandler = async (ctx: Context, botState: BotState) => { const result = await botState.registerUser(user.id, username); switch (result.type) { + // biome-ignore lint/suspicious/noFallthroughSwitchClause: TODO case "ok": { const userEntry = await botState.findUserByTelegramId(user.id); if (userEntry) { diff --git a/src/handlers/stat.ts b/src/handlers/stat.ts index 6cd461d..caa1d12 100644 --- a/src/handlers/stat.ts +++ b/src/handlers/stat.ts @@ -1,56 +1,56 @@ -import { Context } from "telegraf"; -import { BotState } from "../state"; -import { UserStat } from "../types/stat"; +import type { Context } from "telegraf"; +import type { BotState } from "../state"; +import type { UserStat } from "../types/stat"; export const statHandler = async (ctx: Context, botState: BotState) => { - const user = ctx.from; + const user = ctx.from; - if (!user) { - return ctx.reply("/start для начала"); - } + if (!user) { + return ctx.reply("/start для начала"); + } - const userEntry = await botState.findUserByTelegramId(user.id); + const userEntry = await botState.findUserByTelegramId(user.id); - if (!userEntry || userEntry.is_deleted) { - return ctx.reply("Для начала /start"); - } + if (!userEntry || userEntry.is_deleted) { + return ctx.reply("Для начала /start"); + } - const stat = await botState.getUserStat(userEntry.id); + const stat = await botState.getUserStat(userEntry.id); - if (stat) { - const msg = formatTrafficStats(stat); + if (stat) { + const msg = formatTrafficStats(stat); - return ctx.reply(msg); - } + return ctx.reply(msg); + } }; function formatTrafficStats(stats: UserStat[]): string { - const parts = stats.map((s) => { - const lines = [`🔹 ${s.type}`, ` id: ${s.id}`]; - - lines.push( - ``, - ``, - ` • ↑ Upload: ${Math.round(s.stat.uplink / (1024 * 1024))} MB`, - ` • ↓ Download: ${Math.round(s.stat.downlink / (1024 * 1024))} MB`, - ` • Devices Online: ${s.stat.online}`, - ); - return lines.join("\n"); - }); - - const totalUpload = Math.round( - stats.reduce((sum, s) => sum + s.stat.uplink, 0) / (1024 * 1024), - ); - const totalDownload = Math.round( - stats.reduce((sum, s) => sum + s.stat.downlink, 0) / (1024 * 1024), - ); - - return [ - `Статистика трафика за сегодня:\n`, - parts.join("\n\n"), - `\n🔻 Суммарно:`, - ``, - ` ↑ Upload: ${totalUpload} MB`, - ` ↓ Download: ${totalDownload} MB`, - ].join("\n"); + const parts = stats.map((s) => { + const lines = [`🔹 ${s.type}`, ` id: ${s.id}`]; + + lines.push( + ``, + ``, + ` • ↑ Upload: ${Math.round(s.stat.uplink / (1024 * 1024))} MB`, + ` • ↓ Download: ${Math.round(s.stat.downlink / (1024 * 1024))} MB`, + ` • Devices Online: ${s.stat.online}`, + ); + return lines.join("\n"); + }); + + const totalUpload = Math.round( + stats.reduce((sum, s) => sum + s.stat.uplink, 0) / (1024 * 1024), + ); + const totalDownload = Math.round( + stats.reduce((sum, s) => sum + s.stat.downlink, 0) / (1024 * 1024), + ); + + return [ + `Статистика трафика за сегодня:\n`, + parts.join("\n\n"), + `\n🔻 Суммарно:`, + ``, + ` ↑ Upload: ${totalUpload} MB`, + ` ↓ Download: ${totalDownload} MB`, + ].join("\n"); } diff --git a/src/handlers/sub.ts b/src/handlers/sub.ts index 5db2f1c..6348039 100644 --- a/src/handlers/sub.ts +++ b/src/handlers/sub.ts @@ -1,7 +1,7 @@ -import { Context } from "telegraf"; -import { InlineKeyboardMarkup } from "telegraf/types"; +import type { Context } from "telegraf"; +import type { InlineKeyboardMarkup } from "telegraf/types"; import { buildSubPlainKeyboard } from "../keyboards"; -import { BotState } from "../state"; +import type { BotState } from "../state"; export const subPlainHandler = async (ctx: Context, botState: BotState) => { const user = ctx.from; diff --git a/src/site/index.ts b/src/site/index.ts index 03a88d7..1f1fa10 100644 --- a/src/site/index.ts +++ b/src/site/index.ts @@ -1,11 +1,11 @@ import axios from "axios"; import { sha3_512 } from "js-sha3"; -import { ActiveConnection, LoginResponse } from "./types"; +import type { ActiveConnection, LoginResponse } from "./types"; const SITE_URL = process.env.SITE_URL || "https://frkn.org"; export async function connectWithMnemonic( - mnemonic: string + mnemonic: string, ): Promise { const passwordHash = sha3_512(mnemonic); @@ -13,7 +13,7 @@ export async function connectWithMnemonic( const loginResp = await axios.post( SITE_URL + "/api/login", { password: passwordHash }, - { headers: { "Content-Type": "application/json" } } + { headers: { "Content-Type": "application/json" } }, ); if (loginResp.data.status === "error") { @@ -27,7 +27,7 @@ export async function connectWithMnemonic( "Content-Type": "application/json", Authorization: loginResp.data.token, }, - } + }, ); return connectResp.data as ActiveConnection; diff --git a/src/state.ts b/src/state.ts index 316ec1f..b662fd7 100644 --- a/src/state.ts +++ b/src/state.ts @@ -1,14 +1,14 @@ -import { PrismaClient, User as PrismaUser } from "@prisma/client"; +import { PrismaClient, type User as PrismaUser } from "@prisma/client"; import axios from "axios"; -import { RegisterResult, User } from "./types"; -import { +import type { RegisterResult, User } from "./types"; +import type { ConnectionResponse, ConnectionsResponseEntryRaw, CreateConnectionRequest, CreateConnectionResponse, } from "./types/conn"; -import { NodeResponse, NodeScore } from "./types/node"; -import { UserStat, UserStatRaw } from "./types/stat"; +import type { NodeResponse, NodeScore } from "./types/node"; +import type { UserStat, UserStatRaw } from "./types/stat"; import { generatePassword } from "./utils"; export class BotState { diff --git a/src/types/conn.ts b/src/types/conn.ts index 34abfa6..e1e5f80 100644 --- a/src/types/conn.ts +++ b/src/types/conn.ts @@ -1,50 +1,50 @@ export type CreateConnectionRequest = { - env: string; - proto: string; - user_id: string; - node_id?: string; + env: string; + proto: string; + user_id: string; + node_id?: string; }; export type WireguardResponse = { - Wireguard: { - param: { - keys: { - privkey: string; - pubkey: string; - }; - address: { - addr: string; - cidr: number; - }; - }; - node_id: string; - }; + Wireguard: { + param: { + keys: { + privkey: string; + pubkey: string; + }; + address: { + addr: string; + cidr: number; + }; + }; + node_id: string; + }; }; export type XrayResponse = { - Xray: string; + Xray: string; }; export type ConnectionResponse = { - id: string; - env: string; - proto: WireguardResponse | XrayResponse; - stat: { - downlink: number; - uplink: number; - online: number; - }; - user_id: string; - created_at: string; - modified_at: string; - is_deleted: boolean; - node_id: string | null; + id: string; + env: string; + proto: WireguardResponse | XrayResponse; + stat: { + downlink: number; + uplink: number; + online: number; + }; + user_id: string; + created_at: string; + modified_at: string; + is_deleted: boolean; + node_id: string | null; }; export type CreateConnectionResponse = { - status: number; - message: string; - response: ConnectionResponse; + status: number; + message: string; + response: ConnectionResponse; }; export type ConnectionsResponseEntry = [string, ConnectionResponse]; diff --git a/src/types/stat.ts b/src/types/stat.ts index c81544f..35daa48 100644 --- a/src/types/stat.ts +++ b/src/types/stat.ts @@ -1,23 +1,23 @@ -import { ProtoTag } from "./node"; +import type { ProtoTag } from "./node"; export type Status = "Active" | "Expired"; export type UserStatRaw = [ - string, - TrafficStat, - ProtoTag, - Status, - number, - boolean, + string, + TrafficStat, + ProtoTag, + Status, + number, + boolean, ]; export interface TrafficStat { - downlink: number; - uplink: number; - online: number; + downlink: number; + uplink: number; + online: number; } export interface UserStat { - id: string; - stat: TrafficStat; - type: ProtoTag; + id: string; + stat: TrafficStat; + type: ProtoTag; } diff --git a/src/utils.ts b/src/utils.ts index 55207e1..dcb8a4b 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -1,4 +1,4 @@ -import { WireguardResponse, XrayResponse } from "./types/conn"; +import type { WireguardResponse, XrayResponse } from "./types/conn"; export function generatePassword(length = 12): string { const chars = From ac67cacb67b95a83183ab8d90fd3d24a1e98824c Mon Sep 17 00:00:00 2001 From: zapolnoch Date: Thu, 11 Sep 2025 02:45:19 +0300 Subject: [PATCH 4/7] refactor: split index file --- Dockerfile | 2 +- biome.jsonc | 5 + package.json | 6 +- src/bot.ts | 327 ++++++++++----------------- src/handlers/clash.ts | 2 +- src/handlers/start.ts | 2 +- src/handlers/sub.ts | 2 +- src/index.ts | 63 +++++- src/keyboards.ts | 14 -- src/server.ts | 26 +++ src/shared/config.ts | 16 ++ src/{utils.ts => shared/generate.ts} | 8 - src/shared/keyboards.ts | 11 + src/state.ts | 2 +- src/types/env.d.ts | 8 + 15 files changed, 248 insertions(+), 246 deletions(-) delete mode 100644 src/keyboards.ts create mode 100644 src/server.ts create mode 100644 src/shared/config.ts rename src/{utils.ts => shared/generate.ts} (76%) create mode 100644 src/shared/keyboards.ts create mode 100644 src/types/env.d.ts diff --git a/Dockerfile b/Dockerfile index b2a53b8..9152aaa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -21,4 +21,4 @@ COPY --from=builder /app/dist ./dist COPY prisma ./prisma -CMD ["node", "dist/bot.js"] +CMD ["node", "dist/index.js"] diff --git a/biome.jsonc b/biome.jsonc index e21a1a1..4afdeb5 100644 --- a/biome.jsonc +++ b/biome.jsonc @@ -4,6 +4,11 @@ "enabled": true, "indentStyle": "space" }, + "javascript": { + "formatter": { + "semicolons": "always" + } + }, "linter": { "enabled": true, "rules": { diff --git a/package.json b/package.json index 4387b1b..ef82a96 100644 --- a/package.json +++ b/package.json @@ -9,13 +9,13 @@ }, "scripts": { "postinstall": "prisma generate", - "start": "ts-node src/bot.ts", - "dev": "nodemon src/bot.ts", + "start": "ts-node src/index.ts", + "dev": "nodemon src/index.ts", "build": "tsc", "test": "npm-run-all test:*", "test:audit": "npm audit", "test:types": "tsc --noEmit --incremental false", - "test:lint": "biome lint . --diagnostic-level=error" + "test:lint": "biome check . --diagnostic-level=error" }, "devDependencies": { "@biomejs/biome": "2.2.4", diff --git a/src/bot.ts b/src/bot.ts index 444f521..e742a4e 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -1,5 +1,3 @@ -import * as dotenv from "dotenv"; -import express from "express"; import { Telegraf, TelegramError } from "telegraf"; import { awaitingMnemonic, @@ -18,38 +16,19 @@ import { } from "./handlers/feedback"; import { scoreHandler } from "./handlers/score"; import { startHandler } from "./handlers/start"; +import { + ADMIN_CHAT_ID, + API_AUTH_TOKEN, + API_BASE_URL, + BOT_TOKEN, + GOOGLE_SCRIPT_URL, + TOKEN, +} from "./shared/config"; import { connectWithMnemonic } from "./site"; import { BotState } from "./state"; -dotenv.config(); - -// Validate required environment variables -const requiredEnvVars = [ - "BOT_TOKEN", - "API_BASE_URL", - "API_AUTH_TOKEN", - "DOMAIN", -]; -const missingVars = requiredEnvVars.filter((varName) => !process.env[varName]); - -if (missingVars.length > 0) { - throw new Error( - `Missing required environment variables: ${missingVars.join(", ")}`, - ); -} - -const BOT_TOKEN = process.env.BOT_TOKEN!; -const API_BASE_URL = process.env.API_BASE_URL!; -const API_AUTH_TOKEN = process.env.API_AUTH_TOKEN!; -const DOMAIN = process.env.DOMAIN!; -const PORT = process.env.PORT || 3000; -const WEBHOOK_PATH = process.env.WEBHOOK_PATH || "/telegram/webhook"; -const GOOGLE_SCRIPT_URL = process.env.GOOGLE_SCRIPT_URL || "GOOGLE_SCRIPT_URL"; -const TOKEN = process.env.FEEDBACK_SECRET_TOKEN || "FEEDBACK_TOKEN"; -const ADMIN_CHAT_ID = process.env.ADMIN_CHAT_ID || "ADMIN_CHAT_ID"; - -const bot = new Telegraf(BOT_TOKEN); -const botState = new BotState( +export const bot = new Telegraf(BOT_TOKEN); +export const botState = new BotState( API_BASE_URL, API_AUTH_TOKEN, GOOGLE_SCRIPT_URL, @@ -57,205 +36,127 @@ const botState = new BotState( ADMIN_CHAT_ID, ); -const app = express(); - -// Middleware setup in correct order -app.use(express.json()); - -// Logging middleware -app.use((req, res, next) => { - console.log(`[${new Date().toISOString()}] ${req.method} ${req.url}`); - next(); -}); - -// Health check endpoint -app.get("/health", (req, res) => { - res.json({ - status: "OK", - timestamp: new Date().toISOString(), - uptime: process.uptime(), - }); -}); - -// Webhook logging -app.post(WEBHOOK_PATH, (req, res, next) => { - console.log(`[WEBHOOK] Received update:`, JSON.stringify(req.body, null, 2)); - next(); -}); - -// Bot webhook handler -app.use(bot.webhookCallback(WEBHOOK_PATH)); - -// Global bot error handler -bot.catch(async (err, ctx) => { - console.error(`[BOT ERROR] User ${ctx.from?.id}:`, err); - try { - await ctx.reply("Произошла ошибка. Попробуйте позже."); - } catch (e) { - console.error("Failed to send error message:", e); - } -}); - -// Graceful shutdown handlers -const gracefulShutdown = async (signal: string) => { - console.log(`[SHUTDOWN] Received ${signal}, shutting down gracefully...`); - try { - await bot.telegram.deleteWebhook(); - console.log("[SHUTDOWN] Webhook deleted successfully"); - } catch (err) { - console.error("[SHUTDOWN] Error deleting webhook:", err); +// Command handlers +bot.command("start", (ctx) => startHandler(ctx, botState)); +bot.command("connect", (ctx) => subPlainHandler(ctx, botState)); +bot.command("clash", (ctx) => subClashHandler(ctx, botState)); +bot.command("stat", (ctx) => statHandler(ctx, botState)); +bot.command("site", (ctx) => siteHandler(ctx, botState)); +bot.command("delete", (ctx) => deleteHandler(ctx, botState)); +bot.command("stop", (ctx) => deleteHandler(ctx, botState)); +bot.command("status", (ctx) => scoreHandler(ctx, botState)); +bot.command("feedback", (ctx) => feedbackHandler(ctx, botState)); +bot.command("support", (ctx) => feedbackHandler(ctx, botState)); // Alias for feedback + +// Text message handler +bot.on("text", async (ctx) => { + const userId = ctx.from.id; + const message = ctx.message.text; + + // Handle feedback messages first + const handledByFeedback = await handleFeedbackMessage(ctx, botState); + if (handledByFeedback) { + return; } - process.exit(0); -}; - -process.on("SIGINT", () => gracefulShutdown("SIGINT")); -process.on("SIGTERM", () => gracefulShutdown("SIGTERM")); -(async () => { - // Command handlers - bot.command("start", (ctx) => startHandler(ctx, botState)); - bot.command("connect", (ctx) => subPlainHandler(ctx, botState)); - bot.command("clash", (ctx) => subClashHandler(ctx, botState)); - bot.command("stat", (ctx) => statHandler(ctx, botState)); - bot.command("site", (ctx) => siteHandler(ctx, botState)); - bot.command("delete", (ctx) => deleteHandler(ctx, botState)); - bot.command("stop", (ctx) => deleteHandler(ctx, botState)); - bot.command("status", (ctx) => scoreHandler(ctx, botState)); - bot.command("feedback", (ctx) => feedbackHandler(ctx, botState)); - bot.command("support", (ctx) => feedbackHandler(ctx, botState)); // Alias for feedback - - // Text message handler - bot.on("text", async (ctx) => { - const userId = ctx.from.id; - const message = ctx.message.text; - - // Handle feedback messages first - const handledByFeedback = await handleFeedbackMessage(ctx, botState); - if (handledByFeedback) { - return; - } + // Handle site command + if (awaitingMnemonic[userId]) { + awaitingMnemonic[userId] = false; // reset - // Handle site command - if (awaitingMnemonic[userId]) { - awaitingMnemonic[userId] = false; // reset - - const words = message.trim().split(/\s+/); - if (words.length !== 12) { - return ctx.reply( - "Фраза должна содержать 12 слов. Попробуйте ещё раз командой /site", - ); - } - - try { - const data = await connectWithMnemonic(message.trim()); - if (typeof data === "string") { - await ctx.reply(data); - } else { - await ctx.reply( - `Ваша ссылка: ${data.subscription_url}`, - { parse_mode: "HTML" }, - ); - } - } catch (err) { - console.error("Ошибка в siteHandler:", err); - await ctx.reply("Ошибка при обработке фразы."); - } finally { - // biome-ignore lint/correctness/noUnsafeFinally: TODO - return; - } - } - - // Handle unknown commands - if (message.startsWith("/")) { - await ctx.reply( - "Неизвестная команда 🫣\n\nДоступные команды:\n" + - "• /start - Начать работу\n" + - "• /connect - Получить VPN ссылку\n" + - "• /clash - Получить VPN Clash ссылку\n" + - "• /status - Проверить статус\n" + - "• /stat - Статистика\n" + - "• /site - Если оплачивали подписку на сайте\n" + - "• /support - Поддержка и обратная связь\n" + - "• /delete - Удалить аккаунт", + const words = message.trim().split(/\s+/); + if (words.length !== 12) { + return ctx.reply( + "Фраза должна содержать 12 слов. Попробуйте ещё раз командой /site", ); } - }); - // Callback query handler - // biome-ignore lint/complexity/noExcessiveCognitiveComplexity: TODO - bot.on("callback_query", async (ctx) => { try { - const callbackQuery = ctx.callbackQuery; - - // Answer callback query to remove loading state - try { - await ctx.answerCbQuery(); - } catch (err) { - // Ignore common callback query errors - if ( - err instanceof TelegramError && - !err?.description?.includes("query is too old") && - !err?.description?.includes("query ID is invalid") - ) { - console.error("[CALLBACK] answerCbQuery error:", err); - } + const data = await connectWithMnemonic(message.trim()); + if (typeof data === "string") { + await ctx.reply(data); + } else { + await ctx.reply(`Ваша ссылка: ${data.subscription_url}`, { + parse_mode: "HTML", + }); } + } catch (err) { + console.error("Ошибка в siteHandler:", err); + await ctx.reply("Ошибка при обработке фразы."); + } finally { + // biome-ignore lint/correctness/noUnsafeFinally: TODO + return; + } + } - if (!callbackQuery || !("data" in callbackQuery)) return; - - const data = callbackQuery.data; - if (!data) return; + // Handle unknown commands + if (message.startsWith("/")) { + await ctx.reply( + "Неизвестная команда 🫣\n\nДоступные команды:\n" + + "• /start - Начать работу\n" + + "• /connect - Получить VPN ссылку\n" + + "• /clash - Получить VPN Clash ссылку\n" + + "• /status - Проверить статус\n" + + "• /stat - Статистика\n" + + "• /site - Если оплачивали подписку на сайте\n" + + "• /support - Поддержка и обратная связь\n" + + "• /delete - Удалить аккаунт", + ); + } +}); - console.log(`[CALLBACK] User ${ctx.from?.id} pressed: ${data}`); +// Callback query handler +bot.on("callback_query", async (ctx) => { + try { + const callbackQuery = ctx.callbackQuery; - // Route callback data to appropriate handlers - if (data.startsWith("feedback_")) { - await handleFeedbackCallback(ctx, botState); - } else if (data.startsWith("plain")) { - await handleSubscriptionCallback(ctx, botState); - } else if (data.startsWith("clash")) { - await handleSubscriptionClashCallback(ctx, botState); - } else { - console.log(`[CALLBACK] Unknown callback data: ${data}`); - await ctx.reply("Неизвестная команда."); - } + // Answer callback query to remove loading state + try { + await ctx.answerCbQuery(); } catch (err) { - console.error("[CALLBACK] Callback query error:", err); - try { - await ctx.answerCbQuery("Произошла ошибка, попробуйте снова"); - } catch (answerErr) { - console.error("[CALLBACK] Failed to answer callback query:", answerErr); + // Ignore common callback query errors + if ( + err instanceof TelegramError && + !err?.description?.includes("query is too old") && + !err?.description?.includes("query ID is invalid") + ) { + console.error("[CALLBACK] answerCbQuery error:", err); } } - }); - // Start server and set webhook - const server = app.listen(PORT, async () => { - console.log(`[SERVER] Listening on port ${PORT}`); + if (!callbackQuery || !("data" in callbackQuery)) return; + + const data = callbackQuery.data; + if (!data) return; + + console.log(`[CALLBACK] User ${ctx.from?.id} pressed: ${data}`); + // Route callback data to appropriate handlers + if (data.startsWith("feedback_")) { + await handleFeedbackCallback(ctx, botState); + } else if (data.startsWith("plain")) { + await handleSubscriptionCallback(ctx, botState); + } else if (data.startsWith("clash")) { + await handleSubscriptionClashCallback(ctx, botState); + } else { + console.log(`[CALLBACK] Unknown callback data: ${data}`); + await ctx.reply("Неизвестная команда."); + } + } catch (err) { + console.error("[CALLBACK] Callback query error:", err); try { - await bot.telegram.setWebhook(`${DOMAIN}${WEBHOOK_PATH}`); - console.log(`[WEBHOOK] Set webhook: ${DOMAIN}${WEBHOOK_PATH}`); - } catch (err) { - console.error("[WEBHOOK] Error setting webhook:", err); - process.exit(1); + await ctx.answerCbQuery("Произошла ошибка, попробуйте снова"); + } catch (answerErr) { + console.error("[CALLBACK] Failed to answer callback query:", answerErr); } - }); - - // Handle server errors - server.on("error", (err) => { - console.error("[SERVER] Server error:", err); - process.exit(1); - }); + } +}); - console.log( - `[STARTUP] Bot started successfully\n` + - ` Domain: ${DOMAIN}\n` + - ` Port: ${PORT}\n` + - ` Webhook path: ${WEBHOOK_PATH}\n` + - ` Environment: ${process.env.NODE_ENV || "development"}`, - ); -})().catch((err) => { - console.error("[STARTUP] Fatal error during startup:", err); - process.exit(1); +// Global bot error handler +bot.catch(async (err, ctx) => { + console.error(`[BOT ERROR] User ${ctx.from?.id}:`, err); + try { + await ctx.reply("Произошла ошибка. Попробуйте позже."); + } catch (e) { + console.error("Failed to send error message:", e); + } }); diff --git a/src/handlers/clash.ts b/src/handlers/clash.ts index b21a02d..0f07527 100644 --- a/src/handlers/clash.ts +++ b/src/handlers/clash.ts @@ -1,6 +1,6 @@ import type { Context } from "telegraf"; import type { InlineKeyboardMarkup } from "telegraf/types"; -import { buildSubClashKeyboard } from "../keyboards"; +import { buildSubClashKeyboard } from "../shared/keyboards"; import type { BotState } from "../state"; export const subClashHandler = async (ctx: Context, botState: BotState) => { diff --git a/src/handlers/start.ts b/src/handlers/start.ts index edadf08..c63d393 100644 --- a/src/handlers/start.ts +++ b/src/handlers/start.ts @@ -1,6 +1,6 @@ import type { Context } from "telegraf"; +import { generateUsername } from "../shared/generate"; import type { BotState } from "../state"; -import { generateUsername } from "../utils"; export const startHandler = async (ctx: Context, botState: BotState) => { const user = ctx.from; diff --git a/src/handlers/sub.ts b/src/handlers/sub.ts index 6348039..a4341de 100644 --- a/src/handlers/sub.ts +++ b/src/handlers/sub.ts @@ -1,6 +1,6 @@ import type { Context } from "telegraf"; import type { InlineKeyboardMarkup } from "telegraf/types"; -import { buildSubPlainKeyboard } from "../keyboards"; +import { buildSubPlainKeyboard } from "../shared/keyboards"; import type { BotState } from "../state"; export const subPlainHandler = async (ctx: Context, botState: BotState) => { diff --git a/src/index.ts b/src/index.ts index fb6a0ee..8c7cf38 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,3 +1,60 @@ -export * from "./handlers"; -export * from "./state"; -export * from "./types"; +import { bot } from "./bot"; +import { app } from "./server"; +import { DOMAIN, PORT, WEBHOOK_PATH } from "./shared/config"; + +// #region Environment variables +const missingVars = [ + "BOT_TOKEN", + "API_BASE_URL", + "API_AUTH_TOKEN", + "DOMAIN", +].filter((varName) => !process.env[varName]); + +if (missingVars.length > 0) { + throw new Error( + `Missing required environment variables: ${missingVars.join(", ")}`, + ); +} +// #endregion + +app.use(bot.webhookCallback(WEBHOOK_PATH)); +app + .listen(PORT, async () => { + console.log(`[SERVER] Listening on port ${PORT}`); + + try { + await bot.telegram.setWebhook(`${DOMAIN}${WEBHOOK_PATH}`); + console.log(`[WEBHOOK] Set webhook: ${DOMAIN}${WEBHOOK_PATH}`); + } catch (err) { + console.error("[WEBHOOK] Error setting webhook:", err); + process.exit(1); + } + }) + .on("error", (err) => { + console.error("[SERVER] Server error:", err); + process.exit(1); + }); + +console.log( + `[STARTUP] Bot started successfully\n` + + ` Domain: ${DOMAIN}\n` + + ` Port: ${PORT}\n` + + ` Webhook path: ${WEBHOOK_PATH}\n` + + ` Environment: ${process.env.NODE_ENV || "development"}`, +); + +// #region Graceful shutdown handlers +const gracefulShutdown = async (signal: string) => { + console.log(`[SHUTDOWN] Received ${signal}, shutting down gracefully...`); + try { + await bot.telegram.deleteWebhook(); + console.log("[SHUTDOWN] Webhook deleted successfully"); + } catch (err) { + console.error("[SHUTDOWN] Error deleting webhook:", err); + } + process.exit(0); +}; + +process.on("SIGINT", () => gracefulShutdown("SIGINT")); +process.on("SIGTERM", () => gracefulShutdown("SIGTERM")); +// #endregion diff --git a/src/keyboards.ts b/src/keyboards.ts deleted file mode 100644 index 6496ee5..0000000 --- a/src/keyboards.ts +++ /dev/null @@ -1,14 +0,0 @@ -import { InlineKeyboardButton } from "telegraf/typings/core/types/typegram"; -import { ConnectionResponse } from "./types/conn"; - -export async function buildSubPlainKeyboard(): Promise { - return { - inline_keyboard: [[{ text: "Plain", callback_data: "plain" }]], - }; -} - -export async function buildSubClashKeyboard(): Promise { - return { - inline_keyboard: [[{ text: "Clash", callback_data: "clash" }]], - }; -} diff --git a/src/server.ts b/src/server.ts new file mode 100644 index 0000000..1595c1c --- /dev/null +++ b/src/server.ts @@ -0,0 +1,26 @@ +import express from "express"; +import { WEBHOOK_PATH } from "./shared/config"; + +export const app = express(); +app.use(express.json()); + +// Logging middleware +app.use((req, _res, next) => { + console.log(`[${new Date().toISOString()}] ${req.method} ${req.url}`); + next(); +}); + +// Health check endpoint +app.get("/health", (_req, res) => { + res.json({ + status: "OK", + timestamp: new Date().toISOString(), + uptime: process.uptime(), + }); +}); + +// Webhook logging +app.post(WEBHOOK_PATH, (req, _res, next) => { + console.log(`[WEBHOOK] Received update:`, JSON.stringify(req.body, null, 2)); + next(); +}); diff --git a/src/shared/config.ts b/src/shared/config.ts new file mode 100644 index 0000000..de37534 --- /dev/null +++ b/src/shared/config.ts @@ -0,0 +1,16 @@ +import * as dotenv from "dotenv"; + +dotenv.config(); + +export const BOT_TOKEN = process.env.BOT_TOKEN!; +export const API_BASE_URL = process.env.API_BASE_URL!; +export const API_AUTH_TOKEN = process.env.API_AUTH_TOKEN!; +export const DOMAIN = process.env.DOMAIN!; +export const PORT = process.env.PORT || 3000; +export const WEBHOOK_PATH = process.env.WEBHOOK_PATH || "/telegram/webhook"; + +export const GOOGLE_SCRIPT_URL = + process.env.GOOGLE_SCRIPT_URL || "GOOGLE_SCRIPT_URL"; + +export const TOKEN = process.env.FEEDBACK_SECRET_TOKEN || "FEEDBACK_TOKEN"; +export const ADMIN_CHAT_ID = process.env.ADMIN_CHAT_ID || "ADMIN_CHAT_ID"; diff --git a/src/utils.ts b/src/shared/generate.ts similarity index 76% rename from src/utils.ts rename to src/shared/generate.ts index dcb8a4b..fae077b 100644 --- a/src/utils.ts +++ b/src/shared/generate.ts @@ -1,5 +1,3 @@ -import type { WireguardResponse, XrayResponse } from "./types/conn"; - export function generatePassword(length = 12): string { const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*()_+{}:\"<>?|[];',./`~"; @@ -11,12 +9,6 @@ export function generatePassword(length = 12): string { return password; } -export function isXrayResponse( - proto: WireguardResponse | XrayResponse, -): proto is XrayResponse { - return (proto as XrayResponse).Xray !== undefined; -} - export function generateUsername(totalLength = 25): string { const chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; diff --git a/src/shared/keyboards.ts b/src/shared/keyboards.ts new file mode 100644 index 0000000..b4a34a0 --- /dev/null +++ b/src/shared/keyboards.ts @@ -0,0 +1,11 @@ +export async function buildSubPlainKeyboard() { + return { + inline_keyboard: [[{ text: "Plain", callback_data: "plain" }]], + }; +} + +export async function buildSubClashKeyboard() { + return { + inline_keyboard: [[{ text: "Clash", callback_data: "clash" }]], + }; +} diff --git a/src/state.ts b/src/state.ts index b662fd7..ce70b3c 100644 --- a/src/state.ts +++ b/src/state.ts @@ -1,5 +1,6 @@ import { PrismaClient, type User as PrismaUser } from "@prisma/client"; import axios from "axios"; +import { generatePassword } from "./shared/generate"; import type { RegisterResult, User } from "./types"; import type { ConnectionResponse, @@ -9,7 +10,6 @@ import type { } from "./types/conn"; import type { NodeResponse, NodeScore } from "./types/node"; import type { UserStat, UserStatRaw } from "./types/stat"; -import { generatePassword } from "./utils"; export class BotState { private prisma: PrismaClient; diff --git a/src/types/env.d.ts b/src/types/env.d.ts new file mode 100644 index 0000000..4624edc --- /dev/null +++ b/src/types/env.d.ts @@ -0,0 +1,8 @@ +declare namespace NodeJS { + interface ProcessEnv { + BOT_TOKEN: string; + API_BASE_URL: string; + API_AUTH_TOKEN: string; + DOMAIN: string; + } +} From f5cbcbd4bc99ddcd9a460d25b2519528293ca0de Mon Sep 17 00:00:00 2001 From: zapolnoch Date: Mon, 22 Sep 2025 07:44:55 +0300 Subject: [PATCH 5/7] refactor: unused packages --- package-lock.json | 34 ---------------------------------- package.json | 3 --- 2 files changed, 37 deletions(-) diff --git a/package-lock.json b/package-lock.json index 235caab..1433bf2 100644 --- a/package-lock.json +++ b/package-lock.json @@ -10,12 +10,10 @@ "hasInstallScript": true, "dependencies": { "@prisma/client": "6.13.0", - "async-mutex": "0.5.0", "axios": "1.10.0", "dotenv": "16.5.0", "express": "5.1.0", "js-sha3": "0.9.3", - "qr-image": "3.2.0", "qrcode": "1.5.4", "telegraf": "4.16.3", "typescript": "5.8.3" @@ -23,7 +21,6 @@ "devDependencies": { "@biomejs/biome": "2.2.4", "@types/express": "5.0.3", - "@types/qr-image": "3.2.9", "@types/qrcode": "1.5.5", "nodemon": "3.1.10", "npm-run-all": "4.1.5", @@ -466,16 +463,6 @@ "devOptional": true, "license": "MIT" }, - "node_modules/@types/qr-image": { - "version": "3.2.9", - "resolved": "https://registry.npmjs.org/@types/qr-image/-/qr-image-3.2.9.tgz", - "integrity": "sha512-vmqTI+ehoC07jtzjT9Dc+3eMpXTgdluD9orVHtp9bN1gE81SnOuMe9+EwmRuWfTH04YNyk1mihI/Vr7BIhUCZg==", - "dev": true, - "license": "MIT", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/qrcode": { "version": "1.5.5", "resolved": "https://registry.npmjs.org/@types/qrcode/-/qrcode-1.5.5.tgz", @@ -689,15 +676,6 @@ "node": ">= 0.4" } }, - "node_modules/async-mutex": { - "version": "0.5.0", - "resolved": "https://registry.npmjs.org/async-mutex/-/async-mutex-0.5.0.tgz", - "integrity": "sha512-1A94B18jkJ3DYq284ohPxoXbfTA5HsQ7/Mf4DEhcyLx3Bz27Rh59iScbB6EPiP+B+joue6YCxcMXSbFC1tZKwA==", - "license": "MIT", - "dependencies": { - "tslib": "^2.4.0" - } - }, "node_modules/asynckit": { "version": "0.4.0", "resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz", @@ -3375,12 +3353,6 @@ ], "license": "MIT" }, - "node_modules/qr-image": { - "version": "3.2.0", - "resolved": "https://registry.npmjs.org/qr-image/-/qr-image-3.2.0.tgz", - "integrity": "sha512-rXKDS5Sx3YipVsqmlMJsJsk6jXylEpiHRC2+nJy66fxA5ExYyGa4PqwteW69SaVmAb2OQ18HbYriT7cGQMbduw==", - "license": "MIT" - }, "node_modules/qrcode": { "version": "1.5.4", "resolved": "https://registry.npmjs.org/qrcode/-/qrcode-1.5.4.tgz", @@ -4257,12 +4229,6 @@ } } }, - "node_modules/tslib": { - "version": "2.8.1", - "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.8.1.tgz", - "integrity": "sha512-oJFu94HQb+KVduSUQL7wnpmqnfmLsOA/nAh6b6EH0wCEoK0/mPeXU6c3wKDV83MkOuHPRHtSXKKU99IBazS/2w==", - "license": "0BSD" - }, "node_modules/type-fest": { "version": "4.41.0", "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-4.41.0.tgz", diff --git a/package.json b/package.json index ef82a96..664a408 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,6 @@ "devDependencies": { "@biomejs/biome": "2.2.4", "@types/express": "5.0.3", - "@types/qr-image": "3.2.9", "@types/qrcode": "1.5.5", "nodemon": "3.1.10", "npm-run-all": "4.1.5", @@ -29,12 +28,10 @@ }, "dependencies": { "@prisma/client": "6.13.0", - "async-mutex": "0.5.0", "axios": "1.10.0", "dotenv": "16.5.0", "express": "5.1.0", "js-sha3": "0.9.3", - "qr-image": "3.2.0", "qrcode": "1.5.4", "telegraf": "4.16.3", "typescript": "5.8.3" From 5171117b033246a057a3358ae4d93ed7558ad7b6 Mon Sep 17 00:00:00 2001 From: zapolnoch Date: Mon, 22 Sep 2025 07:58:40 +0300 Subject: [PATCH 6/7] feat: menu settings --- src/bot.ts | 9 +++++++++ src/index.ts | 15 --------------- src/shared/config.ts | 13 +++++++++++++ 3 files changed, 22 insertions(+), 15 deletions(-) diff --git a/src/bot.ts b/src/bot.ts index e742a4e..1a11f45 100644 --- a/src/bot.ts +++ b/src/bot.ts @@ -48,6 +48,15 @@ bot.command("status", (ctx) => scoreHandler(ctx, botState)); bot.command("feedback", (ctx) => feedbackHandler(ctx, botState)); bot.command("support", (ctx) => feedbackHandler(ctx, botState)); // Alias for feedback +// Menu +bot.telegram.setMyCommands([ + { command: "start", description: "Начать работу" }, + { command: "connect", description: "Получить VPN ссылку" }, + { command: "clash", description: "Получить VPN Clash ссылку" }, + { command: "stat", description: "Статистика" }, + { command: "site", description: "Если оплачивали подписку на сайте" }, +]); + // Text message handler bot.on("text", async (ctx) => { const userId = ctx.from.id; diff --git a/src/index.ts b/src/index.ts index 8c7cf38..b878244 100644 --- a/src/index.ts +++ b/src/index.ts @@ -2,21 +2,6 @@ import { bot } from "./bot"; import { app } from "./server"; import { DOMAIN, PORT, WEBHOOK_PATH } from "./shared/config"; -// #region Environment variables -const missingVars = [ - "BOT_TOKEN", - "API_BASE_URL", - "API_AUTH_TOKEN", - "DOMAIN", -].filter((varName) => !process.env[varName]); - -if (missingVars.length > 0) { - throw new Error( - `Missing required environment variables: ${missingVars.join(", ")}`, - ); -} -// #endregion - app.use(bot.webhookCallback(WEBHOOK_PATH)); app .listen(PORT, async () => { diff --git a/src/shared/config.ts b/src/shared/config.ts index de37534..28daf21 100644 --- a/src/shared/config.ts +++ b/src/shared/config.ts @@ -2,6 +2,19 @@ import * as dotenv from "dotenv"; dotenv.config(); +const missingVars = [ + "BOT_TOKEN", + "API_BASE_URL", + "API_AUTH_TOKEN", + "DOMAIN", +].filter((varName) => !process.env[varName]); + +if (missingVars.length > 0) { + throw new Error( + `Missing required environment variables: ${missingVars.join(", ")}`, + ); +} + export const BOT_TOKEN = process.env.BOT_TOKEN!; export const API_BASE_URL = process.env.API_BASE_URL!; export const API_AUTH_TOKEN = process.env.API_AUTH_TOKEN!; From 2d809ab6f58de1dabab95eddc932acbc42671c53 Mon Sep 17 00:00:00 2001 From: zapolnoch Date: Mon, 22 Sep 2025 08:11:29 +0300 Subject: [PATCH 7/7] merge main --- src/handlers/delete.ts | 17 +++++++++++++++-- src/handlers/start.ts | 15 ++++++++++++++- src/state.ts | 18 ++++++++++++++++++ 3 files changed, 47 insertions(+), 3 deletions(-) diff --git a/src/handlers/delete.ts b/src/handlers/delete.ts index a143de4..a0d3a2c 100644 --- a/src/handlers/delete.ts +++ b/src/handlers/delete.ts @@ -10,12 +10,25 @@ export const deleteHandler = async (ctx: Context, botState: BotState) => { const reply1 = "Удачи"; - const welcome_msg = reply1; - if (user.username) { const userEntry = await botState.findUserByTelegramId(user.id); + if (userEntry) { + const connections = await botState.getUserConnections(userEntry.id); + + for (const conn of connections) { + const status = await botState.deleteConnection(conn.id); + if (status) { + console.log("Connection deleted: ", conn.id); + } else { + console.log("Connection Not Deleted: ", conn.id); + } + } + await botState.deleteUser(userEntry.id); + console.log("User marked as deleted: ", userEntry.id); + + await ctx.reply(reply1); } } }; diff --git a/src/handlers/start.ts b/src/handlers/start.ts index c63d393..f62695a 100644 --- a/src/handlers/start.ts +++ b/src/handlers/start.ts @@ -68,7 +68,20 @@ export const startHandler = async (ctx: Context, botState: BotState) => { if (userEntry?.is_deleted) { await botState.undeleteUser(userEntry.id); - await ctx.telegram.sendMessage(ctx.chat.id, welcome_msg, { + const conn = await botState.createConnection({ + env: botState.getEnv(), + proto: "VlessXtls", + user_id: userEntry.id, + }); + + if (conn) { + console.log( + `ReCreated connection ${conn.response} for user ${userEntry.id}`, + ); + } + const welcome_back_msg = welcome_msg + "\nДобро пожаловать снова!"; + + await ctx.telegram.sendMessage(ctx.chat.id, welcome_back_msg, { parse_mode: "MarkdownV2", ...({ disable_web_page_preview: true } as any), }); diff --git a/src/state.ts b/src/state.ts index ce70b3c..4ec4fee 100644 --- a/src/state.ts +++ b/src/state.ts @@ -324,6 +324,24 @@ export class BotState { } } + async deleteConnection(id: string): Promise { + try { + const res = await this.api.delete<{ status: number; message?: string }>( + `/connection?id=${id}`, + ); + + if (res.data.status === 200) { + return true; + } else { + console.warn("Failed to delete connection:", res.data.message); + return false; + } + } catch (e) { + console.error("Error deleting connection:", e); + return false; + } + } + async close(): Promise { await this.prisma.$disconnect(); }