[
  {
    "path": ".eslintrc.json",
    "content": "{\n  \"extends\": \"next/core-web-vitals\"\n}\n"
  },
  {
    "path": ".gitignore",
    "content": "# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n/.pnp\n.pnp.js\n\n# testing\n/coverage\n\n# next.js\n/.next/\n/out/\n\n# production\n/build\n\n# misc\n.DS_Store\n*.pem\n\n# debug\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n.pnpm-debug.log*\n\n# local env files\n.env*.local\n.env\n\n# vercel\n.vercel\n\n# typescript\n*.tsbuildinfo\nnext-env.d.ts\n"
  },
  {
    "path": ".vscode/settings.json",
    "content": "{\n  \"typescript.tsdk\": \"node_modules/typescript/lib\",\n  \"typescript.enablePromptUseWorkspaceTsdk\": true\n}"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU AFFERO GENERAL PUBLIC LICENSE\n                       Version 3, 19 November 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU Affero General Public License is a free, copyleft license for\nsoftware and other kinds of works, specifically designed to ensure\ncooperation with the community in the case of network server software.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nour General Public Licenses are intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  Developers that use our General Public Licenses protect your rights\nwith two steps: (1) assert copyright on the software, and (2) offer\nyou this License which gives you legal permission to copy, distribute\nand/or modify the software.\n\n  A secondary benefit of defending all users' freedom is that\nimprovements made in alternate versions of the program, if they\nreceive widespread use, become available for other developers to\nincorporate.  Many developers of free software are heartened and\nencouraged by the resulting cooperation.  However, in the case of\nsoftware used on network servers, this result may fail to come about.\nThe GNU General Public License permits making a modified version and\nletting the public access it on a server without ever releasing its\nsource code to the public.\n\n  The GNU Affero General Public License is designed specifically to\nensure that, in such cases, the modified source code becomes available\nto the community.  It requires the operator of a network server to\nprovide the source code of the modified version running there to the\nusers of that server.  Therefore, public use of a modified version, on\na publicly accessible server, gives the public access to the source\ncode of the modified version.\n\n  An older license, called the Affero General Public License and\npublished by Affero, was designed to accomplish similar goals.  This is\na different license, not a version of the Affero GPL, but Affero has\nreleased a new version of the Affero GPL which permits relicensing under\nthis license.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU Affero General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Remote Network Interaction; Use with the GNU General Public License.\n\n  Notwithstanding any other provision of this License, if you modify the\nProgram, your modified version must prominently offer all users\ninteracting with it remotely through a computer network (if your version\nsupports such interaction) an opportunity to receive the Corresponding\nSource of your version by providing access to the Corresponding Source\nfrom a network server at no charge, through some standard or customary\nmeans of facilitating copying of software.  This Corresponding Source\nshall include the Corresponding Source for any work covered by version 3\nof the GNU General Public License that is incorporated pursuant to the\nfollowing paragraph.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the work with which it is combined will remain governed by version\n3 of the GNU General Public License.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU Affero General Public License from time to time.  Such new versions\nwill be similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU Affero General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU Affero General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU Affero General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU Affero General Public License as published\n    by the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU Affero General Public License for more details.\n\n    You should have received a copy of the GNU Affero General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If your software can interact with users remotely through a computer\nnetwork, you should also make sure that it provides a way for users to\nget its source.  For example, if your program is a web application, its\ninterface could display a \"Source\" link that leads users to an archive\nof the code.  There are many ways you could offer source, and different\nsolutions will be better for different programs; see section 13 for the\nspecific requirements.\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU AGPL, see\n<https://www.gnu.org/licenses/>.\n"
  },
  {
    "path": "README.md",
    "content": "This is an app built to showcase the capabilities of [Next.js 14](https://nextjs.org/docs).\n\nLive demo is up at [nextjs14-showcase.vercel.app](https://nextjs14-showcase.vercel.app)\n\n> **Warning**\n> This app is a work in progress. Site may be unstable.\n> \nHome Page (Desktop)         |  Social Media Feed (Mobile)\n:-------------------------:|:-------------------------:\n<img alt=\"Screenshot 2024-05-22 at 10 10 41 PM\" src=\"https://github.com/yaseenmustapha/nextjs14-app/assets/26501999/5e418f1a-d0a4-4aed-8d00-a873f7d4f73b\"> |  ![IMG_0675](https://github.com/yaseenmustapha/nextjs14-app/assets/26501999/8fdb90fb-ceb8-40f5-9730-ac154edbb7d1)\n\n## Features\n\n- Using new **Next.js 14**\n- New `/app` dir,\n- Routing, Layouts, Nested Layouts and Layout Groups\n- Data Fetching, Caching and Mutation\n- Uses client and server components from **React 18**\n- API Routes\n- Live social media feed with likes, comments, and profanity filter\n- Enhance social media posts using **OpenAI API** with **GPT-3.5-Turbo** model\n- OAuth 2.0 Authentication through Google, GitHub, and Discord using **NextAuth.js**\n- ORM using **Prisma**\n- PostgreSQL Database on **Supabase**\n- UI Components built using **NextUI v2.0**\n- Styled using **Tailwind CSS**\n- Dark mode using **next-themes**\n- Payments using **Stripe**\n- Written in **TypeScript**\n\n## Run locally\n1. Install dependencies\n\n```bash\nnpm install\n```\n2. Copy `.env.example` to `.env.local` and update variables:\n\n```bash\ncp .env.example .env.local\n```\n\n3. Run the development server:\n\n```bash\nnpm run dev\n```\n\nOpen [http://localhost:3000](http://localhost:3000) with your browser to see the result.\n\n## Database setup\n\n1. Setup a PostgreSQL database. I recommend using [Supabase](https://supabase.com) as they have a great free tier and is easy to setup.\n\n2. Put your database URL in the `.env.local` file under the `DATABASE_URL` key.\n\n3. Run the Prisma migrate script to initialize the schema:\n\n```bash\nnpm run migrate:dev\n```\n## License\n\nLicensed under the [GNU Affero General Public License v3.0](https://github.com/yaseenmustapha/nextjs14-app/blob/main/LICENSE).\n"
  },
  {
    "path": "app/(home)/HomePage.tsx",
    "content": "\"use client\";\nimport {\n  Button,\n  Card,\n  CardBody,\n  CardFooter,\n  CardHeader,\n  Link,\n  Spacer,\n  User,\n} from \"@nextui-org/react\";\nimport { useSession } from \"next-auth/react\";\nimport { useTheme } from \"next-themes\";\n\nexport default function HomePage({ numStars }: { numStars: string }) {\n  const { theme, setTheme } = useTheme();\n  const { data: session } = useSession();\n  const { user } = session || {};\n\n  const cardItems = [\n    {\n      title: \"Next.js 14\",\n      description: \"App directory, routing, layouts, and API routes.\",\n      footer: \"Next.js 14 documentation\",\n      url: \"https://beta.nextjs.org/docs\",\n      svg: (\n        <svg viewBox=\"0 0 24 24\" style={{ height: 32 }}>\n          <path\n            d=\"M11.572 0c-.176 0-.31.001-.358.007a19.76 19.76 0 0 1-.364.033C7.443.346 4.25 2.185 2.228 5.012a11.875 11.875 0 0 0-2.119 5.243c-.096.659-.108.854-.108 1.747s.012 1.089.108 1.748c.652 4.506 3.86 8.292 8.209 9.695.779.25 1.6.422 2.534.525.363.04 1.935.04 2.299 0 1.611-.178 2.977-.577 4.323-1.264.207-.106.247-.134.219-.158-.02-.013-.9-1.193-1.955-2.62l-1.919-2.592-2.404-3.558a338.739 338.739 0 0 0-2.422-3.556c-.009-.002-.018 1.579-.023 3.51-.007 3.38-.01 3.515-.052 3.595a.426.426 0 0 1-.206.214c-.075.037-.14.044-.495.044H7.81l-.108-.068a.438.438 0 0 1-.157-.171l-.05-.106.006-4.703.007-4.705.072-.092a.645.645 0 0 1 .174-.143c.096-.047.134-.051.54-.051.478 0 .558.018.682.154.035.038 1.337 1.999 2.895 4.361a10760.433 10760.433 0 0 0 4.735 7.17l1.9 2.879.096-.063a12.317 12.317 0 0 0 2.466-2.163 11.944 11.944 0 0 0 2.824-6.134c.096-.66.108-.854.108-1.748 0-.893-.012-1.088-.108-1.747-.652-4.506-3.859-8.292-8.208-9.695a12.597 12.597 0 0 0-2.499-.523A33.119 33.119 0 0 0 11.573 0zm4.069 7.217c.347 0 .408.005.486.047a.473.473 0 0 1 .237.277c.018.06.023 1.365.018 4.304l-.006 4.218-.744-1.14-.746-1.14v-3.066c0-1.982.01-3.097.023-3.15a.478.478 0 0 1 .233-.296c.096-.05.13-.054.5-.054z\"\n            fill={theme === \"dark\" ? \"#FFFFFF\" : \"#100F13\"}\n          />\n        </svg>\n      ),\n    },\n    {\n      title: \"React 18\",\n      description: \"Server and client components.\",\n      footer: \"React 18 documentation\",\n      url: \"https://react.dev/learn\",\n      svg: (\n        <svg viewBox=\"0 0 24 24\" style={{ height: 32 }}>\n          <path\n            d=\"M14.23 12.004a2.236 2.236 0 0 1-2.235 2.236 2.236 2.236 0 0 1-2.236-2.236 2.236 2.236 0 0 1 2.235-2.236 2.236 2.236 0 0 1 2.236 2.236zm2.648-10.69c-1.346 0-3.107.96-4.888 2.622-1.78-1.653-3.542-2.602-4.887-2.602-.41 0-.783.093-1.106.278-1.375.793-1.683 3.264-.973 6.365C1.98 8.917 0 10.42 0 12.004c0 1.59 1.99 3.097 5.043 4.03-.704 3.113-.39 5.588.988 6.38.32.187.69.275 1.102.275 1.345 0 3.107-.96 4.888-2.624 1.78 1.654 3.542 2.603 4.887 2.603.41 0 .783-.09 1.106-.275 1.374-.792 1.683-3.263.973-6.365C22.02 15.096 24 13.59 24 12.004c0-1.59-1.99-3.097-5.043-4.032.704-3.11.39-5.587-.988-6.38a2.167 2.167 0 0 0-1.092-.278zm-.005 1.09v.006c.225 0 .406.044.558.127.666.382.955 1.835.73 3.704-.054.46-.142.945-.25 1.44a23.476 23.476 0 0 0-3.107-.534A23.892 23.892 0 0 0 12.769 4.7c1.592-1.48 3.087-2.292 4.105-2.295zm-9.77.02c1.012 0 2.514.808 4.11 2.28-.686.72-1.37 1.537-2.02 2.442a22.73 22.73 0 0 0-3.113.538 15.02 15.02 0 0 1-.254-1.42c-.23-1.868.054-3.32.714-3.707.19-.09.4-.127.563-.132zm4.882 3.05c.455.468.91.992 1.36 1.564-.44-.02-.89-.034-1.345-.034-.46 0-.915.01-1.36.034.44-.572.895-1.096 1.345-1.565zM12 8.1c.74 0 1.477.034 2.202.093.406.582.802 1.203 1.183 1.86.372.64.71 1.29 1.018 1.946-.308.655-.646 1.31-1.013 1.95-.38.66-.773 1.288-1.18 1.87a25.64 25.64 0 0 1-4.412.005 26.64 26.64 0 0 1-1.183-1.86c-.372-.64-.71-1.29-1.018-1.946a25.17 25.17 0 0 1 1.013-1.954c.38-.66.773-1.286 1.18-1.868A25.245 25.245 0 0 1 12 8.098zm-3.635.254c-.24.377-.48.763-.704 1.16-.225.39-.435.782-.635 1.174-.265-.656-.49-1.31-.676-1.947.64-.15 1.315-.283 2.015-.386zm7.26 0c.695.103 1.365.23 2.006.387-.18.632-.405 1.282-.66 1.933a25.952 25.952 0 0 0-1.345-2.32zm3.063.675c.484.15.944.317 1.375.498 1.732.74 2.852 1.708 2.852 2.476-.005.768-1.125 1.74-2.857 2.475-.42.18-.88.342-1.355.493a23.966 23.966 0 0 0-1.1-2.98c.45-1.017.81-2.01 1.085-2.964zm-13.395.004c.278.96.645 1.957 1.1 2.98a23.142 23.142 0 0 0-1.086 2.964c-.484-.15-.944-.318-1.37-.5-1.732-.737-2.852-1.706-2.852-2.474 0-.768 1.12-1.742 2.852-2.476.42-.18.88-.342 1.356-.494zm11.678 4.28c.265.657.49 1.312.676 1.948-.64.157-1.316.29-2.016.39a25.819 25.819 0 0 0 1.341-2.338zm-9.945.02c.2.392.41.783.64 1.175.23.39.465.772.705 1.143a22.005 22.005 0 0 1-2.006-.386c.18-.63.406-1.282.66-1.933zM17.92 16.32c.112.493.2.968.254 1.423.23 1.868-.054 3.32-.714 3.708-.147.09-.338.128-.563.128-1.012 0-2.514-.807-4.11-2.28.686-.72 1.37-1.536 2.02-2.44 1.107-.118 2.154-.3 3.113-.54zm-11.83.01c.96.234 2.006.415 3.107.532.66.905 1.345 1.727 2.035 2.446-1.595 1.483-3.092 2.295-4.11 2.295a1.185 1.185 0 0 1-.553-.132c-.666-.38-.955-1.834-.73-3.703.054-.46.142-.944.25-1.438zm4.56.64c.44.02.89.034 1.345.034.46 0 .915-.01 1.36-.034-.44.572-.895 1.095-1.345 1.565-.455-.47-.91-.993-1.36-1.565z\"\n            fill={theme === \"dark\" ? \"#FFFFFF\" : \"#100F13\"}\n          />\n        </svg>\n      ),\n    },\n    {\n      title: \"TypeScript\",\n      description: \"Type safety and more.\",\n      footer: \"TypeScript documentation\",\n      url: \"https://www.typescriptlang.org/docs\",\n      svg: (\n        <svg\n          fill=\"none\"\n          viewBox=\"0 0 512 512\"\n          xmlns=\"http://www.w3.org/2000/svg\"\n          style={{ height: 32 }}\n        >\n          <rect\n            fill={theme === \"dark\" ? \"#FFFFFF\" : \"#100F13\"}\n            height=\"512\"\n            rx=\"50\"\n            width=\"512\"\n          />\n          <path\n            clipRule=\"evenodd\"\n            d=\"m316.939 407.424v50.061c8.138 4.172 17.763 7.3 28.875 9.386s22.823 3.129 35.135 3.129c11.999 0 23.397-1.147 34.196-3.442 10.799-2.294 20.268-6.075 28.406-11.342 8.138-5.266 14.581-12.15 19.328-20.65s7.121-19.007 7.121-31.522c0-9.074-1.356-17.026-4.069-23.857s-6.625-12.906-11.738-18.225c-5.112-5.319-11.242-10.091-18.389-14.315s-15.207-8.213-24.18-11.967c-6.573-2.712-12.468-5.345-17.685-7.9-5.217-2.556-9.651-5.163-13.303-7.822-3.652-2.66-6.469-5.476-8.451-8.448-1.982-2.973-2.974-6.336-2.974-10.091 0-3.441.887-6.544 2.661-9.308s4.278-5.136 7.512-7.118c3.235-1.981 7.199-3.52 11.894-4.615 4.696-1.095 9.912-1.642 15.651-1.642 4.173 0 8.581.313 13.224.938 4.643.626 9.312 1.591 14.008 2.894 4.695 1.304 9.259 2.947 13.694 4.928 4.434 1.982 8.529 4.276 12.285 6.884v-46.776c-7.616-2.92-15.937-5.084-24.962-6.492s-19.381-2.112-31.066-2.112c-11.895 0-23.163 1.278-33.805 3.833s-20.006 6.544-28.093 11.967c-8.086 5.424-14.476 12.333-19.171 20.729-4.695 8.395-7.043 18.433-7.043 30.114 0 14.914 4.304 27.638 12.912 38.172 8.607 10.533 21.675 19.45 39.204 26.751 6.886 2.816 13.303 5.579 19.25 8.291s11.086 5.528 15.415 8.448c4.33 2.92 7.747 6.101 10.252 9.543 2.504 3.441 3.756 7.352 3.756 11.733 0 3.233-.783 6.231-2.348 8.995s-3.939 5.162-7.121 7.196-7.147 3.624-11.894 4.771c-4.748 1.148-10.303 1.721-16.668 1.721-10.851 0-21.597-1.903-32.24-5.71-10.642-3.806-20.502-9.516-29.579-17.13zm-84.159-123.342h64.22v-41.082h-179v41.082h63.906v182.918h50.874z\"\n            fill={theme === \"light\" ? \"#FFFFFF\" : \"#100F13\"}\n            fillRule=\"evenodd\"\n          />\n        </svg>\n      ),\n    },\n    {\n      title: \"ORM\",\n      description: \"Object-relational mapping using Prisma.\",\n      footer: \"Prisma documentation\",\n      url: \"https://www.prisma.io/docs/getting-started/quickstart\",\n      svg: (\n        <svg\n          fill=\"currentColor\"\n          viewBox=\"0.34 -0.059977834648891726 33.11668247084116 39.96397783464889\"\n          xmlns=\"http://www.w3.org/2000/svg\"\n          style={{ height: 32 }}\n        >\n          <path\n            d=\"M32.908 30.475L19.151 1.26a2.208 2.208 0 0 0-1.88-1.257 2.183 2.183 0 0 0-2.01 1.042L.34 25.212a2.26 2.26 0 0 0 .025 2.426L7.66 38.935a2.346 2.346 0 0 0 2.635.969l21.17-6.262a2.32 2.32 0 0 0 1.457-1.258 2.27 2.27 0 0 0-.013-1.91zm-3.08 1.253L11.864 37.04c-.548.163-1.074-.312-.96-.865l6.418-30.731c.12-.575.914-.666 1.165-.134l11.881 25.23a.858.858 0 0 1-.541 1.188z\"\n            clipRule=\"evenodd\"\n            fillRule=\"evenodd\"\n          />\n        </svg>\n      ),\n    },\n    {\n      title: \"Database\",\n      description: \"PostgreSQL database deployed on Supabase.\",\n      footer: \"Provision database on Supabase\",\n      url: \"https://supabase.com/dashboard\",\n      svg: (\n        <svg\n          viewBox=\"0 0 109 113\"\n          fill=\"currentColor\"\n          xmlns=\"http://www.w3.org/2000/svg\"\n          style={{ height: 32 }}\n        >\n          <path\n            d=\"M63.7076 110.284C60.8481 113.885 55.0502 111.912 54.9813 107.314L53.9738 40.0627L99.1935 40.0627C107.384 40.0627 111.952 49.5228 106.859 55.9374L63.7076 110.284Z\"\n            fill=\"url(#paint0_linear)\"\n          />\n          <path\n            d=\"M63.7076 110.284C60.8481 113.885 55.0502 111.912 54.9813 107.314L53.9738 40.0627L99.1935 40.0627C107.384 40.0627 111.952 49.5228 106.859 55.9374L63.7076 110.284Z\"\n            fill=\"url(#paint1_linear)\"\n            fillOpacity=\"0.2\"\n          />\n          <path\n            d=\"M45.317 2.07103C48.1765 -1.53037 53.9745 0.442937 54.0434 5.041L54.4849 72.2922H9.83113C1.64038 72.2922 -2.92775 62.8321 2.1655 56.4175L45.317 2.07103Z\"\n            fill={theme === \"dark\" ? \"#FFFFFF\" : \"#100F13\"}\n          />\n          <defs>\n            <linearGradient\n              id=\"paint0_linear\"\n              x1=\"53.9738\"\n              y1=\"54.974\"\n              x2=\"94.1635\"\n              y2=\"71.8295\"\n              gradientUnits=\"userSpaceOnUse\"\n            >\n              <stop stopColor={theme === \"dark\" ? \"#b8b8b8\" : \"#44414d\"} />\n              <stop\n                offset=\"1\"\n                stopColor={theme === \"dark\" ? \"#FFFFFF\" : \"#100F13\"}\n              />\n            </linearGradient>\n            <linearGradient\n              id=\"paint1_linear\"\n              x1=\"36.1558\"\n              y1=\"30.578\"\n              x2=\"54.4844\"\n              y2=\"65.0806\"\n              gradientUnits=\"userSpaceOnUse\"\n            >\n              <stop />\n              <stop offset=\"1\" stopOpacity=\"0\" />\n            </linearGradient>\n          </defs>\n        </svg>\n      ),\n    },\n    {\n      title: \"Components\",\n      description:\n        \"UI components built with NextUI. Dark mode implemented using next-themes.\",\n      footer: \"NextUI documentation\",\n      url: \"https://nextui.org/docs/guide/getting-started\",\n      svg: (\n        <svg\n          xmlns=\"http://www.w3.org/2000/svg\"\n          viewBox=\"0 0 374 374\"\n          style={{ height: 32 }}\n        >\n          <g id=\"Group_1\" data-name=\"Group 1\" transform=\"translate(-773 -353)\">\n            <rect\n              id=\"Rectangle_1\"\n              data-name=\"Rectangle 1\"\n              width=\"374\"\n              height=\"374\"\n              rx=\"99\"\n              transform=\"translate(773 353)\"\n              fill={theme === \"dark\" ? \"#FFFFFF\" : \"#100F13\"}\n            />\n            <path\n              id=\"Path_2\"\n              data-name=\"Path 2\"\n              d=\"M127.309-159.273h14.543V-53.817a55.656,55.656,0,0,1-7.621,29.047A54.131,54.131,0,0,1,113.039-4.627Q99.468,2.722,81.5,2.722q-17.887,0-31.5-7.388A54.429,54.429,0,0,1,28.775-24.809a55.451,55.451,0,0,1-7.621-29.008V-159.273H35.7V-54.828a44.65,44.65,0,0,0,5.677,22.592A40.568,40.568,0,0,0,57.355-16.643q10.3,5.677,24.148,5.677t24.186-5.677a40.232,40.232,0,0,0,15.982-15.593,44.893,44.893,0,0,0,5.638-22.592Zm71.393,0V0H184.159V-159.273Z\"\n              transform=\"translate(851 620)\"\n              fill={theme === \"dark\" ? \"#100F13\" : \"#FFFFFF\"}\n            />\n          </g>\n        </svg>\n      ),\n    },\n    {\n      title: \"Tailwind CSS\",\n      description:\n        \"Utility-first CSS framework enabling rapid and customizable front-end styling.\",\n      footer: \"Tailwind CSS Documentation\",\n      url: \"https://tailwindcss.com/docs\",\n      svg: (\n        <svg\n          xmlns=\"http://www.w3.org/2000/svg\"\n          fill=\"none\"\n          viewBox=\"0 0 54 33\"\n          style={{ height: 24 }}\n        >\n          <g clipPath=\"url(#prefix__clip0)\">\n            <path\n              fill={theme === \"dark\" ? \"#FFFFFF\" : \"#100F13\"}\n              fillRule=\"evenodd\"\n              d=\"M27 0c-7.2 0-11.7 3.6-13.5 10.8 2.7-3.6 5.85-4.95 9.45-4.05 2.054.513 3.522 2.004 5.147 3.653C30.744 13.09 33.808 16.2 40.5 16.2c7.2 0 11.7-3.6 13.5-10.8-2.7 3.6-5.85 4.95-9.45 4.05-2.054-.513-3.522-2.004-5.147-3.653C36.756 3.11 33.692 0 27 0zM13.5 16.2C6.3 16.2 1.8 19.8 0 27c2.7-3.6 5.85-4.95 9.45-4.05 2.054.514 3.522 2.004 5.147 3.653C17.244 29.29 20.308 32.4 27 32.4c7.2 0 11.7-3.6 13.5-10.8-2.7 3.6-5.85 4.95-9.45 4.05-2.054-.513-3.522-2.004-5.147-3.653C23.256 19.31 20.192 16.2 13.5 16.2z\"\n              clipRule=\"evenodd\"\n            />\n          </g>\n          <defs>\n            <clipPath id=\"prefix__clip0\">\n              <path fill=\"#fff\" d=\"M0 0h54v32.4H0z\" />\n            </clipPath>\n          </defs>\n        </svg>\n      ),\n    },\n    {\n      title: \"Light & Dark Mode\",\n      description: \"Theme switching implemented using next-themes.\",\n      footer: \"next-themes documentation\",\n      url: \"https://github.com/pacocoursey/next-themes/blob/main/README.md\",\n      svg:\n        theme === \"dark\" ? (\n          <svg\n            aria-hidden=\"true\"\n            focusable=\"false\"\n            role=\"presentation\"\n            viewBox=\"0 0 24 24\"\n            style={{ height: 30 }}\n          >\n            <path\n              d=\"M21.53 15.93c-.16-.27-.61-.69-1.73-.49a8.46 8.46 0 01-1.88.13 8.409 8.409 0 01-5.91-2.82 8.068 8.068 0 01-1.44-8.66c.44-1.01.13-1.54-.09-1.76s-.77-.55-1.83-.11a10.318 10.318 0 00-6.32 10.21 10.475 10.475 0 007.04 8.99 10 10 0 002.89.55c.16.01.32.02.48.02a10.5 10.5 0 008.47-4.27c.67-.93.49-1.519.32-1.79z\"\n              fill=\"currentColor\"\n            />\n          </svg>\n        ) : (\n          <svg\n            aria-hidden=\"true\"\n            focusable=\"false\"\n            role=\"presentation\"\n            viewBox=\"0 0 24 24\"\n            style={{ height: 30 }}\n          >\n            <g fill=\"currentColor\">\n              <path d=\"M19 12a7 7 0 11-7-7 7 7 0 017 7z\" />\n              <path d=\"M12 22.96a.969.969 0 01-1-.96v-.08a1 1 0 012 0 1.038 1.038 0 01-1 1.04zm7.14-2.82a1.024 1.024 0 01-.71-.29l-.13-.13a1 1 0 011.41-1.41l.13.13a1 1 0 010 1.41.984.984 0 01-.7.29zm-14.28 0a1.024 1.024 0 01-.71-.29 1 1 0 010-1.41l.13-.13a1 1 0 011.41 1.41l-.13.13a1 1 0 01-.7.29zM22 13h-.08a1 1 0 010-2 1.038 1.038 0 011.04 1 .969.969 0 01-.96 1zM2.08 13H2a1 1 0 010-2 1.038 1.038 0 011.04 1 .969.969 0 01-.96 1zm16.93-7.01a1.024 1.024 0 01-.71-.29 1 1 0 010-1.41l.13-.13a1 1 0 011.41 1.41l-.13.13a.984.984 0 01-.7.29zm-14.02 0a1.024 1.024 0 01-.71-.29l-.13-.14a1 1 0 011.41-1.41l.13.13a1 1 0 010 1.41.97.97 0 01-.7.3zM12 3.04a.969.969 0 01-1-.96V2a1 1 0 012 0 1.038 1.038 0 01-1 1.04z\" />\n            </g>\n          </svg>\n        ),\n    },\n    {\n      title: \"Authentication\",\n      description:\n        \"OAuth 2.0 authentication through Google, GitHub, and Discord using NextAuth.js.\",\n      footer: \"NextAuth.js documentation\",\n      url: \"https://next-auth.js.org/getting-started/introduction\",\n      svg: (\n        <svg\n          viewBox=\"0 0 24 24\"\n          // fill=\"none\"\n          stroke={theme === \"dark\" ? \"#000000\" : \"#FFFFFF\"}\n          strokeWidth=\"1\"\n          className=\"h-12 w-12 fill-current\"\n          style={{ height: 32 }}\n          fill={theme === \"dark\" ? \"#FFFFFF\" : \"#100F13\"}\n        >\n          <path d=\"M12 22s8-4 8-10V5l-8-3-8 3v7c0 6 8 10 8 10z\"></path>\n        </svg>\n      ),\n    },\n    {\n      title: \"OpenAI API\",\n      description:\n        \"Uses GPT-3.5-Turbo model from OpenAI to enhance social media posts.\",\n      footer: \"OpenAI API documentation\",\n      url: \"https://platform.openai.com/docs/api-reference\",\n      svg: (\n        <svg\n          viewBox=\"0 0 24 24\"\n          className=\"h-12 w-12 fill-current\"\n          style={{ height: 32 }}\n        >\n          <path\n            d=\"M22.2819 9.8211a5.9847 5.9847 0 0 0-.5157-4.9108 6.0462 6.0462 0 0 0-6.5098-2.9A6.0651 6.0651 0 0 0 4.9807 4.1818a5.9847 5.9847 0 0 0-3.9977 2.9 6.0462 6.0462 0 0 0 .7427 7.0966 5.98 5.98 0 0 0 .511 4.9107 6.051 6.051 0 0 0 6.5146 2.9001A5.9847 5.9847 0 0 0 13.2599 24a6.0557 6.0557 0 0 0 5.7718-4.2058 5.9894 5.9894 0 0 0 3.9977-2.9001 6.0557 6.0557 0 0 0-.7475-7.0729zm-9.022 12.6081a4.4755 4.4755 0 0 1-2.8764-1.0408l.1419-.0804 4.7783-2.7582a.7948.7948 0 0 0 .3927-.6813v-6.7369l2.02 1.1686a.071.071 0 0 1 .038.052v5.5826a4.504 4.504 0 0 1-4.4945 4.4944zm-9.6607-4.1254a4.4708 4.4708 0 0 1-.5346-3.0137l.142.0852 4.783 2.7582a.7712.7712 0 0 0 .7806 0l5.8428-3.3685v2.3324a.0804.0804 0 0 1-.0332.0615L9.74 19.9502a4.4992 4.4992 0 0 1-6.1408-1.6464zM2.3408 7.8956a4.485 4.485 0 0 1 2.3655-1.9728V11.6a.7664.7664 0 0 0 .3879.6765l5.8144 3.3543-2.0201 1.1685a.0757.0757 0 0 1-.071 0l-4.8303-2.7865A4.504 4.504 0 0 1 2.3408 7.872zm16.5963 3.8558L13.1038 8.364 15.1192 7.2a.0757.0757 0 0 1 .071 0l4.8303 2.7913a4.4944 4.4944 0 0 1-.6765 8.1042v-5.6772a.79.79 0 0 0-.407-.667zm2.0107-3.0231l-.142-.0852-4.7735-2.7818a.7759.7759 0 0 0-.7854 0L9.409 9.2297V6.8974a.0662.0662 0 0 1 .0284-.0615l4.8303-2.7866a4.4992 4.4992 0 0 1 6.6802 4.66zM8.3065 12.863l-2.02-1.1638a.0804.0804 0 0 1-.038-.0567V6.0742a4.4992 4.4992 0 0 1 7.3757-3.4537l-.142.0805L8.704 5.459a.7948.7948 0 0 0-.3927.6813zm1.0976-2.3654l2.602-1.4998 2.6069 1.4998v2.9994l-2.5974 1.4997-2.6067-1.4997Z\"\n            fill={theme === \"dark\" ? \"#FFFFFF\" : \"#100F13\"}\n          />\n        </svg>\n      ),\n    },\n    {\n      title: \"Payments\",\n      description:\n        \"Paid subscriptions using Stripe unlocking features for users.\",\n      footer: \"Stripe Payment API documentation\",\n      url: \"https://stripe.com/docs/payments\",\n      svg: (\n        <svg\n          viewBox=\"0 0 24 24\"\n          className=\"h-12 w-12 fill-current\"\n          style={{ height: 32 }}\n        >\n          <path\n            d=\"M13.976 9.15c-2.172-.806-3.356-1.426-3.356-2.409 0-.831.683-1.305 1.901-1.305 2.227 0 4.515.858 6.09 1.631l.89-5.494C18.252.975 15.697 0 12.165 0 9.667 0 7.589.654 6.104 1.872 4.56 3.147 3.757 4.992 3.757 7.218c0 4.039 2.467 5.76 6.476 7.219 2.585.92 3.445 1.574 3.445 2.583 0 .98-.84 1.545-2.354 1.545-1.875 0-4.965-.921-6.99-2.109l-.9 5.555C5.175 22.99 8.385 24 11.714 24c2.641 0 4.843-.624 6.328-1.813 1.664-1.305 2.525-3.236 2.525-5.732 0-4.128-2.524-5.851-6.594-7.305h.003z\"\n            fill={theme === \"dark\" ? \"#FFFFFF\" : \"#100F13\"}\n          />\n        </svg>\n      ),\n    },\n  ];\n\n  return (\n    <div className=\"container mx-auto p-4 max-w-7xl\">\n      <Spacer />\n\n      <div className=\"space-y-4 text-center\">\n        <h1 className=\"pb-2 font-bold text-5xl text-transparent bg-clip-text bg-gradient-to-r from-indigo-500 via-purple-500 to-pink-500\">\n          Welcome{user && `, ${user.name}`}!\n        </h1>\n        <h2 className=\"text-2xl font-medium\">\n          This is an app built to showcase the capabilities of Next.js 14.\n        </h2>\n\n        <Spacer y={1} />\n\n        <div className=\"flex flex-wrap space-x-4 justify-center\">\n          <Button\n            className=\"font-medium bg-gradient-to-r from-pink-500 to-yellow-600 text-white shadow-lg\"\n            onClick={() =>\n              window.open(\"https://github.com/yaseenmustapha/nextjs14-app\")\n            }\n          >\n            Source Code on GitHub\n          </Button>\n\n          <Link href=\"https://github.com/yaseenmustapha/nextjs14-app\">\n            <p className=\"text-lg font-medium text-transparent bg-clip-text bg-gradient-to-r from-yellow-500 to-pink-500 pr-2\">\n              {numStars} stars on GitHub\n            </p>\n          </Link>\n        </div>\n\n        <User\n          className=\"font-medium text-medium\"\n          name=\"Yaseen Mustapha\"\n          description={\n            <Link\n              className=\"text-small\"\n              href=\"https://github.com/yaseenmustapha\"\n            >\n              github.com/yaseenmustapha\n            </Link>\n          }\n          avatarProps={{\n            src: \"https://avatars.githubusercontent.com/u/26501999\",\n          }}\n          onClick={() => window.open(\"https://github.com/yaseenmustapha\")}\n        />\n\n        <Spacer y={5} />\n\n        <p className=\"text-3xl font-medium\">Features</p>\n      </div>\n\n      <div className=\"grid grid-cols-1 md:grid-cols-3 gap-4 justify-center mt-4\">\n        {cardItems.map((item, i) => (\n          <div key={i} className=\"w-full\">\n            <Card className=\"h-full p-1\">\n              <CardHeader>\n                <div className=\"flex items-center\">\n                  {item.svg}\n                  <div className=\"ml-2 font-bold\">{item.title}</div>\n                </div>\n              </CardHeader>\n              <CardBody>\n                <div className=\"mt-2\">\n                  <p>{item.description}</p>\n                </div>\n              </CardBody>\n              <CardFooter>\n                <Link color=\"primary\" target=\"_blank\" href={item.url}>\n                  {item.footer}\n                </Link>\n              </CardFooter>\n            </Card>\n          </div>\n        ))}\n      </div>\n    </div>\n  );\n}\n"
  },
  {
    "path": "app/(home)/page.tsx",
    "content": "import HomePage from \"./HomePage\";\n\nasync function getStars() {\n  const res = await fetch(\n    \"https://api.github.com/repos/yaseenmustapha/nextjs14-app\",\n    { next: { revalidate: 60 } }\n  );\n  const data = await res.json();\n  return data.stargazers_count;\n}\n\nexport default async function Home() {\n  const githubStars = await getStars();\n\n  return (\n    <main>\n      <HomePage numStars={githubStars} />\n    </main>\n  );\n}\n"
  },
  {
    "path": "app/Nav.tsx",
    "content": "\"use client\";\nimport React, { useState } from \"react\";\nimport { useSession, signIn, signOut } from \"next-auth/react\";\nimport {\n  Avatar,\n  Badge,\n  Button,\n  Link,\n  Navbar,\n  NavbarBrand,\n  NavbarContent,\n  NavbarItem,\n  NavbarMenu,\n  NavbarMenuItem,\n  NavbarMenuToggle,\n  Spinner,\n  Switch,\n} from \"@nextui-org/react\";\nimport NextLink from \"next/link\";\nimport { useTheme } from \"next-themes\";\nimport { useSelectedLayoutSegment } from \"next/navigation\";\n\nconst SunIcon = (\n  props: JSX.IntrinsicAttributes & React.SVGProps<SVGSVGElement>\n) => (\n  <svg\n    aria-hidden=\"true\"\n    focusable=\"false\"\n    height=\"1em\"\n    role=\"presentation\"\n    viewBox=\"0 0 24 24\"\n    width=\"1em\"\n    {...props}\n  >\n    <g fill=\"currentColor\">\n      <path d=\"M19 12a7 7 0 11-7-7 7 7 0 017 7z\" />\n      <path d=\"M12 22.96a.969.969 0 01-1-.96v-.08a1 1 0 012 0 1.038 1.038 0 01-1 1.04zm7.14-2.82a1.024 1.024 0 01-.71-.29l-.13-.13a1 1 0 011.41-1.41l.13.13a1 1 0 010 1.41.984.984 0 01-.7.29zm-14.28 0a1.024 1.024 0 01-.71-.29 1 1 0 010-1.41l.13-.13a1 1 0 011.41 1.41l-.13.13a1 1 0 01-.7.29zM22 13h-.08a1 1 0 010-2 1.038 1.038 0 011.04 1 .969.969 0 01-.96 1zM2.08 13H2a1 1 0 010-2 1.038 1.038 0 011.04 1 .969.969 0 01-.96 1zm16.93-7.01a1.024 1.024 0 01-.71-.29 1 1 0 010-1.41l.13-.13a1 1 0 011.41 1.41l-.13.13a.984.984 0 01-.7.29zm-14.02 0a1.024 1.024 0 01-.71-.29l-.13-.14a1 1 0 011.41-1.41l.13.13a1 1 0 010 1.41.97.97 0 01-.7.3zM12 3.04a.969.969 0 01-1-.96V2a1 1 0 012 0 1.038 1.038 0 01-1 1.04z\" />\n    </g>\n  </svg>\n);\n\nconst MoonIcon = (\n  props: JSX.IntrinsicAttributes & React.SVGProps<SVGSVGElement>\n) => (\n  <svg\n    aria-hidden=\"true\"\n    focusable=\"false\"\n    height=\"1em\"\n    role=\"presentation\"\n    viewBox=\"0 0 24 24\"\n    width=\"1em\"\n    {...props}\n  >\n    <path\n      d=\"M21.53 15.93c-.16-.27-.61-.69-1.73-.49a8.46 8.46 0 01-1.88.13 8.409 8.409 0 01-5.91-2.82 8.068 8.068 0 01-1.44-8.66c.44-1.01.13-1.54-.09-1.76s-.77-.55-1.83-.11a10.318 10.318 0 00-6.32 10.21 10.475 10.475 0 007.04 8.99 10 10 0 002.89.55c.16.01.32.02.48.02a10.5 10.5 0 008.47-4.27c.67-.93.49-1.519.32-1.79z\"\n      fill=\"currentColor\"\n    />\n  </svg>\n);\n\nexport default function Nav() {\n  const { data: session, status } = useSession();\n  const { user } = session || {};\n  const isSubscribed = user?.subscriptionStatus === \"active\" || false;\n  const segment = useSelectedLayoutSegment();\n  const { theme, setTheme } = useTheme();\n  const [isMenuOpen, setIsMenuOpen] = useState(false);\n\n  return (\n    <Navbar onMenuOpenChange={setIsMenuOpen} className=\"mt-2\">\n      <NavbarContent>\n        <NavbarMenuToggle\n          aria-label={isMenuOpen ? \"Close menu\" : \"Open menu\"}\n          className=\"sm:hidden\"\n        />\n        <NavbarBrand>\n          <svg viewBox=\"0 0 24 24\" style={{ height: 32 }}>\n            <path\n              d=\"M11.572 0c-.176 0-.31.001-.358.007a19.76 19.76 0 0 1-.364.033C7.443.346 4.25 2.185 2.228 5.012a11.875 11.875 0 0 0-2.119 5.243c-.096.659-.108.854-.108 1.747s.012 1.089.108 1.748c.652 4.506 3.86 8.292 8.209 9.695.779.25 1.6.422 2.534.525.363.04 1.935.04 2.299 0 1.611-.178 2.977-.577 4.323-1.264.207-.106.247-.134.219-.158-.02-.013-.9-1.193-1.955-2.62l-1.919-2.592-2.404-3.558a338.739 338.739 0 0 0-2.422-3.556c-.009-.002-.018 1.579-.023 3.51-.007 3.38-.01 3.515-.052 3.595a.426.426 0 0 1-.206.214c-.075.037-.14.044-.495.044H7.81l-.108-.068a.438.438 0 0 1-.157-.171l-.05-.106.006-4.703.007-4.705.072-.092a.645.645 0 0 1 .174-.143c.096-.047.134-.051.54-.051.478 0 .558.018.682.154.035.038 1.337 1.999 2.895 4.361a10760.433 10760.433 0 0 0 4.735 7.17l1.9 2.879.096-.063a12.317 12.317 0 0 0 2.466-2.163 11.944 11.944 0 0 0 2.824-6.134c.096-.66.108-.854.108-1.748 0-.893-.012-1.088-.108-1.747-.652-4.506-3.859-8.292-8.208-9.695a12.597 12.597 0 0 0-2.499-.523A33.119 33.119 0 0 0 11.573 0zm4.069 7.217c.347 0 .408.005.486.047a.473.473 0 0 1 .237.277c.018.06.023 1.365.018 4.304l-.006 4.218-.744-1.14-.746-1.14v-3.066c0-1.982.01-3.097.023-3.15a.478.478 0 0 1 .233-.296c.096-.05.13-.054.5-.054z\"\n              fill={theme === \"dark\" ? \"#FFFFFF\" : \"#100F13\"}\n            />\n          </svg>\n          <p className=\"font-bold text-inherit hidden sm:flex pl-4\">\n            Next.js 14 Showcase\n          </p>\n        </NavbarBrand>\n      </NavbarContent>\n\n      <NavbarContent className=\"hidden sm:flex gap-6\" justify=\"center\">\n        <NavbarItem isActive={segment === \"(home)\"}>\n          <Link\n            color={segment === \"(home)\" ? undefined : \"foreground\"}\n            href=\"/\"\n            as={NextLink}\n          >\n            Home\n          </Link>\n        </NavbarItem>\n        <NavbarItem isActive={segment === \"posts\"}>\n          <Link\n            color={segment === \"posts\" ? undefined : \"foreground\"}\n            href=\"/posts\"\n            as={NextLink}\n          >\n            Feed\n          </Link>\n        </NavbarItem>\n        <NavbarItem isActive={segment === \"subscribe\"}>\n          <Link\n            color={segment === \"subscribe\" ? undefined : \"foreground\"}\n            href=\"/subscribe\"\n            as={NextLink}\n          >\n            Subscribe\n          </Link>\n        </NavbarItem>\n      </NavbarContent>\n\n      <NavbarContent justify=\"end\">\n        <Switch\n          isSelected={theme === \"dark\"}\n          onChange={(e) => setTheme(theme === \"dark\" ? \"light\" : \"dark\")}\n          thumbIcon={({ isSelected, className }) =>\n            isSelected ? (\n              <MoonIcon className={className} />\n            ) : (\n              <SunIcon className={className} />\n            )\n          }\n        />\n        {session ? (\n          <>\n            {isSubscribed ? (\n              <Badge\n                disableOutline\n                content=\"PRO\"\n                size=\"md\"\n                color=\"primary\"\n                className=\"font-bold text-xs py-1 px-2\"\n              >\n                {user?.image ? (\n                  <Avatar src={user.image as string} />\n                ) : (\n                  <Avatar name={user?.name?.charAt(0) as string} />\n                )}\n              </Badge>\n            ) : user?.image ? (\n              <Avatar src={user.image as string} />\n            ) : (\n              <Avatar name={user?.name?.charAt(0) as string} />\n            )}\n            <Button variant=\"light\" onClick={() => signOut()}>\n              Sign out\n            </Button>\n          </>\n        ) : (\n          <NavbarItem>\n            <Button variant=\"flat\" onClick={() => signIn()} color=\"primary\">\n              {status && status === \"loading\" ? (\n                <Spinner color=\"primary\" size=\"sm\" />\n              ) : (\n                \"Login\"\n              )}\n            </Button>\n          </NavbarItem>\n        )}\n      </NavbarContent>\n\n      <NavbarMenu>\n        <NavbarMenuItem>\n          <Link\n            style={{\n              minWidth: \"100%\",\n              color: \"inherit\",\n              fontWeight: segment === \"(home)\" ? \"bold\" : \"normal\",\n            }}\n            href=\"/\"\n            as={NextLink}\n          >\n            Home\n          </Link>\n        </NavbarMenuItem>\n        <NavbarMenuItem>\n          <Link\n            style={{\n              minWidth: \"100%\",\n              color: \"inherit\",\n              fontWeight: segment === \"posts\" ? \"bold\" : \"normal\",\n            }}\n            href=\"/posts\"\n            as={NextLink}\n          >\n            Feed\n          </Link>\n        </NavbarMenuItem>\n        <NavbarMenuItem>\n          <Link\n            style={{\n              minWidth: \"100%\",\n              color: \"inherit\",\n              fontWeight: segment === \"subscribe\" ? \"bold\" : \"normal\",\n            }}\n            href=\"/subscribe\"\n            as={NextLink}\n          >\n            Subscribe\n          </Link>\n        </NavbarMenuItem>\n      </NavbarMenu>\n    </Navbar>\n  );\n}\n"
  },
  {
    "path": "app/ProvidersWrapper.tsx",
    "content": "\"use client\";\nimport { NextUIProvider } from \"@nextui-org/react\";\nimport { SessionProvider } from \"next-auth/react\";\nimport { ThemeProvider as NextThemesProvider } from \"next-themes\";\n\nexport default function ProvidersWrapper({\n  children,\n}: {\n  children: React.ReactNode;\n}) {\n  return (\n    <SessionProvider>\n      <NextThemesProvider defaultTheme=\"system\" attribute=\"class\">\n        <NextUIProvider>{children}</NextUIProvider>\n      </NextThemesProvider>\n    </SessionProvider>\n  );\n}\n"
  },
  {
    "path": "app/api/enhanceMessage/route.ts",
    "content": "import { NextResponse } from \"next/server\";\nimport openai from \"@/lib/openai\";\n\nexport async function POST(request: Request) {\n  const { prompt } = await request.json();\n  const chatCompletion = await openai.chat.completions.create({\n    model: \"gpt-3.5-turbo\",\n    messages: [\n      {\n        role: \"user\",\n        content: `Rewrite this social media post to make it more punchy, viral and interesting (keep it under 300 characters and do not add quotes around the text): ${prompt}`,\n      },\n    ],\n    max_tokens: 100,\n    n: 1,\n  });\n\n  return NextResponse.json(chatCompletion.choices[0].message);\n}\n"
  },
  {
    "path": "app/api/portal/route.ts",
    "content": "import prisma from \"@/lib/prisma\";\nimport stripe from \"@/lib/stripe\";\nimport { authOptions } from \"@/pages/api/auth/[...nextauth]\";\nimport { getServerSession } from \"next-auth\";\nimport { NextResponse } from \"next/server\";\n\nexport async function POST(req: Request) {\n  const session = await getServerSession(authOptions);\n  const { user } = session || {};\n\n  try {\n    const dbUser = await prisma.user.findUnique({\n      where: { email: user.email },\n    });\n\n    if (!dbUser) {\n      throw new Error(\"User not found in database\");\n    }\n    if (!dbUser.stripeCustomerId) {\n      throw new Error(\"User does not have a Stripe customer ID\");\n    }\n\n    const session = await stripe.billingPortal.sessions.create({\n      customer: dbUser.stripeCustomerId,\n      return_url: `${process.env.BASE_URL}/subscribe`,\n    });\n\n    return NextResponse.redirect(session.url as string, { status: 303 });\n  } catch (error) {\n    console.log(error);\n    return NextResponse.error();\n  }\n}\n"
  },
  {
    "path": "app/api/stripe/route.ts",
    "content": "import stripe from \"@/lib/stripe\";\nimport { authOptions } from \"@/pages/api/auth/[...nextauth]\";\nimport { getServerSession } from \"next-auth\";\nimport { NextResponse } from \"next/server\";\n\nexport async function POST(req: Request) {\n  const session = await getServerSession(authOptions);\n  const { user } = session || {};\n\n  try {\n    const session = await stripe.checkout.sessions.create({\n      client_reference_id: user.id,\n      mode: \"subscription\",\n      line_items: [\n        {\n          price: process.env.STRIPE_SUBSCRIPTION_PRICE_ID,\n          quantity: 1,\n        },\n      ],\n      // {CHECKOUT_SESSION_ID} is a string literal; do not change it!\n      // the actual Session ID is returned in the query parameter when your customer\n      // is redirected to the success page.\n      // success_url: `${process.env.BASE_URL}/subscribe/success?session_id={CHECKOUT_SESSION_ID}`,\n      success_url: `${process.env.BASE_URL}/subscribe/success`,\n      cancel_url: `${process.env.BASE_URL}/subscribe`,\n    });\n\n    return NextResponse.redirect(session.url as string, { status: 303 });\n  } catch (error) {\n    console.log(error);\n    return NextResponse.error();\n  }\n}\n"
  },
  {
    "path": "app/globals.css",
    "content": "@tailwind base;\n@tailwind components;\n@tailwind utilities;\n\nbody {\n  overflow-y: scroll;\n}\n"
  },
  {
    "path": "app/layout.tsx",
    "content": "import ProvidersWrapper from \"./ProvidersWrapper\";\nimport Nav from \"./Nav\";\nimport \"./globals.css\";\n\nexport const metadata = {\n  title: \"Next.js 14 Showcase\",\n  description: \"Created by Yaseen Mustapha\",\n  keywords: [\n    \"Next.js\",\n    \"React\",\n    \"TypeScript\",\n    \"Server Components\",\n    \"NextUI\",\n    \"NextAuth\",\n    \"Prisma\",\n    \"PostgreSQL\",\n    \"OpenAI\",\n    \"GPT\",\n    \"Stripe\",\n  ],\n  authors: [\n    {\n      name: \"Yaseen Mustapha\",\n      url: \"https://github.com/yaseenmustapha\",\n    },\n  ],\n  creator: \"Yaseen Mustapha\",\n  publisher: \"Yaseen Mustapha\",\n};\n\nexport default function RootLayout({\n  children,\n}: {\n  children: React.ReactNode;\n}) {\n  return (\n    <html lang=\"en\">\n      <body>\n        <ProvidersWrapper>\n          <Nav />\n          {children}\n        </ProvidersWrapper>\n      </body>\n    </html>\n  );\n}\n"
  },
  {
    "path": "app/posts/AddPost.tsx",
    "content": "\"use client\";\nimport {\n  Button,\n  Popover,\n  PopoverContent,\n  PopoverTrigger,\n  Spacer,\n  Spinner,\n  Textarea,\n} from \"@nextui-org/react\";\nimport { useSession } from \"next-auth/react\";\nimport { useRouter } from \"next/navigation\";\nimport { useState } from \"react\";\nimport Filter from \"bad-words\";\n\nconst filter = new Filter();\n\nexport default function AddPost(): JSX.Element {\n  const { data: session } = useSession();\n  const [content, setContent] = useState(\"\");\n  const [loading, setLoading] = useState(false);\n  const [enhancing, setEnhancing] = useState(false);\n  const [enhanceError, setEnhanceError] = useState(false);\n  const [error, setError] = useState(false);\n  const [errorMessage, setErrorMessage] = useState(\"Error creating post.\");\n  const router = useRouter();\n\n  const enhanceWithAI = async () => {\n    if (enhancing) return;\n    if (content.length < 1) {\n      setEnhanceError(true);\n      return;\n    }\n    setEnhancing(true);\n    setEnhanceError(false);\n\n    const res = await fetch(\"/api/enhanceMessage\", {\n      method: \"POST\",\n      headers: {\n        \"Content-Type\": \"application/json\",\n      },\n      body: JSON.stringify({\n        prompt: content,\n      }),\n    });\n\n    if (res.ok) {\n      const GPTdata = await res.json();\n      setContent(GPTdata.content);\n    } else {\n      setEnhanceError(true);\n    }\n    setEnhancing(false);\n  };\n\n  const handleSubmit = async (e: React.FormEvent) => {\n    e.preventDefault();\n    if (loading) return;\n    setLoading(true);\n    setError(false);\n\n    if (content.length < 1) {\n      setErrorMessage(\"Post cannot be empty.\");\n      setError(true);\n    } else if (filter.isProfane(content)) {\n      setErrorMessage(\"Profanity is not allowed.\");\n      setError(true);\n    } else {\n      try {\n        const filteredContent = filter.clean(content);\n        const res = await fetch(\"/api/addPost\", {\n          method: \"POST\",\n          headers: {\n            \"Content-Type\": \"application/json\",\n          },\n          body: JSON.stringify({\n            content: filteredContent,\n          }),\n        });\n        if (res.ok) {\n          setContent(\"\");\n          router.refresh();\n        }\n        setError(false);\n      } catch {\n        setErrorMessage(\"Error creating post.\");\n        setError(true);\n      }\n    }\n\n    setLoading(false);\n  };\n\n  return (\n    <form onSubmit={handleSubmit} style={{ width: \"100%\" }}>\n      <Textarea\n        isInvalid={error}\n        errorMessage={error && errorMessage}\n        className=\"mt-6\"\n        size=\"lg\"\n        variant=\"bordered\"\n        labelPlacement=\"outside\"\n        isDisabled={!session || enhancing}\n        label={session ? \"Write your thoughts:\" : \"Please sign in to post.\"}\n        placeholder={session ? \"Enter your amazing ideas...\" : \"\"}\n        value={content}\n        maxLength={300}\n        onChange={(e) => setContent(e.target.value)}\n      />\n      <Spacer y={0.5} />\n      <div className=\"row flex-wrap flex items-center\">\n        <Button\n          className=\"font-medium\"\n          color=\"primary\"\n          type=\"submit\"\n          isDisabled={!session || enhancing}\n          // auto\n          style={{ minWidth: \"100px\" }}\n        >\n          {loading ? <Spinner size=\"sm\" /> : \"Post\"}\n        </Button>\n\n        <Popover\n          isOpen={enhanceError}\n          onOpenChange={enhanceError ? setEnhanceError : undefined}\n          placement=\"right\"\n        >\n          <PopoverTrigger>\n            <Button\n              // color=\"gradient\"\n              isDisabled={!session || enhancing}\n              style={{ marginLeft: 10, minWidth: \"150px\" }}\n              onClick={enhanceWithAI}\n              // auto\n              // shadow\n              className=\"font-medium bg-gradient-to-r from-pink-700 to-purple-600 text-white shadow-lg\"\n            >\n              {enhancing ? <Spinner size=\"sm\" /> : \"Enhance with AI 😎\"}\n            </Button>\n          </PopoverTrigger>\n          <PopoverContent>\n            <p className=\"p-2\">Error enhancing post. Please try again.</p>\n          </PopoverContent>\n        </Popover>\n\n        <p className=\"ml-auto\">{(content && content.length) || \"0\"}/300</p>\n      </div>\n\n      <Spacer y={2} />\n    </form>\n  );\n}\n"
  },
  {
    "path": "app/posts/Feed.tsx",
    "content": "\"use client\";\nimport { Spacer } from \"@nextui-org/react\";\nimport { Comment, Like, User } from \"@prisma/client\";\nimport AddPost from \"./AddPost\";\nimport Header from \"./Header\";\nimport Post from \"./Post\";\n\nexport default function Feed({\n  posts,\n}: {\n  posts: {\n    id: string;\n    content: string;\n    user: User;\n    createdAt: string;\n    likes: Like[];\n    comments: {\n      id: string;\n      user: User;\n      createdAt: string;\n      content: string;\n    }[];\n  }[];\n}) {\n  return (\n    <main>\n      <div className=\"container mx-auto px-6 sm:px-8 md:px-16 lg:px-20 max-w-3xl mt-6 items-center\">\n        <Spacer y={0.5} />\n        <Header />\n        <AddPost />\n\n        {posts?.map((post) => (\n          <Post\n            key={post.id}\n            id={post.id}\n            userId={post.user.id}\n            subscriptionStatus={post.user.subscriptionStatus}\n            name={post.user.name}\n            avatar={post.user.image}\n            createdAt={post.createdAt}\n            content={post.content}\n            likes={post.likes}\n            comments={post.comments}\n          />\n        ))}\n      </div>\n    </main>\n  );\n}\n"
  },
  {
    "path": "app/posts/Header.tsx",
    "content": "export default function Header() {\n  return (\n    <h1 className=\"font-bold text-5xl text-transparent bg-clip-text bg-gradient-to-r from-purple-500 via-pink-500 to-pink-500\">\n      Feed\n    </h1>\n  );\n}\n"
  },
  {
    "path": "app/posts/Post.tsx",
    "content": "\"use client\";\nimport { useSession } from \"next-auth/react\";\nimport { formatDate } from \"@/lib/utils\";\nimport {\n  Avatar,\n  Badge,\n  Button,\n  Card,\n  CardBody,\n  CardFooter,\n  CardHeader,\n  Modal,\n  ModalContent,\n  ModalFooter,\n  ModalHeader,\n  Spacer,\n  Spinner,\n  useDisclosure,\n} from \"@nextui-org/react\";\nimport { useRouter, useSelectedLayoutSegment } from \"next/navigation\";\nimport { useState } from \"react\";\nimport Link from \"next/link\";\nimport { Comment, Like, User } from \"@prisma/client\";\n\nconst HeartIcon = ({ fill, onClick }: { fill: boolean; onClick: Function }) => {\n  const [hover, setHover] = useState(false);\n  return (\n    <svg\n      style={{ cursor: \"pointer\" }}\n      width={24}\n      height={24}\n      viewBox=\"0 0 24 24\"\n      fill={fill ? \"#F31260\" : \"none\"}\n      xmlns=\"http://www.w3.org/2000/svg\"\n      onClick={() => onClick()}\n      onMouseEnter={() => setHover(true)}\n      onMouseLeave={() => setHover(false)}\n    >\n      <path\n        d=\"M12.62 20.81c-.34.12-.9.12-1.24 0C8.48 19.82 2 15.69 2 8.69 2 5.6 4.49 3.1 7.56 3.1c1.82 0 3.43.88 4.44 2.24a5.53 5.53 0 0 1 4.44-2.24C19.51 3.1 22 5.6 22 8.69c0 7-6.48 11.13-9.38 12.12Z\"\n        stroke={fill || hover ? \"#F31260\" : \"#9ba1a6\"}\n        strokeWidth={1.5}\n        strokeLinecap=\"round\"\n        strokeLinejoin=\"round\"\n      />\n    </svg>\n  );\n};\n\nconst DeleteIcon = ({ onClick }: { onClick: Function }) => {\n  const [hover, setHover] = useState(false);\n  return (\n    <svg\n      style={{ marginLeft: \"auto\", cursor: \"pointer\" }}\n      width={24}\n      height={24}\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      xmlns=\"http://www.w3.org/2000/svg\"\n      onClick={() => onClick()}\n      onMouseEnter={() => setHover(true)}\n      onMouseLeave={() => setHover(false)}\n    >\n      <path\n        fill-rule=\"evenodd\"\n        clip-rule=\"evenodd\"\n        d=\"M20.2871 5.24297C20.6761 5.24297 21 5.56596 21 5.97696V6.35696C21 6.75795 20.6761 7.09095 20.2871 7.09095H3.71385C3.32386 7.09095 3 6.75795 3 6.35696V5.97696C3 5.56596 3.32386 5.24297 3.71385 5.24297H6.62957C7.22185 5.24297 7.7373 4.82197 7.87054 4.22798L8.02323 3.54598C8.26054 2.61699 9.0415 2 9.93527 2H14.0647C14.9488 2 15.7385 2.61699 15.967 3.49699L16.1304 4.22698C16.2627 4.82197 16.7781 5.24297 17.3714 5.24297H20.2871ZM18.8058 19.134C19.1102 16.2971 19.6432 9.55712 19.6432 9.48913C19.6626 9.28313 19.5955 9.08813 19.4623 8.93113C19.3193 8.78413 19.1384 8.69713 18.9391 8.69713H5.06852C4.86818 8.69713 4.67756 8.78413 4.54529 8.93113C4.41108 9.08813 4.34494 9.28313 4.35467 9.48913C4.35646 9.50162 4.37558 9.73903 4.40755 10.1359C4.54958 11.8992 4.94517 16.8102 5.20079 19.134C5.38168 20.846 6.50498 21.922 8.13206 21.961C9.38763 21.99 10.6811 22 12.0038 22C13.2496 22 14.5149 21.99 15.8094 21.961C17.4929 21.932 18.6152 20.875 18.8058 19.134Z\"\n        fill=\"#200E32\"\n        stroke={hover ? \"#F31260\" : \"#9ba1a6\"}\n      />\n    </svg>\n  );\n};\n\nexport default function Post({\n  id,\n  userId,\n  subscriptionStatus,\n  name,\n  avatar,\n  createdAt,\n  content,\n  likes,\n  comments,\n}: {\n  id: string;\n  userId: string;\n  subscriptionStatus: string | null;\n  name: string | null;\n  avatar: string | null;\n  createdAt: string;\n  content: string;\n  likes: Like[];\n  comments: {\n    id: string;\n    user: User;\n    createdAt: string;\n    content: string;\n  }[];\n}) {\n  const { data: session } = useSession();\n  const { user } = session || {};\n  const isSubscribed = subscriptionStatus === \"active\";\n  const currentUserLiked =\n    (session && likes.some((like) => like.userId === user?.id)) || false;\n  const router = useRouter();\n  const [loading, setLoading] = useState(false);\n  const [deleteLoading, setDeleteLoading] = useState(false);\n  const { isOpen, onOpen, onOpenChange } = useDisclosure();\n  const segment = useSelectedLayoutSegment();\n\n  function linkify(text: string) {\n    const urlRegex = /(https?:\\/\\/[^\\s]+)/g;\n    const splitText = text.split(urlRegex);\n    const jsxElements = splitText.map((s, i) => {\n      if (s.match(urlRegex)) {\n        return (\n          <a href={s} target=\"_blank\" rel=\"noopener noreferrer\" key={i}>\n            {s}\n          </a>\n        );\n      }\n      return <span key={i}>{s}</span>;\n    });\n    return jsxElements;\n  }\n\n  const linkifiedContent = linkify(content);\n\n  const addLike = async (id: string) => {\n    setLoading(true);\n    try {\n      const res = await fetch(\"/api/addLike\", {\n        method: \"POST\",\n        headers: {\n          \"Content-Type\": \"application/json\",\n        },\n        body: JSON.stringify({\n          postId: id,\n        }),\n      });\n      if (res.ok) {\n        router.refresh();\n      }\n    } catch {\n      // console.log(\"Error liking post\");\n    }\n    setLoading(false);\n  };\n\n  const deletePost = async (postId: string, onClose: () => void) => {\n    setDeleteLoading(true);\n    try {\n      const res = await fetch(\"/api/deletePost\", {\n        method: \"DELETE\",\n        headers: {\n          \"Content-Type\": \"application/json\",\n        },\n        body: JSON.stringify({ postId }),\n      });\n\n      if (res.ok) {\n        onClose();\n      }\n    } catch (error) {\n      console.log(error);\n    }\n    setDeleteLoading(false);\n    segment === \"posts\" ? router.refresh() : router.push(\"/posts\"); // if on posts page, refresh, else redirect to posts page\n  };\n\n  return (\n    <>\n      <Card className=\"p-2 mt-4\">\n        <CardHeader>\n          {isSubscribed ? (\n            <Badge\n              disableOutline\n              content=\"PRO\"\n              size=\"md\"\n              color=\"primary\"\n              className=\"font-bold text-xs py-1 px-2\"\n            >\n              <Avatar\n                src={avatar || undefined}\n                color=\"primary\"\n                isBordered={userId === user?.id}\n              />\n            </Badge>\n          ) : (\n            <Avatar\n              src={avatar || undefined}\n              color=\"primary\"\n              isBordered={userId === user?.id}\n            />\n          )}\n          <Spacer x={0.5} />\n          <div className=\"pl-4\">\n            <div className=\"font-bold\">{name}</div>\n            <div className=\"text-small text-default-500\">\n              {formatDate(createdAt)}\n            </div>\n          </div>\n        </CardHeader>\n        <CardBody>\n          <p>{linkifiedContent}</p>\n        </CardBody>\n        <CardFooter>\n          <Link href={`/posts/${id}`}>\n            <p className=\"text-default-500\">\n              {comments.length} {comments.length === 1 ? \"comment\" : \"comments\"}\n            </p>\n          </Link>\n          <Spacer x={3} />\n          {loading ? (\n            <Spinner size=\"sm\" color=\"danger\" />\n          ) : (\n            <HeartIcon\n              fill={currentUserLiked}\n              onClick={() => session && addLike(id)}\n            />\n          )}\n          <Spacer x={0.5} />\n          <p className={currentUserLiked ? \"text-red-500\" : \"text-default-500\"}>\n            {likes.length}\n          </p>\n          {userId === user?.id && <DeleteIcon onClick={onOpen} />}\n        </CardFooter>\n      </Card>\n      <Spacer y={1} />\n\n      <Modal\n        closeButton\n        aria-labelledby=\"modal-title\"\n        isOpen={isOpen}\n        onOpenChange={onOpenChange}\n      >\n        <ModalContent>\n          {(onClose) => (\n            <>\n              <ModalHeader>\n                <p className=\"text-xl\" id=\"modal-title\">\n                  Are you sure you want to delete this post?\n                </p>\n              </ModalHeader>\n              <ModalFooter>\n                <Button variant=\"flat\" onClick={onClose}>\n                  Cancel\n                </Button>\n                <Button color=\"danger\" onClick={() => deletePost(id, onClose)}>\n                  {deleteLoading ? <Spinner size=\"sm\" /> : \"Delete\"}\n                </Button>\n              </ModalFooter>\n            </>\n          )}\n        </ModalContent>\n      </Modal>\n    </>\n  );\n}\n"
  },
  {
    "path": "app/posts/[postId]/AddComment.tsx",
    "content": "\"use client\";\nimport {\n  Button,\n  Popover,\n  PopoverContent,\n  PopoverTrigger,\n  Spacer,\n  Spinner,\n  Textarea,\n} from \"@nextui-org/react\";\nimport { useSession } from \"next-auth/react\";\nimport { useRouter } from \"next/navigation\";\nimport { useState } from \"react\";\nimport Filter from \"bad-words\";\n\nconst filter = new Filter();\n\nexport default function AddComment({\n  postId,\n}: {\n  postId: string;\n}): JSX.Element {\n  const { data: session } = useSession();\n  const [content, setContent] = useState(\"\");\n  const [loading, setLoading] = useState(false);\n  const [error, setError] = useState(false);\n  const [errorMessage, setErrorMessage] = useState(\"Error creating post.\");\n  const router = useRouter();\n\n  const handleSubmit = async (e: React.FormEvent) => {\n    e.preventDefault();\n    setLoading(true);\n    setError(false);\n\n    if (content.length < 1) {\n      setErrorMessage(\"Post cannot be empty.\");\n      setError(true);\n    } else if (filter.isProfane(content)) {\n      setErrorMessage(\"Profanity is not allowed.\");\n      setError(true);\n    } else {\n      try {\n        const filteredContent = filter.clean(content);\n        const res = await fetch(\"/api/addComment\", {\n          method: \"POST\",\n          headers: {\n            \"Content-Type\": \"application/json\",\n          },\n          body: JSON.stringify({\n            content: filteredContent,\n            postId: postId,\n          }),\n        });\n        if (res.ok) {\n          setContent(\"\");\n          router.refresh();\n        }\n        setError(false);\n      } catch {\n        setErrorMessage(\"Error creating comment.\");\n        setError(true);\n      }\n    }\n\n    setLoading(false);\n  };\n\n  return (\n    <form onSubmit={handleSubmit} style={{ width: \"100%\" }}>\n      <Spacer y={0.5} />\n      <Textarea\n        isInvalid={error}\n        errorMessage={error && errorMessage}\n        className=\"mt-6\"\n        size=\"lg\"\n        variant=\"bordered\"\n        labelPlacement=\"outside\"\n        isDisabled={!session}\n        width=\"100%\"\n        placeholder={session ? \"Comment here...\" : \"Please sign in to comment.\"}\n        value={content}\n        maxLength={300}\n        onChange={(e) => setContent(e.target.value)}\n      />\n      <Spacer y={0.5} />\n      <div className=\"row flex-wrap flex items-center\">\n        <Button\n          className=\"font-medium\"\n          color=\"primary\"\n          type=\"submit\"\n          isDisabled={!session}\n        >\n          {loading ? <Spinner size=\"sm\" /> : \"Comment\"}\n        </Button>\n\n        <p className=\"ml-auto\">{(content && content.length) || \"0\"}/300</p>\n      </div>\n\n      <Spacer y={1} />\n    </form>\n  );\n}\n"
  },
  {
    "path": "app/posts/[postId]/Comment.tsx",
    "content": "\"use client\";\nimport { formatDate } from \"@/lib/utils\";\nimport {\n  Avatar,\n  Badge,\n  Button,\n  Card,\n  CardBody,\n  CardFooter,\n  CardHeader,\n  Modal,\n  ModalContent,\n  ModalFooter,\n  ModalHeader,\n  Spacer,\n  Spinner,\n  useDisclosure,\n} from \"@nextui-org/react\";\nimport { useSession } from \"next-auth/react\";\nimport { useRouter } from \"next/navigation\";\nimport { useState } from \"react\";\n\nconst DeleteIcon = ({ onClick }: { onClick: Function }) => {\n  const [hover, setHover] = useState(false);\n  return (\n    <svg\n      style={{ marginLeft: \"auto\", cursor: \"pointer\" }}\n      width={24}\n      height={24}\n      viewBox=\"0 0 24 24\"\n      fill=\"none\"\n      xmlns=\"http://www.w3.org/2000/svg\"\n      onClick={() => onClick()}\n      onMouseEnter={() => setHover(true)}\n      onMouseLeave={() => setHover(false)}\n    >\n      <path\n        fill-rule=\"evenodd\"\n        clip-rule=\"evenodd\"\n        d=\"M20.2871 5.24297C20.6761 5.24297 21 5.56596 21 5.97696V6.35696C21 6.75795 20.6761 7.09095 20.2871 7.09095H3.71385C3.32386 7.09095 3 6.75795 3 6.35696V5.97696C3 5.56596 3.32386 5.24297 3.71385 5.24297H6.62957C7.22185 5.24297 7.7373 4.82197 7.87054 4.22798L8.02323 3.54598C8.26054 2.61699 9.0415 2 9.93527 2H14.0647C14.9488 2 15.7385 2.61699 15.967 3.49699L16.1304 4.22698C16.2627 4.82197 16.7781 5.24297 17.3714 5.24297H20.2871ZM18.8058 19.134C19.1102 16.2971 19.6432 9.55712 19.6432 9.48913C19.6626 9.28313 19.5955 9.08813 19.4623 8.93113C19.3193 8.78413 19.1384 8.69713 18.9391 8.69713H5.06852C4.86818 8.69713 4.67756 8.78413 4.54529 8.93113C4.41108 9.08813 4.34494 9.28313 4.35467 9.48913C4.35646 9.50162 4.37558 9.73903 4.40755 10.1359C4.54958 11.8992 4.94517 16.8102 5.20079 19.134C5.38168 20.846 6.50498 21.922 8.13206 21.961C9.38763 21.99 10.6811 22 12.0038 22C13.2496 22 14.5149 21.99 15.8094 21.961C17.4929 21.932 18.6152 20.875 18.8058 19.134Z\"\n        fill=\"#200E32\"\n        stroke={hover ? \"#F31260\" : \"#9ba1a6\"}\n      />\n    </svg>\n  );\n};\n\nexport default function Comment({\n  userId,\n  subscriptionStatus,\n  id,\n  name,\n  avatar,\n  createdAt,\n  content,\n}: {\n  userId: string;\n  subscriptionStatus: string | null;\n  id: string;\n  name: string | null;\n  avatar: string | null;\n  createdAt: string;\n  content: string;\n}) {\n  const { data: session } = useSession();\n  const { user } = session || {};\n  const isSubscribed = subscriptionStatus === \"active\";\n  const router = useRouter();\n  const [deleteLoading, setDeleteLoading] = useState(false);\n  const { isOpen, onOpen, onOpenChange } = useDisclosure();\n\n  function linkify(text: string) {\n    const urlRegex = /(https?:\\/\\/[^\\s]+)/g;\n    const splitText = text.split(urlRegex);\n    const jsxElements = splitText.map((s, i) => {\n      if (s.match(urlRegex)) {\n        return (\n          <a href={s} target=\"_blank\" rel=\"noopener noreferrer\" key={i}>\n            {s}\n          </a>\n        );\n      }\n      return <span key={i}>{s}</span>;\n    });\n    return jsxElements;\n  }\n\n  const linkifiedContent = linkify(content);\n\n  const deleteComment = async (commentId: string, onClose: () => void) => {\n    setDeleteLoading(true);\n    try {\n      const res = await fetch(\"/api/deleteComment\", {\n        method: \"DELETE\",\n        headers: {\n          \"Content-Type\": \"application/json\",\n        },\n        body: JSON.stringify({ commentId }),\n      });\n\n      if (res.ok) {\n        onClose();\n        router.refresh();\n      }\n    } catch (error) {\n      console.log(error);\n    }\n    setDeleteLoading(false);\n  };\n\n  return (\n    <>\n      <Card className=\"p-2 mt-4\">\n        <CardHeader>\n          {isSubscribed ? (\n            <Badge\n              disableOutline\n              content=\"PRO\"\n              size=\"md\"\n              color=\"primary\"\n              className=\"font-bold text-xs py-1 px-2\"\n            >\n              <Avatar\n                src={avatar || undefined}\n                color=\"primary\"\n                isBordered={userId === user?.id}\n              />\n            </Badge>\n          ) : (\n            <Avatar\n              src={avatar || undefined}\n              color=\"primary\"\n              isBordered={userId === user?.id}\n            />\n          )}\n          <Spacer x={0.5} />\n          <div className=\"pl-4\">\n            <div className=\"font-bold\">{name}</div>\n            <div className=\"text-small text-default-500\">\n              {formatDate(createdAt)}\n            </div>\n          </div>\n        </CardHeader>\n        <CardBody>\n          <p>{linkifiedContent}</p>\n        </CardBody>\n        {userId === user?.id && (\n          <CardFooter>\n            <DeleteIcon onClick={onOpen} />\n          </CardFooter>\n        )}\n      </Card>\n      <Spacer y={1} />\n\n      <Modal\n        closeButton\n        aria-labelledby=\"modal-title\"\n        isOpen={isOpen}\n        onOpenChange={onOpenChange}\n      >\n        <ModalContent>\n          {(onClose) => (\n            <>\n              <ModalHeader>\n                <p className=\"text-xl\" id=\"modal-title\">\n                  Are you sure you want to delete this comment?\n                </p>\n              </ModalHeader>\n              <ModalFooter>\n                <Button variant=\"flat\" onClick={onClose}>\n                  Cancel\n                </Button>\n                <Button\n                  className=\"font-medium\"\n                  color=\"danger\"\n                  onClick={() => deleteComment(id, onClose)}\n                >\n                  {deleteLoading ? <Spinner size=\"sm\" /> : \"Delete\"}\n                </Button>\n              </ModalFooter>\n            </>\n          )}\n        </ModalContent>\n      </Modal>\n    </>\n  );\n}\n"
  },
  {
    "path": "app/posts/[postId]/Header.tsx",
    "content": "export default function Header() {\n  return (\n    <h1 className=\"font-bold text-5xl text-transparent bg-clip-text bg-gradient-to-r from-purple-500 via-pink-500 to-pink-500\">\n      Thread\n    </h1>\n  );\n}\n"
  },
  {
    "path": "app/posts/[postId]/Thread.tsx",
    "content": "\"use client\";\nimport { Spacer } from \"@nextui-org/react\";\nimport Header from \"./Header\";\nimport Post from \"../Post\";\nimport Comment from \"./Comment\";\nimport AddComment from \"./AddComment\";\nimport { Comment as PrismaComment, Like, User } from \"@prisma/client\";\n\nexport default function Thread({\n  post,\n}: {\n  post: {\n    id: string;\n    content: string;\n    user: User;\n    createdAt: string;\n    likes: Like[];\n    comments: {\n      id: string;\n      user: User;\n      createdAt: string;\n      content: string;\n    }[];\n  };\n}) {\n  return (\n    <div className=\"container mx-auto px-6 sm:px-8 md:px-16 lg:px-20 max-w-3xl mt-6 items-center\">\n      <Spacer y={0.5} />\n      <Header />\n      <Post\n        key={post.id}\n        userId={post.user.id}\n        subscriptionStatus={post.user.subscriptionStatus}\n        id={post.id}\n        name={post.user.name}\n        avatar={post.user.image}\n        createdAt={post.createdAt}\n        content={post.content}\n        likes={post.likes}\n        comments={post.comments}\n      />\n      <AddComment postId={post.id} />\n      {post.comments?.map((comment) => (\n        <Comment\n          key={comment.id}\n          userId={comment.user.id}\n          subscriptionStatus={comment.user.subscriptionStatus}\n          id={comment.id}\n          name={comment.user.name}\n          avatar={comment.user.image}\n          createdAt={comment.createdAt}\n          content={comment.content}\n        />\n      ))}\n    </div>\n  );\n}\n"
  },
  {
    "path": "app/posts/[postId]/page.tsx",
    "content": "import { Comment, Like, User } from \"@prisma/client\";\nimport Thread from \"./Thread\";\n\nasync function getPost(postId: string) {\n  const res = await fetch(`${process.env.BASE_URL}/api/posts/${postId}`, {\n    cache: \"no-store\",\n  });\n  // console.log(res);\n  return res.json();\n}\n\nexport default async function PostDetails({\n  params,\n}: {\n  params: { postId: string };\n}) {\n  const data: {\n    id: string;\n    content: string;\n    user: User;\n    createdAt: string;\n    likes: Like[];\n    comments: {\n      id: string;\n      user: User;\n      createdAt: string;\n      content: string;\n    }[];\n  } | null = await getPost(params.postId);\n\n  if (data === null) {\n    // Handle the case where data is null, such as showing an error message\n    return (\n      <div className=\"flex justify-center items-center mt-16\">\n        Post not found.\n      </div>\n    );\n  }\n\n  return <Thread post={data} />;\n}\n"
  },
  {
    "path": "app/posts/layout.tsx",
    "content": "export const metadata = {\n  title: \"Feed | Next.js 14 Showcase\",\n};\n\nexport default function SubscribeLayout({\n  children,\n}: {\n  children: React.ReactNode;\n}) {\n  return <section>{children}</section>;\n}\n"
  },
  {
    "path": "app/posts/page.tsx",
    "content": "import { Comment, Like, User } from \"@prisma/client\";\nimport Feed from \"./Feed\";\n\nasync function getPosts() {\n  const res = await fetch(`${process.env.BASE_URL}/api/getPosts`, {\n    cache: \"no-store\",\n  });\n  // console.log(res);\n  return res.json();\n}\n\nexport default async function Posts() {\n  const data: {\n    id: string;\n    content: string;\n    user: User;\n    createdAt: string;\n    likes: Like[];\n    comments: {\n      id: string;\n      user: User;\n      createdAt: string;\n      content: string;\n    }[];\n  }[] = await getPosts();\n  // console.log(data);\n  return (\n    <main>\n      <Feed posts={data} />\n    </main>\n  );\n}\n"
  },
  {
    "path": "app/subscribe/layout.tsx",
    "content": "export const metadata = {\n  title: \"Subscribe | Next.js 14 Showcase\",\n};\n\nexport default function SubscribeLayout({\n  children,\n}: {\n  children: React.ReactNode;\n}) {\n  return <section>{children}</section>;\n}\n"
  },
  {
    "path": "app/subscribe/page.tsx",
    "content": "\"use client\";\nimport { Button, Card, CardFooter, CardHeader, Image } from \"@nextui-org/react\";\nimport { useSession } from \"next-auth/react\";\n\nexport default function Subscribe() {\n  const { data: session } = useSession();\n  const { user } = session || {};\n  const isSubscribed = user?.subscriptionStatus === \"active\" || false;\n\n  return (\n    <main>\n      <div className=\"container mx-auto px-6 sm:px-8 md:px-16 lg:px-20 max-w-6xl mt-6\">\n        <h1 className=\"text-6xl font-bold bg-gradient-to-r from-red-600 via-yellow-600 to-yellow-600 to-50% text-transparent bg-clip-text\">\n          Subscribe\n        </h1>\n\n        {isSubscribed ? (\n          <>\n            <h2 className=\"text-4xl mt-4\">You are already subscribed.</h2>\n            <div className=\"mt-4\">\n              <form action=\"/api/portal\" method=\"POST\">\n                <Button\n                  type=\"submit\"\n                  color=\"primary\"\n                  radius=\"full\"\n                  variant=\"flat\"\n                >\n                  Manage Subscription\n                </Button>\n              </form>\n            </div>\n          </>\n        ) : (\n          <Card\n            isFooterBlurred\n            className=\"w-full h-[400px] col-span-12 sm:col-span-7 mt-8\"\n          >\n            <CardHeader className=\"absolute z-10 top-1 flex-col items-start\">\n              <p className=\"text-tiny text-white/60 uppercase font-bold\">\n                Pro Plan\n              </p>\n              <h4 className=\"text-white/90 font-medium text-xl\">\n                Get unlimited posts and comments\n              </h4>\n              <h4 className=\"text-white/90 font-medium text-xl\">\n                PRO badge on your profile\n              </h4>\n            </CardHeader>\n            <Image\n              removeWrapper\n              src=\"https://images.pexels.com/photos/3975590/pexels-photo-3975590.jpeg\"\n              alt=\"Relaxing app background\"\n              className=\"z-0 w-full h-full object-cover\"\n            />\n            <CardFooter className=\"absolute bg-black/40 bottom-0 z-10 border-t-1 border-default-600 dark:border-default-100\">\n              <div className=\"flex flex-grow gap-2 items-center\">\n                <div className=\"flex flex-col\">\n                  <p className=\"text-tiny text-white/60\">Available now.</p>\n                  <p className=\"text-tiny text-white/60\">\n                    Use card 4242 4242 4242 4242 to test.\n                  </p>\n                </div>\n              </div>\n              <form action=\"/api/stripe\" method=\"POST\">\n                <Button\n                  radius=\"full\"\n                  variant=\"flat\"\n                  className=\"text-teal-200 bg-teal-400 bg-opacity-30\"\n                  type=\"submit\"\n                  isDisabled={isSubscribed || !session}\n                >\n                  <span className=\"text-sm font-semibold uppercase\">\n                    {session ? \"Subscribe Now\" : \"Sign in to Subscribe\"}\n                  </span>\n                </Button>\n              </form>\n            </CardFooter>\n          </Card>\n        )}\n      </div>\n    </main>\n  );\n}\n"
  },
  {
    "path": "app/subscribe/success/page.tsx",
    "content": "export default function Success() {\n  return (\n    <main>\n      <div className=\"container mx-auto px-6 sm:px-8 md:px-16 lg:px-20 max-w-6xl mt-6\">\n        <h1 className=\"text-6xl font-bold bg-gradient-to-r from-red-600 via-yellow-600 to-yellow-600 to-50% text-transparent bg-clip-text\">\n          Success!\n        </h1>\n        <h2 className=\"text-4xl mt-4\">\n          You have successfully subscribed to the Pro Plan.\n        </h2>\n      </div>\n    </main>\n  );\n}\n"
  },
  {
    "path": "lib/openai.ts",
    "content": "import OpenAI from \"openai\";\n\nconst openai = new OpenAI({\n    apiKey: process.env.OPENAI_API_KEY,\n});\n\nexport default openai;"
  },
  {
    "path": "lib/posts.ts",
    "content": "import prisma from \"./prisma\";\n\nexport const getAllPosts = async () => {\n  const posts = await prisma.post.findMany({\n    include: {\n      user: true,\n      likes: true,\n      comments: true,\n    },\n    orderBy: {\n      createdAt: \"desc\",\n    },\n  });\n  return posts;\n};\n\nexport const getSinglePost = async (id: string) => {\n  const post = await prisma.post.findUnique({\n    where: {\n      id: id,\n    },\n    include: {\n      user: true,\n      likes: true,\n      comments: {\n        orderBy: {\n          createdAt: \"desc\",\n        },\n        include: {\n          user: true,\n        },\n      },\n    },\n  });\n  return post;\n};\n"
  },
  {
    "path": "lib/prisma.ts",
    "content": "import { PrismaClient } from \"@prisma/client\";\n\ndeclare global {\n  var cachedPrisma: PrismaClient;\n}\n\nlet prisma: PrismaClient;\n\nif (process.env.NODE_ENV === \"production\") {\n  prisma = new PrismaClient();\n} else {\n  if (!global.cachedPrisma) {\n    global.cachedPrisma = new PrismaClient();\n  }\n  prisma = global.cachedPrisma;\n}\n\nexport default prisma;\n"
  },
  {
    "path": "lib/stripe.ts",
    "content": "import Stripe from \"stripe\";\n\nconst stripe = new Stripe(process.env.STRIPE_API_KEY as string, {\n  apiVersion: \"2022-11-15\",\n  typescript: true,\n});\n\nexport default stripe;"
  },
  {
    "path": "lib/utils.ts",
    "content": "export function formatDate(input: string | number): string {\n    const date = new Date(input)\n    return date.toLocaleString(\"en-US\", {\n      month: \"long\",\n      day: \"numeric\",\n      year: \"numeric\",\n      hour: \"numeric\",\n      minute: \"numeric\",\n    })\n  }"
  },
  {
    "path": "next.config.js",
    "content": "/** @type {import('next').NextConfig} */\nconst nextConfig = {\n  images: {\n    domains: [\"lh3.googleusercontent.com\", \"avatars.githubusercontent.com\"],\n  },\n};\n\nmodule.exports = nextConfig;\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"next-app\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"scripts\": {\n    \"dev\": \"next dev\",\n    \"build\": \"next build\",\n    \"start\": \"next start\",\n    \"lint\": \"next lint\",\n    \"migrate:dev\": \"npx dotenv -e .env.local -- prisma migrate dev\",\n    \"db:push\": \"npx dotenv -e .env.local -- prisma db push\",\n    \"migrate:reset\": \"npx dotenv -e .env.local -- prisma migrate reset\",\n    \"db:seed\": \"npx dotenv -e .env.local -- prisma db seed\",\n    \"prisma:generate\": \"npx dotenv -e .env.local -- prisma generate\",\n    \"prisma:studio\": \"npx dotenv -e .env.local -- prisma studio\",\n    \"production:build\": \"npx prisma generate && npx prisma migrate deploy && next build\",\n    \"stripe:listen\": \"stripe listen --forward-to localhost:3000/api/webhook/stripe\"\n  },\n  \"dependencies\": {\n    \"@next-auth/prisma-adapter\": \"^1.0.7\",\n    \"@nextui-org/react\": \"^2.3.6\",\n    \"@prisma/client\": \"^5.14.0\",\n    \"@types/node\": \"^20.12.12\",\n    \"@types/react\": \"^18.3.2\",\n    \"@types/react-dom\": \"^18.3.0\",\n    \"bad-words\": \"^3.0.4\",\n    \"eslint\": \"8.34.0\",\n    \"eslint-config-next\": \"^13.4.13\",\n    \"framer-motion\": \"^10.15.0\",\n    \"next\": \"^14.2.3\",\n    \"next-auth\": \"^4.24.7\",\n    \"next-themes\": \"^0.3.0\",\n    \"openai\": \"^4.47.1\",\n    \"raw-body\": \"^2.5.2\",\n    \"react\": \"^18.3.1\",\n    \"react-dom\": \"^18.2.0\",\n    \"stripe\": \"^12.2.0\",\n    \"typescript\": \"^5.4.5\"\n  },\n  \"devDependencies\": {\n    \"@types/bad-words\": \"^3.0.1\",\n    \"autoprefixer\": \"^10.4.14\",\n    \"dotenv-cli\": \"^7.0.0\",\n    \"postcss\": \"^8.4.27\",\n    \"prisma\": \"^4.10.1\",\n    \"tailwindcss\": \"^3.3.3\"\n  }\n}\n"
  },
  {
    "path": "pages/api/addComment.ts",
    "content": "import { NextApiRequest, NextApiResponse } from \"next\";\nimport { getServerSession } from \"next-auth/next\";\nimport prisma from \"@/lib/prisma\";\nimport { authOptions } from \"./auth/[...nextauth]\";\n\nexport default async function handler(\n  req: NextApiRequest,\n  res: NextApiResponse\n) {\n  const session = await getServerSession(req, res, authOptions);\n  if (!session) {\n    return res\n      .status(401)\n      .json({ message: \"Please sign in to create a comment.\" });\n  }\n\n  const { user } = session;\n  const { postId, content } = req.body;\n  // Get user from database\n  const prismaUser = await prisma.user.findUnique({\n    where: { email: session?.user?.email || undefined },\n  });\n\n  // Create comment\n  try {\n    const body = req.body;\n\n    const result = await prisma.comment.create({\n      data: {\n        content: content as string,\n        postId: postId as string,\n        userId: prismaUser?.id as string,\n      },\n    });\n\n    return res.json(result);\n  } catch (err) {\n    // console.log(err);\n    res.status(402).json({ err: \"Error has occured while making a comment\" });\n  }\n}\n"
  },
  {
    "path": "pages/api/addLike.ts",
    "content": "import { NextApiRequest, NextApiResponse } from \"next\";\nimport { getServerSession } from \"next-auth/next\";\nimport prisma from \"@/lib/prisma\";\nimport { authOptions } from \"./auth/[...nextauth]\";\n\nexport default async function handler(\n  req: NextApiRequest,\n  res: NextApiResponse\n) {\n  const session = await getServerSession(req, res, authOptions);\n  if (!session) {\n    return res\n      .status(401)\n      .json({ message: \"Please sign in to create a post.\" });\n  }\n\n  const { postId } = req.body;\n  // Get user from database\n  const prismaUser = await prisma.user.findUnique({\n    where: { email: session?.user?.email || undefined },\n  });\n\n  // Check if user has already liked the post\n  const alreadyLiked = await prisma.like.findFirst({\n    where: {\n      postId: postId as string,\n      userId: prismaUser?.id as string,\n    },\n  });\n\n  // Create like\n  try {\n    if (!alreadyLiked) {\n      // Create like if user has not liked the post\n      const result = await prisma.like.create({\n        data: {\n          postId: postId as string,\n          userId: prismaUser?.id as string,\n        },\n      });\n\n      return res.status(200).json(result);\n    } else {\n      // Delete like if user has already liked the post\n      const result = await prisma.like.delete({\n        where: {\n          id: alreadyLiked.id,\n        },\n      });\n\n      return res.status(201).json(result);\n    }\n  } catch (err) {\n    // console.log(err);\n    res\n      .status(402)\n      .json({ err: \"Error has occured while trying to like post\" });\n  }\n}\n"
  },
  {
    "path": "pages/api/addPost.ts",
    "content": "import { NextApiRequest, NextApiResponse } from \"next\";\nimport { getServerSession } from \"next-auth/next\";\nimport prisma from \"@/lib/prisma\";\nimport { authOptions } from \"./auth/[...nextauth]\";\n\nexport default async function handler(\n  req: NextApiRequest,\n  res: NextApiResponse\n) {\n  const session = await getServerSession(req, res, authOptions);\n  if (!session) {\n    return res\n      .status(401)\n      .json({ message: \"Please sign in to create a post.\" });\n  }\n\n  const { user } = session;\n  const { content } = req.body;\n  // Get user from database\n  const prismaUser = await prisma.user.findUnique({\n    where: { email: session?.user?.email || undefined },\n  });\n\n  // Create post\n  try {\n    const body = req.body;\n\n    const result = await prisma.post.create({\n      data: {\n        content: content as string,\n        userId: prismaUser?.id as string,\n      },\n    });\n\n    return res.json(result);\n  } catch (err) {\n    // console.log(err);\n    res.status(402).json({ err: \"Error has occured while making a post\" });\n  }\n}\n"
  },
  {
    "path": "pages/api/auth/[...nextauth].ts",
    "content": "import NextAuth from \"next-auth\";\nimport type { NextAuthOptions } from \"next-auth\";\nimport GithubProvider from \"next-auth/providers/github\";\nimport GoogleProvider from \"next-auth/providers/google\";\nimport DiscordProvider from \"next-auth/providers/discord\";\nimport { PrismaAdapter } from \"@next-auth/prisma-adapter\";\nimport prisma from \"../../../lib/prisma\";\n\nexport const authOptions: NextAuthOptions = {\n  adapter: PrismaAdapter(prisma),\n  secret: process.env.NEXTAUTH_SECRET,\n  providers: [\n    GithubProvider({\n      clientId: process.env.GITHUB_ID as string,\n      clientSecret: process.env.GITHUB_SECRET as string,\n    }),\n    GoogleProvider({\n      clientId: process.env.GOOGLE_CLIENT_ID as string,\n      clientSecret: process.env.GOOGLE_CLIENT_SECRET as string,\n    }),\n    DiscordProvider({\n      clientId: process.env.DISCORD_CLIENT_ID as string,\n      clientSecret: process.env.DISCORD_CLIENT_SECRET as string\n    })\n    // ...add more providers here\n  ],\n  callbacks: {\n    session: async ({ session, token, user }) => {\n      if (session?.user) {\n        session.user.id = user.id;\n      }\n      const userData = await fetch(`${process.env.NEXTAUTH_URL}/api/user?userId=${user.id}`).then(response => response.json());\n      session.user.subscriptionStatus = userData.subscriptionStatus;\n      return session;\n    },\n  },\n};\n\nexport default NextAuth(authOptions);\n"
  },
  {
    "path": "pages/api/auth/nextauth.d.ts",
    "content": "import NextAuth from 'next-auth';\n\ndeclare module 'next-auth' {\n  interface Session {\n    user: {\n      id: string;\n    } & DefaultSession['user'];\n  }\n}"
  },
  {
    "path": "pages/api/deleteComment.ts",
    "content": "import { NextApiRequest, NextApiResponse } from \"next\";\nimport { getServerSession } from \"next-auth/next\";\nimport prisma from \"@/lib/prisma\";\nimport { authOptions } from \"./auth/[...nextauth]\";\n\nexport default async function handler(\n  req: NextApiRequest,\n  res: NextApiResponse\n) {\n  const session = await getServerSession(req, res, authOptions);\n  if (!session) {\n    return res\n      .status(401)\n      .json({ message: \"Please sign in to delete a comment.\" });\n  }\n\n  const { user } = session;\n  const { commentId } = req.body;\n\n  try {\n    const comment = await prisma.comment.findUnique({\n      where: { id: commentId as string },\n      select: { userId: true },\n    });\n    if (!comment) {\n      res.status(404).json({ message: \"Comment not found\" });\n      return;\n    }\n    if (comment.userId !== user.id) {\n      res.status(403).json({ message: \"Forbidden\" });\n      return;\n    }\n\n    const result = await prisma.comment.delete({\n      where: {\n        id: commentId as string,\n      },\n    });\n\n    return res.json(result);\n  } catch (err) {\n    // console.log(err);\n    res.status(402).json({ err: \"Error has occured while deleting a comment\" });\n  }\n}\n"
  },
  {
    "path": "pages/api/deletePost.ts",
    "content": "import { NextApiRequest, NextApiResponse } from \"next\";\nimport { getServerSession } from \"next-auth/next\";\nimport prisma from \"@/lib/prisma\";\nimport { authOptions } from \"./auth/[...nextauth]\";\n\nexport default async function handler(\n  req: NextApiRequest,\n  res: NextApiResponse\n) {\n  const session = await getServerSession(req, res, authOptions);\n  if (!session) {\n    return res\n      .status(401)\n      .json({ message: \"Please sign in to delete a post.\" });\n  }\n\n  const { user } = session;\n  const { postId } = req.body;\n\n  // Create post\n  try {\n    const post = await prisma.post.findUnique({\n      where: { id: postId as string },\n      select: { userId: true },\n    });\n    if (!post) {\n      res.status(404).json({ message: \"Post not found\" });\n      return;\n    }\n    if (post.userId !== user.id) {\n      res.status(403).json({ message: \"Forbidden\" });\n      return;\n    }\n\n    const result = await prisma.post.delete({\n      where: {\n        id: postId as string,\n      },\n    });\n\n    return res.json(result);\n  } catch (err) {\n    // console.log(err);\n    res.status(402).json({ err: \"Error has occured while deleting a post\" });\n  }\n}\n"
  },
  {
    "path": "pages/api/getPosts.ts",
    "content": "import { NextApiRequest, NextApiResponse } from \"next\";\nimport prisma from \"@/lib/prisma\";\n\nexport default async function handler(\n  req: NextApiRequest,\n  res: NextApiResponse\n) {\n  try {\n    const data = await prisma.post.findMany({\n      include: {\n        user: true,\n        likes: true,\n        comments: true,\n      },\n      orderBy: {\n        createdAt: \"desc\",\n      },\n    });\n    return res.status(200).json(data);\n  } catch (error) {\n    res.status(403).json({ err: \"Error has occured while fetching posts\" })\n  }\n}\n"
  },
  {
    "path": "pages/api/posts/[postId].ts",
    "content": "import { NextApiRequest, NextApiResponse } from \"next\";\nimport prisma from \"@/lib/prisma\";\n\nexport default async function handler(\n  req: NextApiRequest,\n  res: NextApiResponse\n) {\n  if (req.method === \"GET\") {\n    try {\n      const data = await prisma.post.findUnique({\n        where: {\n          id: req.query.postId as string,\n        },\n        include: {\n          user: true,\n          likes: true,\n          comments: {\n            orderBy: {\n              createdAt: \"desc\",\n            },\n            include: {\n              user: true,\n            },\n          },\n        },\n      });\n      return res.status(200).json(data);\n    } catch (err) {\n      res\n        .status(403)\n        .json({ err: \"Error has occured while getting post details\" });\n    }\n  }\n}\n"
  },
  {
    "path": "pages/api/user.ts",
    "content": "import { NextApiRequest, NextApiResponse } from \"next\";\nimport prisma from \"@/lib/prisma\";\n\nexport default async function handler(\n  req: NextApiRequest,\n  res: NextApiResponse\n) {\n  const userId = req.query.userId;\n  const user = await prisma.user.findUnique({\n    where: { id: userId as string },\n  });\n\n  // Return user data, including the subscription status, in the response\n  res.status(200).json({\n    id: user?.id,\n    email: user?.email,\n    subscriptionStatus: user?.subscriptionStatus || \"none\",\n  });\n}\n"
  },
  {
    "path": "pages/api/webhook/stripe.ts",
    "content": "import Stripe from \"stripe\";\nimport stripe from \"@/lib/stripe\";\nimport prisma from \"@/lib/prisma\";\nimport { NextApiRequest, NextApiResponse } from \"next\";\nimport getRawBody from \"raw-body\";\n\nexport const config = {\n  api: {\n    bodyParser: false,\n  },\n};\n\nexport default async function handler(\n  req: NextApiRequest,\n  res: NextApiResponse\n) {\n  const rawBody = await getRawBody(req);\n  const signature = req.headers[\"stripe-signature\"] as string;\n\n  let event: Stripe.Event;\n\n  try {\n    event = stripe.webhooks.constructEvent(\n      rawBody,\n      signature,\n      process.env.STRIPE_WEBHOOK_SECRET as string\n    );\n  } catch (error) {\n    console.log(error);\n    return res.status(400).send(\"Webhook signature verification failed.\");\n  }\n\n  const stripeSession = event.data.object as Stripe.Checkout.Session;\n\n  console.log(\n    \"stripeSessionClientReferenceId\",\n    stripeSession.client_reference_id\n  );\n\n  // Sent when a customer clicks the Pay or Subscribe button in Checkout, informing you of a new purchase.\n  if (event.type === \"checkout.session.completed\") {\n    // Retrieve the subscription details from Stripe.\n    const subscription = await stripe.subscriptions.retrieve(\n      stripeSession.subscription as string\n    );\n\n    // Update the user stripe into in our database.\n    // Since this is the initial subscription, we need to update\n    // the subscription id and customer id.\n    await prisma.user.update({\n      where: {\n        id: stripeSession?.client_reference_id ?? \"\",\n      },\n      data: {\n        subscriptionId: subscription.id,\n        stripeCustomerId: subscription.customer as string,\n        subscriptionStatus: subscription.status,\n      },\n    });\n  }\n\n  // Sent each billing interval when a payment succeeds.\n  if (event.type === \"invoice.paid\") {\n    // Retrieve the subscription details from Stripe.\n    const subscription = await stripe.subscriptions.retrieve(\n      stripeSession.subscription as string\n    );\n\n    await prisma.user.update({\n      where: {\n        subscriptionId: subscription.id,\n      },\n      data: {\n        subscriptionStatus: subscription.status,\n      },\n    });\n  }\n\n  // Sent each billing interval if there is an issue with your customer’s payment method.\n  if (event.type === \"invoice.payment_failed\") {\n    // Retrieve the subscription details from Stripe.\n    const subscription = await stripe.subscriptions.retrieve(\n      stripeSession.subscription as string\n    );\n\n    await prisma.user.update({\n      where: {\n        subscriptionId: subscription.id,\n      },\n      data: {\n        subscriptionStatus: subscription.status,\n      },\n    });\n  }\n\n  return res.status(200).end();\n}\n"
  },
  {
    "path": "postcss.config.js",
    "content": "module.exports = {\n  plugins: {\n    tailwindcss: {},\n    autoprefixer: {},\n  },\n}\n"
  },
  {
    "path": "prisma/migrations/20230224223753_add_user_and_post_models/migration.sql",
    "content": "-- CreateTable\nCREATE TABLE \"User\" (\n    \"id\" SERIAL NOT NULL,\n    \"email\" TEXT NOT NULL,\n    \"name\" TEXT,\n\n    CONSTRAINT \"User_pkey\" PRIMARY KEY (\"id\")\n);\n\n-- CreateTable\nCREATE TABLE \"Post\" (\n    \"id\" SERIAL NOT NULL,\n    \"title\" TEXT NOT NULL,\n    \"content\" TEXT,\n    \"published\" BOOLEAN NOT NULL DEFAULT false,\n    \"authorId\" INTEGER NOT NULL,\n\n    CONSTRAINT \"Post_pkey\" PRIMARY KEY (\"id\")\n);\n\n-- CreateIndex\nCREATE UNIQUE INDEX \"User_email_key\" ON \"User\"(\"email\");\n\n-- AddForeignKey\nALTER TABLE \"Post\" ADD CONSTRAINT \"Post_authorId_fkey\" FOREIGN KEY (\"authorId\") REFERENCES \"User\"(\"id\") ON DELETE RESTRICT ON UPDATE CASCADE;\n"
  },
  {
    "path": "prisma/migrations/20230225062901_add_next_auth_js_models/migration.sql",
    "content": "/*\n  Warnings:\n\n  - The primary key for the `User` table will be changed. If it partially fails, the table could be left without primary key constraint.\n\n*/\n-- DropForeignKey\nALTER TABLE \"Post\" DROP CONSTRAINT \"Post_authorId_fkey\";\n\n-- AlterTable\nALTER TABLE \"Post\" ALTER COLUMN \"authorId\" SET DATA TYPE TEXT;\n\n-- AlterTable\nALTER TABLE \"User\" DROP CONSTRAINT \"User_pkey\",\nADD COLUMN     \"emailVerified\" TIMESTAMP(3),\nADD COLUMN     \"image\" TEXT,\nALTER COLUMN \"id\" DROP DEFAULT,\nALTER COLUMN \"id\" SET DATA TYPE TEXT,\nALTER COLUMN \"email\" DROP NOT NULL,\nADD CONSTRAINT \"User_pkey\" PRIMARY KEY (\"id\");\nDROP SEQUENCE \"User_id_seq\";\n\n-- CreateTable\nCREATE TABLE \"Account\" (\n    \"id\" TEXT NOT NULL,\n    \"userId\" TEXT NOT NULL,\n    \"type\" TEXT NOT NULL,\n    \"provider\" TEXT NOT NULL,\n    \"providerAccountId\" TEXT NOT NULL,\n    \"refresh_token\" TEXT,\n    \"access_token\" TEXT,\n    \"expires_at\" INTEGER,\n    \"token_type\" TEXT,\n    \"scope\" TEXT,\n    \"id_token\" TEXT,\n    \"session_state\" TEXT,\n\n    CONSTRAINT \"Account_pkey\" PRIMARY KEY (\"id\")\n);\n\n-- CreateTable\nCREATE TABLE \"Session\" (\n    \"id\" TEXT NOT NULL,\n    \"sessionToken\" TEXT NOT NULL,\n    \"userId\" TEXT NOT NULL,\n    \"expires\" TIMESTAMP(3) NOT NULL,\n\n    CONSTRAINT \"Session_pkey\" PRIMARY KEY (\"id\")\n);\n\n-- CreateTable\nCREATE TABLE \"VerificationToken\" (\n    \"identifier\" TEXT NOT NULL,\n    \"token\" TEXT NOT NULL,\n    \"expires\" TIMESTAMP(3) NOT NULL\n);\n\n-- CreateIndex\nCREATE UNIQUE INDEX \"Account_provider_providerAccountId_key\" ON \"Account\"(\"provider\", \"providerAccountId\");\n\n-- CreateIndex\nCREATE UNIQUE INDEX \"Session_sessionToken_key\" ON \"Session\"(\"sessionToken\");\n\n-- CreateIndex\nCREATE UNIQUE INDEX \"VerificationToken_token_key\" ON \"VerificationToken\"(\"token\");\n\n-- CreateIndex\nCREATE UNIQUE INDEX \"VerificationToken_identifier_token_key\" ON \"VerificationToken\"(\"identifier\", \"token\");\n\n-- AddForeignKey\nALTER TABLE \"Account\" ADD CONSTRAINT \"Account_userId_fkey\" FOREIGN KEY (\"userId\") REFERENCES \"User\"(\"id\") ON DELETE CASCADE ON UPDATE CASCADE;\n\n-- AddForeignKey\nALTER TABLE \"Session\" ADD CONSTRAINT \"Session_userId_fkey\" FOREIGN KEY (\"userId\") REFERENCES \"User\"(\"id\") ON DELETE CASCADE ON UPDATE CASCADE;\n\n-- AddForeignKey\nALTER TABLE \"Post\" ADD CONSTRAINT \"Post_authorId_fkey\" FOREIGN KEY (\"authorId\") REFERENCES \"User\"(\"id\") ON DELETE RESTRICT ON UPDATE CASCADE;\n"
  },
  {
    "path": "prisma/migrations/20230226222646_posts_likes_comments/migration.sql",
    "content": "/*\n  Warnings:\n\n  - The primary key for the `Post` table will be changed. If it partially fails, the table could be left without primary key constraint.\n  - You are about to drop the column `authorId` on the `Post` table. All the data in the column will be lost.\n  - You are about to drop the column `title` on the `Post` table. All the data in the column will be lost.\n  - Added the required column `updatedAt` to the `Post` table without a default value. This is not possible if the table is not empty.\n  - Added the required column `userId` to the `Post` table without a default value. This is not possible if the table is not empty.\n  - Made the column `content` on table `Post` required. This step will fail if there are existing NULL values in that column.\n\n*/\n-- DropForeignKey\nALTER TABLE \"Post\" DROP CONSTRAINT \"Post_authorId_fkey\";\n\n-- AlterTable\nALTER TABLE \"Post\" DROP CONSTRAINT \"Post_pkey\",\nDROP COLUMN \"authorId\",\nDROP COLUMN \"title\",\nADD COLUMN     \"createdAt\" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,\nADD COLUMN     \"updatedAt\" TIMESTAMP(3) NOT NULL,\nADD COLUMN     \"userId\" TEXT NOT NULL,\nALTER COLUMN \"id\" DROP DEFAULT,\nALTER COLUMN \"id\" SET DATA TYPE TEXT,\nALTER COLUMN \"content\" SET NOT NULL,\nADD CONSTRAINT \"Post_pkey\" PRIMARY KEY (\"id\");\nDROP SEQUENCE \"Post_id_seq\";\n\n-- CreateTable\nCREATE TABLE \"Like\" (\n    \"id\" TEXT NOT NULL,\n    \"postId\" TEXT NOT NULL,\n    \"userId\" TEXT NOT NULL,\n\n    CONSTRAINT \"Like_pkey\" PRIMARY KEY (\"id\")\n);\n\n-- CreateTable\nCREATE TABLE \"Comment\" (\n    \"id\" TEXT NOT NULL,\n    \"title\" TEXT NOT NULL,\n    \"postId\" TEXT NOT NULL,\n    \"userId\" TEXT NOT NULL,\n    \"createdAt\" TIMESTAMP(3) NOT NULL DEFAULT CURRENT_TIMESTAMP,\n\n    CONSTRAINT \"Comment_pkey\" PRIMARY KEY (\"id\")\n);\n\n-- AddForeignKey\nALTER TABLE \"Post\" ADD CONSTRAINT \"Post_userId_fkey\" FOREIGN KEY (\"userId\") REFERENCES \"User\"(\"id\") ON DELETE RESTRICT ON UPDATE CASCADE;\n\n-- AddForeignKey\nALTER TABLE \"Like\" ADD CONSTRAINT \"Like_postId_fkey\" FOREIGN KEY (\"postId\") REFERENCES \"Post\"(\"id\") ON DELETE CASCADE ON UPDATE CASCADE;\n\n-- AddForeignKey\nALTER TABLE \"Like\" ADD CONSTRAINT \"Like_userId_fkey\" FOREIGN KEY (\"userId\") REFERENCES \"User\"(\"id\") ON DELETE CASCADE ON UPDATE CASCADE;\n\n-- AddForeignKey\nALTER TABLE \"Comment\" ADD CONSTRAINT \"Comment_postId_fkey\" FOREIGN KEY (\"postId\") REFERENCES \"Post\"(\"id\") ON DELETE CASCADE ON UPDATE CASCADE;\n\n-- AddForeignKey\nALTER TABLE \"Comment\" ADD CONSTRAINT \"Comment_userId_fkey\" FOREIGN KEY (\"userId\") REFERENCES \"User\"(\"id\") ON DELETE RESTRICT ON UPDATE CASCADE;\n"
  },
  {
    "path": "prisma/migrations/20230305195951_change_comment_title_to_content/migration.sql",
    "content": "/*\n  Warnings:\n\n  - You are about to drop the column `title` on the `Comment` table. All the data in the column will be lost.\n  - Added the required column `content` to the `Comment` table without a default value. This is not possible if the table is not empty.\n\n*/\n-- AlterTable\nALTER TABLE \"Comment\" DROP COLUMN \"title\",\nADD COLUMN     \"content\" TEXT NOT NULL;\n"
  },
  {
    "path": "prisma/migrations/20230424232141_stripe/migration.sql",
    "content": "-- AlterTable\nALTER TABLE \"User\" ADD COLUMN     \"stripeCustomerId\" TEXT,\nADD COLUMN     \"subscriptionId\" TEXT,\nADD COLUMN     \"subscriptionStatus\" TEXT;\n"
  },
  {
    "path": "prisma/migrations/20230425043110_stripe_i_ds_unique/migration.sql",
    "content": "/*\n  Warnings:\n\n  - A unique constraint covering the columns `[stripeCustomerId]` on the table `User` will be added. If there are existing duplicate values, this will fail.\n  - A unique constraint covering the columns `[subscriptionId]` on the table `User` will be added. If there are existing duplicate values, this will fail.\n\n*/\n-- CreateIndex\nCREATE UNIQUE INDEX \"User_stripeCustomerId_key\" ON \"User\"(\"stripeCustomerId\");\n\n-- CreateIndex\nCREATE UNIQUE INDEX \"User_subscriptionId_key\" ON \"User\"(\"subscriptionId\");\n"
  },
  {
    "path": "prisma/migrations/migration_lock.toml",
    "content": "# Please do not edit this file manually\n# It should be added in your version-control system (i.e. Git)\nprovider = \"postgresql\""
  },
  {
    "path": "prisma/schema.prisma",
    "content": "// This is your Prisma schema file,\n// learn more about it in the docs: https://pris.ly/d/prisma-schema\n\ngenerator client {\n  provider = \"prisma-client-js\"\n}\n\ndatasource db {\n  provider = \"postgresql\"\n  url      = env(\"DATABASE_URL\")\n}\n\nmodel Account {\n  id                String  @id @default(cuid())\n  userId            String\n  type              String\n  provider          String\n  providerAccountId String\n  refresh_token     String? @db.Text\n  access_token      String? @db.Text\n  expires_at        Int?\n  token_type        String?\n  scope             String?\n  id_token          String? @db.Text\n  session_state     String?\n\n  user User @relation(fields: [userId], references: [id], onDelete: Cascade)\n\n  @@unique([provider, providerAccountId])\n}\n\nmodel Session {\n  id           String   @id @default(cuid())\n  sessionToken String   @unique\n  userId       String\n  expires      DateTime\n  user         User     @relation(fields: [userId], references: [id], onDelete: Cascade)\n}\n\nmodel User {\n  id                 String    @id @default(cuid())\n  stripeCustomerId   String?   @unique\n  subscriptionId     String?   @unique\n  subscriptionStatus String?\n  name               String?\n  email              String?   @unique\n  emailVerified      DateTime?\n  image              String?\n  posts              Post[]\n  comments           Comment[]\n  likes              Like[]\n  accounts           Account[]\n  sessions           Session[]\n}\n\nmodel VerificationToken {\n  identifier String\n  token      String   @unique\n  expires    DateTime\n\n  @@unique([identifier, token])\n}\n\nmodel Post {\n  id        String    @id @default(cuid())\n  createdAt DateTime  @default(now())\n  updatedAt DateTime  @updatedAt\n  content   String\n  published Boolean   @default(false)\n  user      User      @relation(fields: [userId], references: [id])\n  userId    String\n  comments  Comment[]\n  likes     Like[]\n}\n\nmodel Like {\n  id     String @id @default(cuid())\n  postId String\n  userId String\n  post   Post   @relation(fields: [postId], references: [id], onDelete: Cascade)\n  user   User   @relation(fields: [userId], references: [id], onDelete: Cascade)\n}\n\nmodel Comment {\n  id        String   @id @default(cuid())\n  post      Post     @relation(fields: [postId], references: [id], onDelete: Cascade)\n  user      User     @relation(fields: [userId], references: [id])\n  content   String\n  postId    String\n  userId    String\n  createdAt DateTime @default(now())\n}\n"
  },
  {
    "path": "tailwind.config.js",
    "content": "// tailwind.config.js\nconst { nextui } = require(\"@nextui-org/react\");\n\n/** @type {import('tailwindcss').Config} */\nmodule.exports = {\n  content: [\n    \"./app/**/*.{js,ts,jsx,tsx,mdx}\",\n    \"./pages/**/*.{js,ts,jsx,tsx,mdx}\",\n    \"./components/**/*.{js,ts,jsx,tsx,mdx}\",\n\n    // Or if using `src` directory:\n    \"./src/**/*.{js,ts,jsx,tsx,mdx}\",\n    \"./node_modules/@nextui-org/theme/dist/**/*.{js,ts,jsx,tsx}\",\n  ],\n  theme: {\n    extend: {},\n  },\n  darkMode: \"class\",\n  plugins: [nextui()],\n};\n"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    \"target\": \"es5\",\n    \"lib\": [\"dom\", \"dom.iterable\", \"esnext\"],\n    \"allowJs\": true,\n    \"skipLibCheck\": true,\n    \"strict\": true,\n    \"forceConsistentCasingInFileNames\": true,\n    \"noEmit\": true,\n    \"esModuleInterop\": true,\n    \"module\": \"esnext\",\n    \"moduleResolution\": \"node\",\n    \"resolveJsonModule\": true,\n    \"isolatedModules\": true,\n    \"jsx\": \"preserve\",\n    \"incremental\": true,\n    \"plugins\": [\n      {\n        \"name\": \"next\"\n      }\n    ],\n    \"baseUrl\": \".\",\n    \"paths\": {\n      \"@/*\": [\"./*\"]\n    }\n  },\n  \"include\": [\"next-env.d.ts\", \"**/*.ts\", \"**/*.tsx\", \".next/types/**/*.ts\"],\n  \"exclude\": [\"node_modules\"]\n}\n"
  }
]