[
  {
    "path": ".github/workflows/dailyFetchTraffic.yml",
    "content": "name: daily-traffic-data-fetching\n\n\non:\n  schedule:\n  - cron: \"1 0 * * *\"\n\njobs:\n  fetch-traffics:\n    runs-on: ubuntu-latest\n\n    steps:\n    - uses: actions/checkout@v1\n    - name: Use Node.js\n      uses: actions/setup-node@v1\n      with:\n        node-version: 12.x\n    - name: npm install\n      run: npm install\n      working-directory: ./backend\n    - name: fetch\n      run: node scripts/dailyGetTraffics.js\n      env:\n        awsAccessKeyId: ${{ secrets.awsAccessKeyId }}\n        awsSecretAccessKey: ${{ secrets.awsSecretAccessKey }}\n      working-directory: ./backend\n"
  },
  {
    "path": ".gitignore",
    "content": "secret.json\n\n# Logs\nlogs\n*.log\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n\n# Runtime data\npids\n*.pid\n*.seed\n*.pid.lock\n\n# Directory for instrumented libs generated by jscoverage/JSCover\nlib-cov\n\n# Coverage directory used by tools like istanbul\ncoverage\n\n# nyc test coverage\n.nyc_output\n\n# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)\n.grunt\n\n# Bower dependency directory (https://bower.io/)\nbower_components\n\n# node-waf configuration\n.lock-wscript\n\n# Compiled binary addons (https://nodejs.org/api/addons.html)\nbuild/Release\n\n# Dependency directories\nnode_modules/\njspm_packages/\n\n# TypeScript v1 declaration files\ntypings/\n\n# Optional npm cache directory\n.npm\n\n# Optional eslint cache\n.eslintcache\n\n# Optional REPL history\n.node_repl_history\n\n# Output of 'npm pack'\n*.tgz\n\n# Yarn Integrity file\n.yarn-integrity\n\n# dotenv environment variables file\n.env\n\n# next.js build output\n.next\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 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 General Public License is a free, copyleft license for\nsoftware and other kinds of works.\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,\nthe GNU General Public License is 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.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\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  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\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 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. Use with the GNU Affero General Public License.\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 Affero 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 special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe 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 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 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 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 General Public License as published by\n    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 General Public License for more details.\n\n    You should have received a copy of the GNU 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 the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\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 GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "[![](https://raw.githubusercontent.com/timqian/images/master/20191017115402.gif)](https://repo-analytics.github.io)\n[![](https://raw.githubusercontent.com/timqian/images/master/20191017114556.png)](https://repo-analytics.github.io)\n\n# [Repo Analytics](https://repo-analytics.github.io)\n\nThorough analytics for your GitHub repos\n\nChat with us in [Slack](https://join.slack.com/t/t9tio/shared_invite/enQtNjgzMzkwMDM0NTE3LTE5ZTUzYjU4Y2I0YzRiZjNkYTkzMzE1ZmM0NDdmYzRlZmMxNGY1MzZlN2EwYjYyNWVlMWY0Nzk2MDBhNWZlY2I)\n\n## Setup\n\nAdd config file\n\n```js\n// backend/secret.json\n{\n  \"aws\": {\n    \"accessKeyId\": \"\",\n    \"secretAccessKey\": \"\"\n  },\n  \"github\": {\n    \"clientID\": \"\",\n    \"clientSecret\": \"\"\n  },\n  \"jwtSecret\": \"\"\n}\n```\n\n## Thanks\n\n- [XKCD styled chart lib - chart.xkcd](https://github.com/timqian/chart.xkcd)\n- [Host single page apps with GitHub Pages](https://github.com/rafrex/spa-github-pages)\n- [Walking octocat](https://dribbble.com/shots/6364613-Octocat-walk-cycle)\n- [Icons: remix icon](https://remixicon.com)\n"
  },
  {
    "path": "backend/README.md",
    "content": "## Table structure\n\n### What to track:\n\nstargizers data;\nclone data;\nvisits data;\nreferal data;\ntoppage data;\n\n### Usefull analytics:\n\nstar history\nstar country distrubution\nclone history\nclone country distrubution\nfork history\nfork country distrubution\nvisits data (more than 14 days)\nunique visits\nreferall data\ntop page data\n\nsuggestions?\n\n\nTraffic\n\n```js\n{\n  date: '',\n  visits: '',\n  uniqueVists: '',\n  refs: '',\n  topPages: '',\n}\n```"
  },
  {
    "path": "backend/db/Repo.js",
    "content": "/**\n * {\n *   username: 'timqian',\n *   repo: 'timqian/chart.xkcd',\n *   createdAt: '',\n * }\n */\nconst dynamodb = require('./dynamodb');\n\n// TODO: secondary index for repo - to get repo's 'createdAt'\nasync function createTable() {\n  console.log('going to create \"repo-analytics-repo\" table');\n  await dynamodb.createTable({\n    TableName: 'repo-analytics-repo',\n    KeySchema: [\n      { AttributeName: 'username', KeyType: 'HASH' },\n      { AttributeName: 'repo', KeyType: 'RANGE' },\n    ],\n    AttributeDefinitions: [\n      { AttributeName: 'username', AttributeType: 'S' },\n      { AttributeName: 'repo', AttributeType: 'S' },\n    ],\n    BillingMode: 'PAY_PER_REQUEST',\n    // ProvisionedThroughput: {\n    //   ReadCapacityUnits: 1,\n    //   WriteCapacityUnits: 1,\n    // },\n  }).promise();\n  console.log('successfully created table \"repo-analytics-repo\"');\n}\n\nasync function deleteTable() {\n  await dynamodb.deleteTable({ TableName: 'repo-analytics-repo' }).promise();\n}\n\nasync function getAllForUser({ username }) {\n  const { Items } = await dynamodb.query({\n    TableName: 'repo-analytics-repo',\n    KeyConditionExpression: 'username = :username',\n    ExpressionAttributeValues: {\n      ':username': { S: username },\n    },\n  }).promise();\n  return Items;\n}\n\nasync function put({\n  username, repo,\n}) {\n  await dynamodb.putItem({\n    TableName: 'repo-analytics-repo',\n    Item: {\n      username: { S: username },\n      repo: { S: repo },\n      createdAt: { S: new Date().toISOString() },\n    },\n  }).promise();\n}\n\nasync function scan() {\n  const data = await dynamodb.scan({\n    TableName: 'repo-analytics-repo',\n    AttributesToGet: [\n      'username',\n      'repo',\n      'createdAt',\n    ],\n  }).promise();\n\n  // FIXME: if repo data larger than 1MB data, we need to handle pagination\n  return data.Items;\n}\n\nmodule.exports = {\n  createTable,\n  deleteTable,\n  getAllForUser,\n  put,\n  scan,\n};\n\n\n// // test\n// (async () => {\n//   // await createTable();\n//   // await new Promise((r) => setTimeout(r, 1000));\n//   await put({\n//     username: 'timqian',\n//     repo: 'repo-analytics/repo-analytics.github.io',\n//   });\n//   // const items = await getAllForUser({\n//   //   username: 'timqian',\n//   // });\n//   // console.log(items);\n//   const scanRes = await scan();\n//   console.log(scanRes)\n// })();\n"
  },
  {
    "path": "backend/db/Star.js",
    "content": "/**\n * {\n *   repo: 'timqian/chart.xkcd',\n *   updatedAt: '2016-09-18',\n *   totalCount: '100',\n *   history: {\n *     '2018-04-12': 10,\n *   },\n *   locations: {\n *     china: 3,\n *   }\n * }\n */\n\nconst dynamodb = require('./dynamodb');\n\nasync function createTable() {\n  console.log('going to create \"repo-analytics-stars\" table');\n  await dynamodb.createTable({\n    TableName: 'repo-analytics-stars',\n    KeySchema: [\n      { AttributeName: 'repo', KeyType: 'HASH' },\n    ],\n    AttributeDefinitions: [\n      { AttributeName: 'repo', AttributeType: 'S' },\n    ],\n    BillingMode: 'PAY_PER_REQUEST',\n    // ProvisionedThroughput: {\n    //   ReadCapacityUnits: 1,\n    //   WriteCapacityUnits: 1,\n    // },\n  }).promise();\n  console.log('successfully created table \"repo-analytics-stars\"');\n}\n\nasync function deleteTable() {\n  await dynamodb.deleteTable({ TableName: 'repo-analytics-stars' }).promise();\n}\n\nasync function get({ repo }) {\n  const { Item } = await dynamodb.getItem({\n    TableName: 'repo-analytics-stars',\n    Key: {\n      repo: { S: repo },\n    },\n  }).promise();\n  return Item;\n}\n\nasync function put({\n  repo, updatedAt, totalCount, history, locations,\n}) {\n  await dynamodb.putItem({\n    TableName: 'repo-analytics-stars',\n    Item: {\n      repo: { S: repo },\n      updatedAt: { S: updatedAt },\n      totalCount: { S: totalCount + '' },\n      history: { S: JSON.stringify(history) },\n      locations: { S: JSON.stringify(locations) },\n    },\n  }).promise();\n}\n\nmodule.exports = {\n  createTable,\n  deleteTable,\n  get,\n  put,\n};\n\n// // test\n// (async () => {\n//   // await createTable();\n//   // await new Promise((r) => setTimeout(r, 1000));\n//   await put({\n//     repo: 'timqian/star-history',\n//     updatedAt: '2019-03-01',\n//     totalCount: 19,\n//     history: {'2018-09-09': 2},\n//     locations: {'china':1}\n//   });\n//   const item = await get({\n//     repo: 'timqian/star-history',\n//   });\n//   console.log(item);\n// })();\n"
  },
  {
    "path": "backend/db/Traffic.js",
    "content": "/**\n * {\n *   repo: 'timqian/chart.xkcd',\n *   date: '2016-09-18',\n *   views: [],\n *   clones: [],\n *   referrers: [],\n *   paths: [],\n *   repoCreatedAt: '2019-10-08'\n * }\n */\n\nconst dynamodb = require('./dynamodb');\n\nasync function createTable() {\n  console.log('going to create \"repo-analytics-analytics\" table');\n  await dynamodb.createTable({\n    TableName: 'repo-analytics-analytics',\n    KeySchema: [\n      { AttributeName: 'repo', KeyType: 'HASH' },\n      { AttributeName: 'date', KeyType: 'RANGE' },\n    ],\n    AttributeDefinitions: [\n      { AttributeName: 'repo', AttributeType: 'S' },\n      { AttributeName: 'date', AttributeType: 'S' },\n    ],\n    BillingMode: 'PAY_PER_REQUEST',\n    // ProvisionedThroughput: {\n    //   ReadCapacityUnits: 1,\n    //   WriteCapacityUnits: 1,\n    // },\n  }).promise();\n  console.log('successfully created table \"repo-analytics-analytics\"');\n}\n\nasync function deleteTable() {\n  await dynamodb.deleteTable({ TableName: 'repo-analytics-analytics' }).promise();\n}\n\nasync function batchGetViewAndClones({ repo, dateArr }) {\n  const keys = dateArr.map(date => ({\n    repo: { S: repo },\n    date: { S: date }\n  }));\n\n  const { Responses } = await dynamodb.batchGetItem({\n    RequestItems: {\n      \"repo-analytics-analytics\": {\n        Keys: keys,\n        AttributesToGet: [\n          'repo',\n          'date',\n          'views',\n          'clones',\n        ],\n      }\n    }\n  }).promise();\n  return Responses[\"repo-analytics-analytics\"];\n}\n\nasync function getLatest({ repo }) {\n  const { Items } = await dynamodb.query({\n    TableName: 'repo-analytics-analytics',\n    KeyConditionExpression: 'repo = :repo',\n    ExpressionAttributeValues: {\n      ':repo': { S: repo },\n    },\n    Limit: 1,\n    ScanIndexForward: false,\n  }).promise();\n  return Items[0];\n}\n\nasync function put({\n  repo, date, views, clones, referrers, paths, repoCreatedAt,\n}) {\n  await dynamodb.putItem({\n    TableName: 'repo-analytics-analytics',\n    Item: {\n      repo: { S: repo },\n      date: { S: date },\n      views: { S: JSON.stringify(views) },\n      clones: { S: JSON.stringify(clones) },\n      referrers: { S: JSON.stringify(referrers) },\n      paths: { S: JSON.stringify(paths) },\n      createdAt: { S: new Date().toISOString() },\n      repoCreatedAt: { S: repoCreatedAt }\n    },\n  }).promise();\n}\n\nmodule.exports = {\n  createTable,\n  deleteTable,\n  getLatest,\n  batchGetViewAndClones,\n  put,\n};\n\n\n// // test\n// (async () => {\n//   // await createTable();\n//   // await new Promise((r) => setTimeout(r, 1000));\n//   // await put({\n//   //   repo: 'timqian/chart.xkcd',\n//   //   date: '2019-10-09',\n//   //   views: [\n//   //     {\n//   //       \"timestamp\": \"2016-10-10T00:00:00Z\",\n//   //       \"count\": 440,\n//   //       \"uniques\": 143\n//   //     },\n//   //     {\n//   //       \"timestamp\": \"2016-10-11T00:00:00Z\",\n//   //       \"count\": 1308,\n//   //       \"uniques\": 414\n//   //     },\n//   //   ],\n//   //   referrers: [\n//   //     {\n//   //       \"referrer\": \"Google\",\n//   //       \"count\": 4,\n//   //       \"uniques\": 3\n//   //     },\n//   //     {\n//   //       \"referrer\": \"stackoverflow.com\",\n//   //       \"count\": 2,\n//   //       \"uniques\": 2\n//   //     }\n//   //   ],\n//   //   paths: [\n//   //     {\n//   //       \"path\": \"/github/hubot\",\n//   //       \"title\": \"github/hubot: A customizable life embetterment robot.\",\n//   //       \"count\": 3542,\n//   //       \"uniques\": 2225\n//   //     },\n//   //     {\n//   //       \"path\": \"/github/hubot/blob/master/docs/scripting.md\",\n//   //       \"title\": \"hubot/scripting.md at master · github/hubot · GitHub\",\n//   //       \"count\": 1707,\n//   //       \"uniques\": 804\n//   //     }\n//   //   ],\n//   //   clones: [\n//   //     {\n//   //       \"timestamp\": \"2016-10-10T00:00:00Z\",\n//   //       \"count\": 2,\n//   //       \"uniques\": 1\n//   //     },\n//   //     {\n//   //       \"timestamp\": \"2016-10-11T00:00:00Z\",\n//   //       \"count\": 17,\n//   //       \"uniques\": 16\n//   //     }\n//   //   ]\n//   //   repoCreatedAt: '2018-09-10'\n//   // });\n\n//   // const item = await batchGet({ repo: 'timqian/chart.xkcd', dateArr: ['2019-10-09']})\n\n//   // console.log(item);\n\n//   // const latestItem = await getLatest({ repo: 'timqian/chart.xkcd' });\n//   // console.log(latestItem)\n// })();\n"
  },
  {
    "path": "backend/db/User.js",
    "content": "/**\n * {\n *   username: 'timqian',\n *   email: 'timqian@t9t.io',\n *   accessToken: '',\n *   displayName: '', \n *   photo: '',\n *   createdAt: '',\n * }\n */\n\nconst dynamodb = require('./dynamodb');\n\nasync function createTable() {\n  console.log('going to create \"repo-analytics-user\" table');\n  await dynamodb.createTable({\n    TableName: 'repo-analytics-user',\n    KeySchema: [\n      { AttributeName: 'username', KeyType: 'HASH' },\n    ],\n    AttributeDefinitions: [\n      { AttributeName: 'username', AttributeType: 'S' },\n    ],\n    BillingMode: 'PAY_PER_REQUEST',\n    // ProvisionedThroughput: {\n    //   ReadCapacityUnits: 1,\n    //   WriteCapacityUnits: 1,\n    // },\n  }).promise();\n  console.log('successfully created table \"repo-analytics-user\"');\n}\n\nasync function deleteTable() {\n  await dynamodb.deleteTable({ TableName: 'repo-analytics-user' }).promise();\n}\n\nasync function get({ username }) {\n  const { Item } = await dynamodb.getItem({\n    TableName: 'repo-analytics-user',\n    Key: {\n      username: { S: username },\n    },\n  }).promise();\n  return Item;\n}\n\nasync function put({\n  username, email, accessToken, displayName, photo,\n}) {\n  if (displayName) {\n    await dynamodb.putItem({\n      TableName: 'repo-analytics-user',\n      Item: {\n        username: { S: username },\n        email: { S: email },\n        accessToken: { S: accessToken },\n        displayName: { S: displayName },\n        photo: { S: photo },\n        createdAt: { S: new Date().toISOString() },\n      },\n    }).promise();\n  } else {\n    await dynamodb.putItem({\n      TableName: 'repo-analytics-user',\n      Item: {\n        username: { S: username },\n        email: { S: email },\n        accessToken: { S: accessToken },\n        photo: { S: photo },\n        createdAt: { S: new Date().toISOString() },\n      },\n    }).promise(); \n  }\n\n}\n\nasync function scan() {\n  const data = await dynamodb.scan({\n    TableName: 'repo-analytics-user',\n    AttributesToGet: [\n      'username',\n      'accessToken'\n    ],\n  }).promise();\n\n  // FIXME: if user data larger than 1MB data, we need to handle pagination\n  return data.Items;\n}\n\nmodule.exports = {\n  createTable,\n  deleteTable,\n  get,\n  put,\n  scan,\n};\n\n\n// // test\n// (async () => {\n//   // await createTable();\n//   // await new Promise((r) => setTimeout(r, 1000));\n//   // await put({\n//   //   username: 'timqn',\n//   //   email: 'timqian@t9t.io',\n//   //   displayName: 'timqian', photo:'abc',\n//   // });\n//   // const item = await get({\n//   //   username: 'timqian',\n//   // });\n//   // console.log(item);\n\n//   // const scanRes = await scan();\n//   // console.log(scanRes)\n// })();\n"
  },
  {
    "path": "backend/db/dynamodb.js",
    "content": "const AWS = require('aws-sdk');\n\nlet config = {};\n\ntry {\n  config = require('../secret.json');\n} catch (error) {\n  console.log('no secret json, on github action')\n}\n\nconst awsConfig = {\n  region: 'us-east-1',\n  // process.env.awsAccessKeyId in action secret\n  accessKeyId: process.env.awsAccessKeyId ? process.env.awsAccessKeyId : config.aws.accessKeyId,\n  secretAccessKey: process.env.awsSecretAccessKey ? process.env.awsSecretAccessKey : config.aws.secretAccessKey,\n  signatureVersion: 'v4',\n};\n\nAWS.config.update(awsConfig);\n\nconst dynamodb = new AWS.DynamoDB();\n\nmodule.exports = dynamodb;\n"
  },
  {
    "path": "backend/package.json",
    "content": "{\n  \"name\": \"backend\",\n  \"version\": \"1.0.0\",\n  \"main\": \"server.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\",\n    \"start\": \"node server.js\",\n    \"deploy\": \"up deploy production\"\n  },\n  \"keywords\": [],\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"aws-sdk\": \"^2.543.0\",\n    \"axios\": \"^0.19.0\",\n    \"body-parser\": \"^1.19.0\",\n    \"cors\": \"^2.8.5\",\n    \"dayjs\": \"^1.8.16\",\n    \"express\": \"^4.17.1\",\n    \"graphql-request\": \"^1.8.2\",\n    \"jwt-simple\": \"^0.5.6\",\n    \"passport\": \"^0.4.1\",\n    \"passport-github\": \"^1.1.0\"\n  }\n}\n"
  },
  {
    "path": "backend/scripts/README.md",
    "content": "## TODO\n\n- add cities in the largest cities\n\n## Refs\n\n- List of largest cities: https://en.wikipedia.org/wiki/List_of_largest_cities\n- Largest cities in China: https://en.wikipedia.org/wiki/List_of_cities_in_China_by_population\n- United States: https://en.wikipedia.org/wiki/List_of_United_States_cities_by_population\n- Russuia: https://en.wikipedia.org/wiki/List_of_cities_and_towns_in_Russia_by_population\n- Canada: https://en.wikipedia.org/wiki/List_of_the_100_largest_population_centres_in_Canada\n"
  },
  {
    "path": "backend/scripts/countries.json",
    "content": "[{\n  \"country\": \"russia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": [\"moscow\",\n    \"saint petersburg\",\n    \"novosibirsk\",\n    \"yekaterinburg\",\n    \"nizhny novgorod\",\n    \"kazan\",\n    \"chelyabinsk\",\n    \"omsk\",\n    \"samara\",\n    \"rostov-on-don\",\n    \"ufa\",\n    \"krasnoyarsk\",\n    \"perm\",\n    \"voronezh\",\n    \"volgograd\",\n    \"krasnodar\",\n    \"saratov\",\n    \"tyumen\",\n    \"tolyatti\",\n    \"izhevsk\",\n    \"barnaul\",\n    \"ulyanovsk\",\n    \"irkutsk\",\n    \"khabarovsk\",\n    \"yaroslavl\",\n    \"vladivostok\",\n    \"makhachkala\",\n    \"tomsk\",\n    \"orenburg\",\n    \"kemerovo\",\n    \"novokuznetsk\",\n    \"ryazan\",\n    \"astrakhan\",\n    \"naberezhnye chelny\",\n    \"penza\",\n    \"lipetsk\",\n    \"kirov\",\n    \"cheboksary\",\n    \"tula\",\n    \"kaliningrad\",\n    \"balashikha\",\n    \"kursk\",\n    \"stavropol\",\n    \"ulan-ude\",\n    \"tver\",\n    \"magnitogorsk\",\n    \"sochi\",\n    \"ivanovo\",\n    \"bryansk\",\n    \"belgorod\",\n    \"surgut\",\n    \"vladimir\",\n    \"nizhny tagil\",\n    \"arkhangelsk\",\n    \"chita\",\n    \"kaluga\",\n    \"smolensk\",\n    \"volzhsky\",\n    \"kurgan\",\n    \"cherepovets\",\n    \"oryol\",\n    \"saransk\",\n    \"vologda\",\n    \"yakutsk\",\n    \"vladikavkaz\",\n    \"podolsk\",\n    \"murmansk\",\n    \"grozny\",\n    \"tambov\",\n    \"sterlitamak\",\n    \"petrozavodsk\",\n    \"kostroma\",\n    \"nizhnevartovsk\",\n    \"novorossiysk\",\n    \"yoshkar-ola\",\n    \"taganrog\",\n    \"komsomolsk-on-amur\",\n    \"khimki\",\n    \"syktyvkar\",\n    \"nalchik\",\n    \"nizhnekamsk\",\n    \"shakhty\",\n    \"dzerzhinsk\",\n    \"bratsk\",\n    \"orsk\",\n    \"angarsk\",\n    \"engels\",\n    \"blagoveshchensk\",\n    \"stary oskol\",\n    \"veliky novgorod\",\n    \"korolyov\",\n    \"pskov\",\n    \"mytishchi\",\n    \"biysk\",\n    \"lyubertsy\",\n    \"prokopyevsk\",\n    \"yuzhno-sakhalinsk\",\n    \"balakovo\",\n    \"armavir\",\n    \"rybinsk\",\n    \"severodvinsk\",\n    \"abakan\",\n    \"petropavlovsk-kamchatsky\",\n    \"norilsk\",\n    \"syzran\",\n    \"volgodonsk\",\n    \"ussuriysk\",\n    \"kamensk-uralsky\",\n    \"novocherkassk\",\n    \"zlatoust\",\n    \"elektrostal\",\n    \"almetyevsk\",\n    \"krasnogorsk\",\n    \"salavat\",\n    \"miass\",\n    \"nakhodka\",\n    \"kopeysk\",\n    \"pyatigorsk\",\n    \"rubtsovsk\",\n    \"berezniki\",\n    \"kolomna\",\n    \"maykop\",\n    \"odintsovo\",\n    \"khasavyurt\",\n    \"kovrov\",\n    \"kislovodsk\",\n    \"neftekamsk\",\n    \"nefteyugansk\",\n    \"novocheboksarsk\",\n    \"serpukhov\",\n    \"shchyolkovo\",\n    \"novomoskovsk\",\n    \"bataysk\",\n    \"pervouralsk\",\n    \"domodedovo\",\n    \"derbent\",\n    \"cherkessk\",\n    \"orekhovo-zuyevo\",\n    \"nevinnomyssk\",\n    \"dimitrovgrad\",\n    \"nazran\",\n    \"kyzyl\",\n    \"oktyabrsky\",\n    \"obninsk\",\n    \"kaspiysk\",\n    \"novy urengoy\",\n    \"ramenskoye\",\n    \"kamyshin\",\n    \"murom\",\n    \"zhukovsky\",\n    \"novoshakhtinsk\",\n    \"seversk\",\n    \"yessentuki\",\n    \"noyabrsk\",\n    \"artyom\",\n    \"pushkino\",\n    \"achinsk\",\n    \"yelets\",\n    \"sergiyev posad\",\n    \"arzamas\",\n    \"dolgoprudny\",\n    \"elista\",\n    \"berdsk\",\n    \"novokuybyshevsk\",\n    \"noginsk\",\n    \"zheleznogorsk\",\n    \"reutov\",\n    \"zelenodolsk\",\n    \"tobolsk\",\n    \"khanty-mansiysk\",\n    \"votkinsk\",\n    \"sarapul\",\n    \"mezhdurechensk\",\n    \"ukhta\",\n    \"serov\",\n    \"leninsk-kuznetsky\",\n    \"gatchina\",\n    \"sarov\",\n    \"solikamsk\",\n    \"voskresensk\",\n    \"michurinsk\",\n    \"glazov\",\n    \"velikiye luki\",\n    \"magadan\",\n    \"kiselyovsk\",\n    \"kansk\",\n    \"kamensk-shakhtinsky\",\n    \"novotroitsk\",\n    \"mikhaylovsk\",\n    \"lobnya\",\n    \"gubkin\",\n    \"buzuluk\",\n    \"bugulma\",\n    \"yeysk\",\n    \"zheleznogorsk\",\n    \"kineshma\",\n    \"chaykovsky\",\n    \"kuznetsk\",\n    \"ust-ilimsk\",\n    \"yurga\",\n    \"novouralsk\",\n    \"azov\",\n    \"ozyorsk\",\n    \"kropotkin\",\n    \"klin\",\n    \"vyborg\",\n    \"bor\",\n    \"usolye-sibirskoye\",\n    \"balashov\",\n    \"shadrinsk\",\n    \"mineralnye vody\",\n    \"anapa\",\n    \"troitsk\",\n    \"dubna\",\n    \"gelendzhik\",\n    \"chernogorsk\",\n    \"ivanteyevka\",\n    \"birobidzhan\",\n    \"yelabuga\",\n    \"yegoryevsk\",\n    \"novoaltaysk\",\n    \"kirovo-chepetsk\",\n    \"chapayevsk\",\n    \"belovo\",\n    \"anzhero-sudzhensk\",\n    \"chekhov\",\n    \"vsevolozhsk\",\n    \"verkhnyaya pyshma\",\n    \"georgiyevsk\",\n    \"tuymazy\",\n    \"minusinsk\",\n    \"sosnovy bor\",\n    \"kstovo\",\n    \"dmitrov\",\n    \"belogorsk\",\n    \"stupino\",\n    \"gukovo\",\n    \"kungur\",\n    \"slavyansk-na-kubani\",\n    \"beloretsk\",\n    \"pavlovsky posad\",\n    \"ishimbay\",\n    \"ishim\",\n    \"vidnoye\",\n    \"zarechny\",\n    \"kogalym\",\n    \"asbest\",\n    \"buynaksk\",\n    \"volsk\",\n    \"donskoy\",\n    \"gorno-altaysk\",\n    \"leninogorsk\",\n    \"rossosh\",\n    \"tuapse\",\n    \"klintsy\",\n    \"budyonnovsk\",\n    \"borisoglebsk\",\n    \"revda\",\n    \"lysva\",\n    \"zelenogorsk\",\n    \"polevskoy\",\n    \"naro-fominsk\",\n    \"kotlas\",\n    \"sibay\",\n    \"labinsk\",\n    \"kumertau\",\n    \"chistopol\",\n    \"fryazino\",\n    \"rzhev\",\n    \"lesosibirsk\",\n    \"alexandrov\",\n    \"belebey\",\n    \"tikhoretsk\",\n    \"shuya\",\n    \"urus-martan\",\n    \"meleuz\",\n    \"mikhaylovka\",\n    \"aleksin\",\n    \"salsk\",\n    \"pavlovo\",\n    \"izberbash\",\n    \"vorkuta\",\n    \"shchyokino\",\n    \"tikhvin\",\n    \"prokhladny\",\n    \"nyagan\",\n    \"lytkarino\",\n    \"krasnoturyinsk\",\n    \"krymsk\",\n    \"neryungri\",\n    \"beryozovsky\",\n    \"iskitim\",\n    \"apatity\",\n    \"gus-khrustalny\",\n    \"dzerzhinsky\",\n    \"volzhsk\",\n    \"zhigulyovsk\",\n    \"liski\",\n    \"svobodny\",\n    \"krasnokamsk\",\n    \"vyksa\",\n    \"vyazma\",\n    \"shali\",\n    \"krasnokamensk\",\n    \"arsenyev\",\n    \"solnechnogorsk\",\n    \"timashyovsk\",\n    \"belorechensk\",\n    \"kirishi\",\n    \"uzlovaya\",\n    \"gudermes\",\n    \"sertolovo\",\n    \"cheremkhovo\",\n    \"severomorsk\",\n    \"borovichi\",\n    \"roslavl\",\n    \"snezhinsk\",\n    \"nazarovo\"]\n}, {\n  \"country\": \"canada\",\n  \"states\": [], \"alias\": [],\n  \"cities\": [\"montreal\",\n    \"vancouver\",\n    \"calgary\",\n    \"edmonton\",\n    \"ottawa–gatineau\",\n    \"winnipeg\",\n    \"quebec city\",\n    \"hamilton\",\n    \"kitchener\",\n    \"london\",\n    \"victoria\",\n    \"halifax\",\n    \"oshawa\",\n    \"windsor\",\n    \"saskatoon\",\n    \"st. catharines–niagara falls\",\n    \"regina\",\n    \"st. john's\",\n    \"kelowna\",\n    \"barrie\",\n    \"sherbrooke\",\n    \"guelph\",\n    \"abbotsford\",\n    \"kingston\",\n    \"kanata\",\n    \"trois-rivières\",\n    \"moncton\",\n    \"chicoutimi–jonquière\",\n    \"milton\",\n    \"red deer\",\n    \"brantford\",\n    \"thunder bay\",\n    \"white rock\",\n    \"nanaimo\",\n    \"sudbury\",\n    \"lethbridge\",\n    \"saint-jean-sur-richelieu\",\n    \"peterborough\",\n    \"kamloops\",\n    \"saint-jérôme\",\n    \"chilliwack\",\n    \"sarnia\",\n    \"châteauguay\",\n    \"drummondville\",\n    \"belleville\",\n    \"fort mcmurray\",\n    \"sault ste. marie\",\n    \"prince george\",\n    \"medicine hat\",\n    \"welland–pelham\",\n    \"grande prairie\",\n    \"airdrie\",\n    \"granby\",\n    \"fredericton\",\n    \"saint john\",\n    \"beloeil\",\n    \"north bay\",\n    \"saint-hyacinthe\",\n    \"brandon\",\n    \"vernon\",\n    \"cornwall\",\n    \"joliette\",\n    \"courtenay\",\n    \"charlottetown\",\n    \"victoriaville\",\n    \"chatham\",\n    \"georgetown\",\n    \"st. thomas\",\n    \"woodstock\",\n    \"bowmanville\",\n    \"salaberry-de-valleyfield\",\n    \"shawinigan\",\n    \"rimouski\",\n    \"spruce grove\",\n    \"sorel\",\n    \"campbell river\",\n    \"prince albert\",\n    \"penticton\",\n    \"mission\",\n    \"leamington\",\n    \"moose jaw\",\n    \"stouffville\",\n    \"lloydminster\",\n    \"orillia\",\n    \"stratford\",\n    \"orangeville\",\n    \"cape breton–sydney\",\n    \"bradford\",\n    \"leduc\",\n    \"timmins\",\n    \"okotoks\",\n    \"saint-georges\",\n    \"keswick–elmhurst beach\",\n    \"bolton\",\n    \"val-d'or\",\n    \"cochrane\",\n    \"quispamsis–rothesay\",\n    \"midland\",\n    \"innisfil\"]\n}, {\n  \"country\": \"united states\",\n  \"states\": [], \"alias\": [\"usa\", \"america\"],\n  \"cities\": [\"new york\",\n    \"los angeles\",\n    \"chicago\",\n    \"houston\",\n    \"phoenix\",\n    \"philadelphia\",\n    \"san antonio\",\n    \"san diego\",\n    \"dallas\",\n    \"san jose\",\n    \"austin\",\n    \"jacksonville\",\n    \"fort worth\",\n    \"columbus\",\n    \"san francisco\",\n    \"charlotte\",\n    \"indianapolis\",\n    \"seattle\",\n    \"denver\",\n    \"washington\",\n    \"boston\",\n    \"el paso\",\n    \"detroit\",\n    \"nashville\",\n    \"portland\",\n    \"memphis\",\n    \"oklahoma city\",\n    \"las vegas\",\n    \"louisville\",\n    \"baltimore\",\n    \"milwaukee\",\n    \"albuquerque\",\n    \"tucson\",\n    \"fresno\",\n    \"mesa\",\n    \"sacramento\",\n    \"atlanta\",\n    \"kansas city\",\n    \"colorado springs\",\n    \"miami\",\n    \"raleigh\",\n    \"omaha\",\n    \"long beach\",\n    \"virginia beach\",\n    \"oakland\",\n    \"minneapolis\",\n    \"tulsa\",\n    \"arlington\",\n    \"tampa\",\n    \"new orleans\",\n    \"wichita\",\n    \"cleveland\",\n    \"bakersfield\",\n    \"aurora\",\n    \"anaheim\",\n    \"honolulu\",\n    \"santa ana\",\n    \"riverside\",\n    \"corpus christi\",\n    \"lexington\",\n    \"stockton\",\n    \"henderson\",\n    \"saint paul\",\n    \"st. louis\",\n    \"cincinnati\",\n    \"pittsburgh\",\n    \"greensboro\",\n    \"anchorage\",\n    \"plano\",\n    \"lincoln\",\n    \"orlando\",\n    \"irvine\",\n    \"newark\",\n    \"toledo\",\n    \"durham\",\n    \"chula vista\",\n    \"fort wayne\",\n    \"jersey city\",\n    \"st. petersburg\",\n    \"laredo\",\n    \"madison\",\n    \"chandler\",\n    \"buffalo\",\n    \"lubbock\",\n    \"scottsdale\",\n    \"reno\",\n    \"glendale\",\n    \"gilbert\",\n    \"winston–salem\",\n    \"north las vegas\",\n    \"norfolk\",\n    \"chesapeake\",\n    \"garland\",\n    \"irving\",\n    \"hialeah\",\n    \"fremont\",\n    \"boise\",\n    \"richmond\",\n    \"baton rouge\",\n    \"spokane\",\n    \"des moines\",\n    \"tacoma\",\n    \"san bernardino\",\n    \"modesto\",\n    \"fontana\",\n    \"santa clarita\",\n    \"birmingham\",\n    \"oxnard\",\n    \"fayetteville\",\n    \"moreno valley\",\n    \"rochester\",\n    \"glendale\",\n    \"huntington beach\",\n    \"salt lake city\",\n    \"grand rapids\",\n    \"amarillo\",\n    \"yonkers\",\n    \"aurora\",\n    \"montgomery\",\n    \"akron\",\n    \"little rock\",\n    \"huntsville\",\n    \"augusta\",\n    \"port st. lucie\",\n    \"grand prairie\",\n    \"columbus\",\n    \"tallahassee\",\n    \"overland park\",\n    \"tempe\",\n    \"mckinney\",\n    \"mobile\",\n    \"cape coral\",\n    \"shreveport\",\n    \"frisco\",\n    \"knoxville\",\n    \"worcester\",\n    \"brownsville\",\n    \"vancouver\",\n    \"fort lauderdale\",\n    \"sioux falls\",\n    \"ontario\",\n    \"chattanooga\",\n    \"providence\",\n    \"newport news\",\n    \"rancho cucamonga\",\n    \"santa rosa\",\n    \"oceanside\",\n    \"salem\",\n    \"elk grove\",\n    \"garden grove\",\n    \"pembroke pines\",\n    \"peoria\",\n    \"eugene\",\n    \"corona\",\n    \"cary\",\n    \"springfield\",\n    \"fort collins\",\n    \"jackson\",\n    \"alexandria\",\n    \"hayward\",\n    \"lancaster\",\n    \"lakewood\",\n    \"clarksville\",\n    \"palmdale\",\n    \"salinas\",\n    \"springfield\",\n    \"hollywood\",\n    \"pasadena\",\n    \"sunnyvale\",\n    \"macon\",\n    \"kansas city\",\n    \"pomona\",\n    \"escondido\",\n    \"killeen\",\n    \"naperville\",\n    \"joliet\",\n    \"bellevue\",\n    \"rockford\",\n    \"savannah\",\n    \"paterson\",\n    \"torrance\",\n    \"bridgeport\",\n    \"mcallen\",\n    \"mesquite\",\n    \"syracuse\",\n    \"midland\",\n    \"pasadena\",\n    \"murfreesboro\",\n    \"miramar\",\n    \"dayton\",\n    \"fullerton\",\n    \"olathe\",\n    \"orange\",\n    \"thornton\",\n    \"roseville\",\n    \"denton\",\n    \"waco\",\n    \"surprise\",\n    \"carrollton\",\n    \"west valley city\",\n    \"charleston\",\n    \"warren\",\n    \"hampton\",\n    \"gainesville\",\n    \"visalia\",\n    \"coral springs\",\n    \"columbia\",\n    \"cedar rapids\",\n    \"sterling heights\",\n    \"new haven\",\n    \"stamford\",\n    \"concord\",\n    \"kent\",\n    \"santa clara\",\n    \"elizabeth\",\n    \"round rock\",\n    \"thousand oaks\",\n    \"lafayette\",\n    \"athens\",\n    \"topeka\",\n    \"simi valley\",\n    \"fargo\",\n    \"norman\",\n    \"columbia\",\n    \"abilene\",\n    \"wilmington\",\n    \"hartford\",\n    \"victorville\",\n    \"pearland\",\n    \"vallejo\",\n    \"ann arbor\",\n    \"berkeley\",\n    \"allentown\",\n    \"richardson\",\n    \"odessa\",\n    \"arvada\",\n    \"cambridge\",\n    \"sugar land\",\n    \"beaumont\",\n    \"lansing\",\n    \"evansville\",\n    \"rochester\",\n    \"independence\",\n    \"fairfield\",\n    \"provo\",\n    \"clearwater\",\n    \"college station\",\n    \"west jordan\",\n    \"carlsbad\",\n    \"el monte\",\n    \"murrieta\",\n    \"temecula\",\n    \"springfield\",\n    \"palm bay\",\n    \"costa mesa\",\n    \"westminster\",\n    \"north charleston\",\n    \"miami gardens\",\n    \"manchester\",\n    \"high point\",\n    \"downey\",\n    \"clovis\",\n    \"pompano beach\",\n    \"pueblo\",\n    \"elgin\",\n    \"lowell\",\n    \"antioch\",\n    \"west palm beach\",\n    \"peoria\",\n    \"everett\",\n    \"ventura\",\n    \"centennial\",\n    \"lakeland\",\n    \"gresham\",\n    \"richmond\",\n    \"billings\",\n    \"inglewood\",\n    \"broken arrow\",\n    \"sandy springs\",\n    \"jurupa valley\",\n    \"hillsboro\",\n    \"waterbury\",\n    \"santa maria\",\n    \"boulder\",\n    \"greeley\",\n    \"daly city\",\n    \"meridian\",\n    \"lewisville\",\n    \"davie\",\n    \"west covina\",\n    \"league city\",\n    \"tyler\",\n    \"norwalk\",\n    \"san mateo\",\n    \"green bay\",\n    \"wichita falls\",\n    \"sparks\",\n    \"lakewood\",\n    \"burbank\",\n    \"rialto\",\n    \"allen\",\n    \"el cajon\",\n    \"las cruces\",\n    \"renton\",\n    \"davenport\",\n    \"south bend\",\n    \"vista\",\n    \"tuscaloosa\",\n    \"clinton\",\n    \"edison\",\n    \"woodbridge\",\n    \"san angelo\",\n    \"kenosha\",\n    \"vacaville\"]\n}, {\n  \"country\": \"china\",\n  \"states\": [], \"alias\": [],\n  \"cities\": [\"shanghai\",\"beijing\",\"guangzhou\",\"shenzhen\",\"tianjin\",\"wuhan\",\"dongguan\",\"chengdu\",\"foshan\",\"chongqing\",\"nanjing\",\"shenyang\",\"hangzhou\",\"xi'an\",\"harbin\",\"suzhou\",\"qingdao\",\"dalian\",\"zhengzhou\",\"shantou\",\"jinan\",\"changchun\",\"kunming\",\"changsha\",\"taiyuan\",\"xiamen\",\"hefei\",\"shijiazhuang\",\"ürümqi\",\"fuzhou\",\"wuxi\",\"zhongshan\",\"wenzhou\",\"nanning\",\"nanchang\",\"ningbo\",\"guiyang\",\"lanzhou\",\"zibo\",\"changzhou\",\"xuzhou\",\"tangshan\",\"baotou\",\"huizhou\",\"yantai\",\"shaoxing\",\"liuzhou\",\"nantong\",\"luoyang\",\"yangzhou\"]\n}, {\n  \"country\": \"brazil\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"australia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"india\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"argentina\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"kazakhstan\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"algeria\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"democratic republic of the congo\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"greenland\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"mexico\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"saudi arabia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"indonesia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"sudan\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"libya\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"iran\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"mongolia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"peru\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"chad\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"niger\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"angola\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"mali\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"south africa\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"colombia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"ethiopia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"bolivia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"mauritania\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"egypt\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"tanzania\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"nigeria\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"venezuela\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"namibia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"pakistan\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"mozambique\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"turkey\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"chile\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"zambia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"myanmar\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"afghanistan\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"south sudan\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"somalia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"central african republic\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"ukraine\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"botswana\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"madagascar\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"kenya\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"france\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"yemen\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"thailand\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"spain\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"turkmenistan\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"cameroon\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"papua new guinea\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"sweden\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"uzbekistan\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"morocco\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"iraq\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"paraguay\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"zimbabwe\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"japan\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"germany\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"republic of congo\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"finland\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"malaysia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"vietnam\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"norway\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"ivory coast\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"poland\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"italy\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"philippines\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"ecuador\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"burkina faso\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"new zealand\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"gabon\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"western sahara\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"guinea\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"united kingdom\",\n  \"states\": [], \"alias\": [\"uk\"],\n  \"cities\": []\n}, {\n  \"country\": \"ghana\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"romania\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"laos\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"uganda\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"guyana\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"oman\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"belarus\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"kyrgyzstan\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"senegal\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"syria\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"cambodia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"uruguay\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"tunisia\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"suriname\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"bangladesh\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"tajikistan\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"nepal\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"greece\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"nicaragua\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}, {\n  \"country\": \"eritrea\",\n  \"states\": [], \"alias\": [],\n  \"cities\": []\n}]"
  },
  {
    "path": "backend/scripts/dailyGetStars.js",
    "content": "const RepoDao = require('../db/Repo');\nconst getStars = require('../utils/getStars');\nconst StarDao = require('../db/Star');\n\nconst get = async () => {\n  const repos = await RepoDao.scan();\n\n  for (const repo of repos) {\n    const repoPath = repo.repo.S;\n    // if (repoPath !== 'NervJS/taro') continue;\n    const repoOwner = repo.username.S;\n    try {\n      console.log('going to fetch', repoOwner, repoPath)\n      const res = await getStars(repoOwner, repoPath);\n      console.log('going to store', repoOwner, repoPath);\n      await StarDao.put({\n        repo: repoPath,\n        ...res\n      });\n      console.log('success', repoOwner, repoPath);\n    } catch (error) {\n      if(error.response) {\n        console.log(error.response.message);\n      } else {\n        console.log(error.message)\n      }\n    }\n  }\n}\n\nget();\n"
  },
  {
    "path": "backend/scripts/dailyGetTraffics.js",
    "content": "const axios = require('axios');\nconst UserDao = require('../db/User');\nconst RepoDao = require('../db/Repo');\nconst TrafficDao = require('../db/Traffic');\n\n/**\n * This script get daily traffic data for all repos.\n * Run once per day\n * \n * Process\n *   1. get all users\n *   1. get all repos\n *   1. for every repo: get its traffic by using user's token\n */\nasync function run() {\n  const dateStr = new Date().toISOString().slice(0, 10);\n\n  // ---- 1. get all users ----\n\n  // [{ username: { S: 'timqian' }, accessToken: { S: 'token' }}]\n  const users = await UserDao.scan();\n  // { timqian: 'token' }\n  const userMap = users.reduce((pre, cur) => {\n    pre[cur.username.S] = cur.accessToken.S;\n    return pre;\n  }, {});\n\n  // ---- 2. get all repos ----\n\n  // [{ username: { S: 'timqian' }, repo: { S: 'timqian/chart.xkcd' }}]\n  const repos = await RepoDao.scan();\n\n  // [{ username: 'timqian', repo: 'timqian/chart.xkcd', accessToken: 'token' }]\n  const repoArr = repos.map(repo => {\n    const username = repo.username.S;\n    const createdAt = repo.createdAt.S;\n    const accessToken = userMap[username];\n    return {\n      username,\n      repo: repo.repo.S,\n      accessToken,\n      createdAt,\n    }\n  });\n\n  // ---- 3. query and store to db ----\n  for(let i = 0; i < repoArr.length; i++) {\n    const repo = repoArr[i];\n    try {\n      // if (!['airyland/vux', 'ZhuPeng/mp-transform-public', 'amorist/platelet', 'timqian/star-history'].includes(repo.repo)) continue;\n      console.log('Fetching', repo.repo);\n      const http = axios.create({\n        baseURL: 'https://api.github.com/',\n        timeout: 30000,\n        headers: {\n          'Accept': 'application/vnd.github.v3+json',\n          'Authorization': `token ${repo.accessToken}`,\n        },\n      });\n      const viewsPromise = http.get(`/repos/${repo.repo}/traffic/views`);\n      const clonesPromise = http.get(`/repos/${repo.repo}/traffic/clones`);\n      const referrersPromise = http.get(`/repos/${repo.repo}/traffic/popular/referrers`);\n      const pathsPromise = http.get(`/repos/${repo.repo}/traffic/popular/paths`);\n      \n      const trafficRes = await Promise.all([viewsPromise, clonesPromise, referrersPromise, pathsPromise]);\n      \n      await TrafficDao.put({\n        repo: repo.repo,\n        date: dateStr,\n        views: trafficRes[0].data.views,\n        clones: trafficRes[1].data.clones,\n        referrers: trafficRes[2].data,\n        paths: trafficRes[3].data,\n        repoCreatedAt: repo.createdAt,\n      });\n    } catch (error) {\n      if(error.response) {\n        console.log(error.response.message);\n      } else {\n        console.log(error.message)\n      }\n    }\n\n  }\n}\n\nrun();"
  },
  {
    "path": "backend/scripts/getStarsAndSaveDbForRepoWithoutRepos.js",
    "content": "const { GraphQLClient } = require('graphql-request');\nconst guess = require('./guessCountryFromAddress');\n\nconst UserDao = require('../db/User');\n\n/**\n * Get all stargazers of a repo and store to db\n * \n * {\n *   totalCount: '',\n *   updatedAt: '',\n *   history: {\n *     '2018-04-12': 10,\n *   },\n *   locations: {\n *     china: 3,\n *   }\n * }\n */\n\nconst getStars = async (username, repoPath) => {\n  const res = {\n    totalCount: 0,\n    updatedAt: '',\n    history: {},\n    locations: {},\n  };\n\n  const user = await UserDao.get({username});\n  const token = user.accessToken.S;\n  const [repoOwner, repoName] = repoPath.split('/')\n\n  const endpoint = 'https://api.github.com/graphql';\n\n  const graphQLClient = new GraphQLClient(endpoint, {\n    headers: {\n      Authorization: `bearer ${token}`,\n    },\n  })\n\n  const query = `\n    {\n      repository(owner: \"${repoOwner}\", name: \"${repoName}\") {\n        stargazers(first: 100) {\n          nodes {\n            location\n          }\n          edges {\n            starredAt\n          }\n          totalCount\n          pageInfo {\n            hasNextPage\n            endCursor\n          }\n        }\n      }\n    }  \n  `;\n\n  let data = await graphQLClient.request(query);\n  res.totalCount = data.repository.stargazers.totalCount;\n\n  const updateRes = (stargazers) => {\n    const dateArr = stargazers.edges;\n    const userArr = stargazers.nodes;\n\n    dateArr.forEach(element => {\n      const starDate = element.starredAt.slice(0, 10);\n      if(res.history[starDate]) {\n        res.history[starDate] = res.history[starDate] + 1;\n      } else {\n        res.history[starDate] = 1;\n      }\n    });\n\n    userArr.forEach(el => {\n      if (el.location) {\n        const location = guess(el.location);\n        if (location) res.locations[location]\n          ? res.locations[location] = res.locations[location] + 1 \n          : res.locations[location] = 1;\n      }\n    })\n  }\n\n  updateRes(data.repository.stargazers);\n\n  let pageCount = 0\n  while(data.repository.stargazers.pageInfo.hasNextPage) {\n    console.log('page count', pageCount + 1);\n    const query2 = `\n    {\n      repository(owner: \"${repoOwner}\", name: \"${repoName}\") {\n        stargazers(first: 100, after: \"${data.repository.stargazers.pageInfo.endCursor}\") {\n          nodes {\n            location\n          }\n          edges {\n            starredAt\n          }\n          totalCount\n          pageInfo {\n            hasNextPage\n            endCursor\n          }\n        }\n      }\n    }   \n    `;\n    data = await graphQLClient.request(query2);\n    updateRes(data.repository.stargazers); \n    pageCount++;\n  }\n\n  res.updatedAt = new Date().toISOString();\n  // console.log(res)\n  return res;\n}\n\n\nmodule.exports = getStars;\n// getStars('timqian', 't9tio/cloudquery')\n"
  },
  {
    "path": "backend/scripts/guessCountryFromAddress.js",
    "content": "const countries = require('./countries.json');\n\nconst guess = (address) => {\n  const lowerCaseAddr = address.toLowerCase();\n  let guess = null;\n  for(let i = 0; i < countries.length; i++) {\n    const country = countries[i];\n    if (lowerCaseAddr.includes(country.country)) {\n      guess = country.country;\n      break;\n    }\n\n    for(let j = 0; j < country.alias.length; j++) {\n      if (lowerCaseAddr.includes(country.alias[j])) {\n        guess = country.country;\n        break;\n      }\n    }\n\n    for(let j = 0; j < country.cities.length; j++) {\n      if (lowerCaseAddr.includes(country.cities[j])) {\n        guess = country.country;\n        break;\n      }\n    }\n\n    if (guess) break;\n  }\n  return guess;\n}\n\nmodule.exports = guess;\n\n// // test\n// console.log(guess('China'));\n// console.log(guess('beijing, china'));\n// console.log(guess('USA'));\n// console.log(guess('new york'));\nconsole.log(guess('inia'))"
  },
  {
    "path": "backend/server.js",
    "content": "const express = require('express');\nconst cors = require('cors');\nconst bodyParser = require('body-parser');\nconst passport = require('passport');\nconst GitHubStrategy = require('passport-github').Strategy;\nconst jwt = require('jwt-simple');\nconst UserDao = require('./db/User');\nconst RepoDao = require('./db/Repo');\nconst TrafficDao = require('./db/Traffic');\nconst StarDao = require('./db/Star');\nconst config = require('./secret.json');\nconst trafficDateRangeToDateArr = require('./utils/trafficDateRangeToDateArr');\nconst getUniqueListBy = require('./utils/getUniqueListBy');\nconst getTrafficOfRepoAndSave = require('./utils/getTrafficOfRepoAndSave');\nconst getStars = require('./utils/getStars');\n\nconst app = express();\n\napp.use(cors());\napp.use(bodyParser.json());\napp.use(passport.initialize());\n\npassport.use(\n  new GitHubStrategy(\n    {\n      clientID: config.github.clientID,\n      clientSecret: config.github.clientSecret,\n      scope: 'user:email,public_repo',\n      callbackURL: 'https://repo-analytics.t9t.io/auth/github/callback',\n    },\n    async (accessToken, refreshToken, profile, cb) => {\n      /**\n       * {\n       *   id: '5512552',\n       *   displayName: 'Tim Qian',\n       *   username: 'timqian',\n       *   profileUrl: 'https://github.com/timqian',\n       *   emails: [\n       *     { value: 'timqian92@gmail.com', primary: false, verified: true },\n       *     { value: 'timqian92@qq.com', primary: true, verified: false },\n       *     { value: 'timqian@shu.edu.cn', primary: false, verified: true }\n       *   ],\n       *   photos: [{ value: 'https://avatars3.githubusercontent.com/u/5512552?v=4' }],\n       * }\n       */\n      const {\n        id, username, displayName, emails, photos,\n      } = profile;\n      // FIXME: add updatedAt to record user relogin\n      // const user = await UserDao.get({ username });\n\n      // console.log(emails)\n      const userToSave = {\n        username,\n\n        accessToken,\n        email: emails.filter(email => email.primary === true)[0].value,\n        photo: photos[0].value,\n      };\n\n      if (displayName) userToSave.displayName = displayName;\n\n      // if (!user) {\n        await UserDao.put(userToSave);\n      // }\n      profile.accessToken = accessToken\n      cb(null, profile);\n    },\n  ),\n);\n\napp.get(\n  '/auth/github',\n  passport.authenticate('github'),\n);\n\napp.get(\n  '/auth/github/callback',\n  passport.authenticate('github', { failureRedirect: '/login', session: false }),\n  async (req, res) => {\n    const {\n      id, username, displayName, emails, photos,\n    } = req.user;\n\n    const token = jwt.encode({ username }, config.jwtSecret);\n    res.redirect(`https://repo-analytics.github.io/${username}?username=${username}&photo=${photos[0].value}&token=${token}`);\n  },\n);\n\n/**\n * {\n *   repos: [{\n *     username: 'timqian',\n *     repo: 'timqian/chart.xkcd',\n *     createdAt: '',\n *     views: [{\"timestamp\":\"2019-09-29T00:00:00Z\",\"count\":11,\"uniques\":8}],\n *   }]\n * }\n */\napp.get('/user/:username', async (req, res) => {\n  const username = req.params.username;\n  const repos = await RepoDao.getAllForUser({ username });\n  const promiseArr = repos.map(repo => {\n    const repoPath = repo.repo.S;\n    // FIXME: getting unnecessary data - add another method\n    return TrafficDao.getLatest({ repo: repoPath });\n  });\n\n  const traffics = await Promise.all(promiseArr);\n  const returnRepos = repos.map((repo, i) => {\n\n    const obj = {\n      username: repo.username.S,\n      repo: repo.repo.S,\n      createdAt: repo.createdAt.S,\n      views: JSON.parse(traffics[i].views.S),\n    }\n\n    return obj;\n  });\n\n  res.json({\n    repos: returnRepos,\n  })\n});\n\n/**\n * @returns - grouped: vistit and clone data; 14 days: referrer and paths data\n * {\n *   views: [{\n *     timestamp: '2019-03-12',\n *     count: 500,\n *     unique: 300.\n *   }],\n *   clones: [{\n *     timestamp: '2019-03-12',\n *     count: 500,\n *     unique: 300.\n *   }],\n * }\n */\napp.get('/repo/:org/:repo', async (req, res) => {\n  const org = req.params.org;\n  const repo = req.params.repo;\n  const repoPath = `${org}/${repo}`;\n\n  const latestTrafficData = await TrafficDao.getLatest({ repo: repoPath });\n  const trafficObj = {\n    date: latestTrafficData.date.S, // date when latest traffic data created\n    repoCreatedAt: latestTrafficData.repoCreatedAt.S, // when do we start to collect data\n    views: JSON.parse(latestTrafficData.views.S), // all data\n    clones: JSON.parse(latestTrafficData.clones.S), // all data\n    referrers: JSON.parse(latestTrafficData.referrers.S), // last 14 days\n    paths: JSON.parse(latestTrafficData.paths.S), // last 14 days\n  }\n\n  // 4. combine views and clones data - how, choose larger count if timestamp is the same\n  // assuming traffic data exists for everyday\n  const dateArr = trafficDateRangeToDateArr(trafficObj.repoCreatedAt.slice(0,10), trafficObj.date);\n\n  // No need to get more clone and view data\n  if (!dateArr) {\n    res.json({\n      traffic: trafficObj,\n    });\n    return;\n  }\n\n  const batchRes = await TrafficDao.batchGetViewAndClones({ repo: repoPath, dateArr });\n\n  for (const traffic of batchRes) {\n    const clones = JSON.parse(traffic.clones.S);\n    const views = JSON.parse(traffic.views.S);\n    trafficObj.clones.unshift(...clones);\n    trafficObj.views.unshift(...views);\n  }\n\n  trafficObj.clones = getUniqueListBy(trafficObj.clones, 'timestamp')\n    .sort((a, b) => new Date(a.timestamp) - new Date(b.timestamp));\n  trafficObj.views = getUniqueListBy(trafficObj.views, 'timestamp')\n    .sort((a, b) => new Date(a.timestamp) - new Date(b.timestamp));\n\n  res.json({\n    traffic: trafficObj,\n  });\n\n});\n\napp.get('/repo/:org/:repo/stars', async (req, res) => {\n  const org = req.params.org;\n  const repo = req.params.repo;\n  const repoPath = `${org}/${repo}`; \n  const starRes = await StarDao.get({repo: repoPath});\n\n  const starObj = {\n    repo: starRes.repo.S,\n    totalCount: starRes.totalCount.S,\n    history: JSON.parse(starRes.history.S),\n    locations: JSON.parse(starRes.locations.S),\n    updatedAt: starRes.updatedAt.S,\n  }\n  res.json(starObj);\n});\n\napp.post('/repo/add', async (req, res) => {\n  const { username, repoPath, token } = req.body;\n  // 1. test if the user is allowed to add repo to username\n  let decoded;\n  try {\n    decoded = jwt.decode(token, config.jwtSecret);\n  } catch (error) {\n    res.status(400).json('bad token');\n    return;\n  }\n  if (decoded.username !== username) {\n    res.status(400).json('token user mismatch');\n    return;\n  }\n\n  // 2. test if user already have 3 repos TODO: remove after finishing billing part\n\n  const userCurrentRepos = await RepoDao.getAllForUser({username});\n  if (userCurrentRepos.length >= 3 && !config.patrons.includes(username) ) {\n    res.status(400).json('Currently we only support importing 3 repos, see pricing page for more info');\n    return;\n  }\n\n  // 3. test if user being able to get traffic of the repo\n  const user = await UserDao.get({ username });\n  const githubToken = user.accessToken.S;\n  try {\n    await getTrafficOfRepoAndSave({ repoPath, token: githubToken });\n    // create repo\n    await RepoDao.put({\n      username,\n      repo: repoPath,\n    });\n\n    // add star analytics(async)\n    getStars(username, repoPath)\n      .then(res => {\n        StarDao.put({\n          repo: repoPath,\n          ...res\n        });\n      });\n\n    res.json('ok');\n  } catch (e) {\n    console.log(e)\n    res.status(400).json('github token permission insufficient');\n  }\n})\n\napp.get('/', (req, res) => {\n  res.json('hey')\n});\n\nconst { PORT = 8080 } = process.env;\napp.listen(PORT);\nconsole.log(`server running on http://localhost:${PORT}`);\n"
  },
  {
    "path": "backend/up.json",
    "content": "{\n  \"name\": \"repo-traffic\",\n  \"profile\": \"timConsole\",\n  \"regions\": [\"us-east-1\"],\n  \"error_pages\": {\n    \"variables\": {\n      \"support_email\": \"timqian@t9t.io\",\n      \"color\": \"#228ae6\"\n    }\n  },\n  \"stages\": {\n    \"production\": {\n      \"domain\": \"repo-analytics.t9t.io\"\n    },\n    \"staging\": {\n      \"domain\": \"repo-analytics-staging.t9t.io\"\n    }\n  },\n  \"lambda\": {\n    \"memory\": 1536\n  }\n}"
  },
  {
    "path": "backend/utils/getStars.js",
    "content": "const { GraphQLClient } = require('graphql-request');\nconst guess = require('../scripts/guessCountryFromAddress');\n\nconst UserDao = require('../db/User');\n\n/**\n * Get all stargazers of a repo and store to db\n * \n * {\n *   totalCount: '',\n *   updatedAt: '',\n *   history: {\n *     '2018-04-12': 10,\n *   },\n *   locations: {\n *     china: 3,\n *   }\n * }\n */\n\nconst getStars = async (username, repoPath) => {\n  const res = {\n    totalCount: 0,\n    updatedAt: '',\n    history: {},\n    locations: {},\n  };\n\n  const user = await UserDao.get({username});\n  const token = user.accessToken.S;\n  const [repoOwner, repoName] = repoPath.split('/')\n\n  const endpoint = 'https://api.github.com/graphql';\n\n  const graphQLClient = new GraphQLClient(endpoint, {\n    headers: {\n      Authorization: `bearer ${token}`,\n    },\n  })\n\n  const query = `\n    {\n      repository(owner: \"${repoOwner}\", name: \"${repoName}\") {\n        stargazers(first: 100) {\n          nodes {\n            location\n          }\n          edges {\n            starredAt\n          }\n          totalCount\n          pageInfo {\n            hasNextPage\n            endCursor\n          }\n        }\n      }\n    }  \n  `;\n\n  let data = await graphQLClient.request(query);\n  res.totalCount = data.repository.stargazers.totalCount;\n\n  const updateRes = (stargazers) => {\n    const dateArr = stargazers.edges;\n    const userArr = stargazers.nodes;\n\n    dateArr.forEach(element => {\n      const starDate = element.starredAt.slice(0, 10);\n      if(res.history[starDate]) {\n        res.history[starDate] = res.history[starDate] + 1;\n      } else {\n        res.history[starDate] = 1;\n      }\n    });\n\n    userArr.forEach(el => {\n      if (el.location) {\n        const location = guess(el.location);\n        if (location) res.locations[location]\n          ? res.locations[location] = res.locations[location] + 1 \n          : res.locations[location] = 1;\n      }\n    })\n  }\n\n  updateRes(data.repository.stargazers);\n\n  while(data.repository.stargazers.pageInfo.hasNextPage) {\n    console.log(data.repository.stargazers.pageInfo)\n    const query2 = `\n    {\n      repository(owner: \"${repoOwner}\", name: \"${repoName}\") {\n        stargazers(first: 100, after: \"${data.repository.stargazers.pageInfo.endCursor}\") {\n          nodes {\n            location\n          }\n          edges {\n            starredAt\n          }\n          totalCount\n          pageInfo {\n            hasNextPage\n            endCursor\n          }\n        }\n      }\n    }   \n    `;\n    data = await graphQLClient.request(query2);\n    updateRes(data.repository.stargazers); \n  }\n\n  res.updatedAt = new Date().toISOString();\n  // console.log(res)\n  return res;\n}\n\n\nmodule.exports = getStars;\n// getStars('timqian', 't9tio/cloudquery')\n"
  },
  {
    "path": "backend/utils/getTrafficOfRepoAndSave.js",
    "content": "const axios = require('axios');\nconst TrafficDao = require('../db/Traffic');\n\nconst func = async ({ repoPath, token }) => {\n  const http = axios.create({\n    baseURL: 'https://api.github.com/',\n    timeout: 10000,\n    headers: {\n      'Accept': 'application/vnd.github.v3+json',\n      'Authorization': `token ${token}`,\n    },\n  });\n  const viewsPromise = http.get(`/repos/${repoPath}/traffic/views`);\n  const clonesPromise = http.get(`/repos/${repoPath}/traffic/clones`);\n  const referrersPromise = http.get(`/repos/${repoPath}/traffic/popular/referrers`);\n  const pathsPromise = http.get(`/repos/${repoPath}/traffic/popular/paths`);\n\n  const trafficRes = await Promise.all([viewsPromise, clonesPromise, referrersPromise, pathsPromise]);\n\n  const dateStr = new Date().toISOString().slice(0, 10);\n\n  await TrafficDao.put({\n    repo: repoPath,\n    date: dateStr,\n    views: trafficRes[0].data.views,\n    clones: trafficRes[1].data.clones,\n    referrers: trafficRes[2].data,\n    paths: trafficRes[3].data,\n    repoCreatedAt: new Date().toISOString(),\n  });\n}\n\nmodule.exports = func;\n\n// test\n// func({repoPath: 'timqian/chart.xkcd', token: ''})"
  },
  {
    "path": "backend/utils/getUniqueListBy.js",
    "content": "function getUniqueListBy(arr, key) {\n  return [...new Map(arr.map(item => [item[key], item])).values()]\n}\n\nmodule.exports = getUniqueListBy;\n\n// // test\n// const res = getUniqueListBy([ { timestamp: '2019-09-27T00:00:00Z', count: 586, uniques: 352 },\n// { timestamp: '2019-09-28T00:00:00Z', count: 175, uniques: 121 },\n// { timestamp: '2019-09-29T00:00:00Z', count: 405, uniques: 251 },\n// { timestamp: '2019-09-30T00:00:00Z', count: 322, uniques: 182 },\n// { timestamp: '2019-10-01T00:00:00Z', count: 94, uniques: 58 },\n// { timestamp: '2019-10-02T00:00:00Z', count: 152, uniques: 99 },\n// { timestamp: '2019-10-03T00:00:00Z', count: 166, uniques: 91 },\n// { timestamp: '2019-10-04T00:00:00Z', count: 83, uniques: 56 },\n// { timestamp: '2019-10-05T00:00:00Z', count: 39, uniques: 31 },\n// { timestamp: '2019-10-06T00:00:00Z', count: 92, uniques: 43 },\n// { timestamp: '2019-10-07T00:00:00Z', count: 200, uniques: 96 },\n// { timestamp: '2019-10-08T00:00:00Z', count: 255, uniques: 135 },\n// { timestamp: '2019-10-09T00:00:00Z', count: 405, uniques: 161 },\n// { timestamp: '2019-10-10T00:00:00Z', count: 236, uniques: 120 },\n// { timestamp: '2019-09-27T00:00:00Z', count: 586, uniques: 352 },\n// { timestamp: '2019-09-28T00:00:00Z', count: 175, uniques: 121 },\n// { timestamp: '2019-09-29T00:00:00Z', count: 405, uniques: 251 },\n// { timestamp: '2019-09-30T00:00:00Z', count: 322, uniques: 182 },\n// { timestamp: '2019-10-01T00:00:00Z', count: 94, uniques: 58 },\n// { timestamp: '2019-10-02T00:00:00Z', count: 152, uniques: 99 },\n// { timestamp: '2019-10-03T00:00:00Z', count: 166, uniques: 91 },\n// { timestamp: '2019-10-04T00:00:00Z', count: 83, uniques: 56 },\n// { timestamp: '2019-10-05T00:00:00Z', count: 39, uniques: 31 },\n// { timestamp: '2019-10-06T00:00:00Z', count: 92, uniques: 43 },\n// { timestamp: '2019-10-07T00:00:00Z', count: 200, uniques: 96 },\n// { timestamp: '2019-10-08T00:00:00Z', count: 255, uniques: 135 },\n// { timestamp: '2019-10-09T00:00:00Z', count: 405, uniques: 161 },\n// { timestamp: '2019-10-10T00:00:00Z', count: 236, uniques: 120 } ], 'timestamp');\n\n// console.log(res);"
  },
  {
    "path": "backend/utils/trafficDateRangeToDateArr.js",
    "content": "const dayjs = require('dayjs');\n/**\n * @param {String} earliestDate\n * @param {String} latestDate\n * @return {Array} date array\n * \n * @example\n *   // ['2019-03-19', '2019-04-02', ..., '2019-10-01']\n *   func('2019-03-19', '2019-10-10')\n */\nfunction func(earliestDate, latestDate) {\n  const earliestDay = dayjs(earliestDate);\n  const latestDay = dayjs(latestDate);\n  const daysCount = latestDay.diff(earliestDay, 'day');\n\n  if (daysCount <= 0) return undefined;\n\n  let daysToGet = [earliestDay.format('YYYY-MM-DD')];\n  if (daysCount > 14) {\n    let curDay = earliestDay.add(14, 'days');\n    while (curDay.isBefore(latestDay)) {\n      daysToGet.push(curDay.format('YYYY-MM-DD'));\n      curDay = curDay.add(14, 'days');\n    }\n  }\n\n  return daysToGet;\n}\n\nmodule.exports = func;\n\n// // test\n// console.log(func('2019-03-19', '2019-10-10'));\n// console.log(func('2019-10-08', '2019-10-10'));\n// console.log(func('2019-10-01', '2019-10-10'));"
  },
  {
    "path": "frontend/.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# production\n/build\n\n# misc\n.DS_Store\n.env.local\n.env.development.local\n.env.test.local\n.env.production.local\n\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n"
  },
  {
    "path": "frontend/README.md",
    "content": "# Frontend code base of repo-traffic\n\n## Important Scripts\n\n```bash\n# start dev server\nnpm start\n\n# build website\nnpm build\n\n# deploy to github pages\nnpm run deploy\n```\n\n## TODO\n\n- [Make it an PWA](https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app)\n\nThis project was bootstrapped with [Create React App](https://github.com/facebook/create-react-app).\n\n## Available Scripts\n\nIn the project directory, you can run:\n\n### `npm start`\n\nRuns the app in the development mode.<br>\nOpen [http://localhost:3000](http://localhost:3000) to view it in the browser.\n\nThe page will reload if you make edits.<br>\nYou will also see any lint errors in the console.\n\n### `npm test`\n\nLaunches the test runner in the interactive watch mode.<br>\nSee the section about [running tests](https://facebook.github.io/create-react-app/docs/running-tests) for more information.\n\n### `npm run build`\n\nBuilds the app for production to the `build` folder.<br>\nIt correctly bundles React in production mode and optimizes the build for the best performance.\n\nThe build is minified and the filenames include the hashes.<br>\nYour app is ready to be deployed!\n\nSee the section about [deployment](https://facebook.github.io/create-react-app/docs/deployment) for more information.\n\n### `npm run eject`\n\n**Note: this is a one-way operation. Once you `eject`, you can’t go back!**\n\nIf you aren’t satisfied with the build tool and configuration choices, you can `eject` at any time. This command will remove the single build dependency from your project.\n\nInstead, it will copy all the configuration files and the transitive dependencies (Webpack, Babel, ESLint, etc) right into your project so you have full control over them. All of the commands except `eject` will still work, but they will point to the copied scripts so you can tweak them. At this point you’re on your own.\n\nYou don’t have to ever use `eject`. The curated feature set is suitable for small and middle deployments, and you shouldn’t feel obligated to use this feature. However we understand that this tool wouldn’t be useful if you couldn’t customize it when you are ready for it.\n\n## Learn More\n\nYou can learn more in the [Create React App documentation](https://facebook.github.io/create-react-app/docs/getting-started).\n\nTo learn React, check out the [React documentation](https://reactjs.org/).\n\n### Code Splitting\n\nThis section has moved here: https://facebook.github.io/create-react-app/docs/code-splitting\n\n### Analyzing the Bundle Size\n\nThis section has moved here: https://facebook.github.io/create-react-app/docs/analyzing-the-bundle-size\n\n### Making a Progressive Web App\n\nThis section has moved here: https://facebook.github.io/create-react-app/docs/making-a-progressive-web-app\n\n### Advanced Configuration\n\nThis section has moved here: https://facebook.github.io/create-react-app/docs/advanced-configuration\n\n### Deployment\n\nThis section has moved here: https://facebook.github.io/create-react-app/docs/deployment\n\n### `npm run build` fails to minify\n\nThis section has moved here: https://facebook.github.io/create-react-app/docs/troubleshooting#npm-run-build-fails-to-minify\n"
  },
  {
    "path": "frontend/package.json",
    "content": "{\n  \"name\": \"frontend\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"dependencies\": {\n    \"axios\": \"^0.19.0\",\n    \"chart.xkcd\": \"^1.1.7\",\n    \"notie\": \"^4.3.1\",\n    \"query-string\": \"^6.8.3\",\n    \"react\": \"^16.10.1\",\n    \"react-content-loader\": \"^4.3.1\",\n    \"react-dom\": \"^16.10.1\",\n    \"react-github-btn\": \"^1.0.6\",\n    \"react-router-dom\": \"^5.1.1\",\n    \"react-scripts\": \"3.1.2\",\n    \"remixicon\": \"^2.0.0\"\n  },\n  \"scripts\": {\n    \"start\": \"react-scripts start\",\n    \"build\": \"react-scripts build\",\n    \"test\": \"react-scripts test\",\n    \"eject\": \"react-scripts eject\",\n    \"deploy\": \"npm run build && gh-pages -d build -b master\"\n  },\n  \"eslintConfig\": {\n    \"extends\": \"react-app\"\n  },\n  \"browserslist\": {\n    \"production\": [\n      \">0.2%\",\n      \"not dead\",\n      \"not op_mini all\"\n    ],\n    \"development\": [\n      \"last 1 chrome version\",\n      \"last 1 firefox version\",\n      \"last 1 safari version\"\n    ]\n  },\n  \"devDependencies\": {\n    \"gh-pages\": \"^2.1.1\"\n  }\n}\n"
  },
  {
    "path": "frontend/public/404.html",
    "content": "<!DOCTYPE html>\n<html>\n  <head>\n    <meta charset=\"utf-8\">\n    <title>Single Page Apps for GitHub Pages</title>\n    <script type=\"text/javascript\">\n      // Single Page Apps for GitHub Pages\n      // https://github.com/rafrex/spa-github-pages\n      // Copyright (c) 2016 Rafael Pedicini, licensed under the MIT License\n      // ----------------------------------------------------------------------\n      // This script takes the current url and converts the path and query\n      // string into just a query string, and then redirects the browser\n      // to the new url with only a query string and hash fragment,\n      // e.g. http://www.foo.tld/one/two?a=b&c=d#qwe, becomes\n      // http://www.foo.tld/?p=/one/two&q=a=b~and~c=d#qwe\n      // Note: this 404.html file must be at least 512 bytes for it to work\n      // with Internet Explorer (it is currently > 512 bytes)\n      // If you're creating a Project Pages site and NOT using a custom domain,\n      // then set segmentCount to 1 (enterprise users may need to set it to > 1).\n      // This way the code will only replace the route part of the path, and not\n      // the real directory in which the app resides, for example:\n      // https://username.github.io/repo-name/one/two?a=b&c=d#qwe becomes\n      // https://username.github.io/repo-name/?p=/one/two&q=a=b~and~c=d#qwe\n      // Otherwise, leave segmentCount as 0.\n      var segmentCount = 0;\n      var l = window.location;\n      l.replace(\n        l.protocol + '//' + l.hostname + (l.port ? ':' + l.port : '') +\n        l.pathname.split('/').slice(0, 1 + segmentCount).join('/') + '/?p=/' +\n        l.pathname.slice(1).split('/').slice(segmentCount).join('/').replace(/&/g, '~and~') +\n        (l.search ? '&q=' + l.search.slice(1).replace(/&/g, '~and~') : '') +\n        l.hash\n      );\n    </script>\n  </head>\n  <body>\n  </body>\n</html>"
  },
  {
    "path": "frontend/public/index.html",
    "content": "<!DOCTYPE html>\n<html lang=\"en\">\n  <head>\n    <meta charset=\"utf-8\" />\n    <link rel=\"shortcut icon\" href=\"%PUBLIC_URL%/favicon.ico\" />\n    <meta name=\"viewport\" content=\"width=device-width, initial-scale=1\" />\n    <meta name=\"theme-color\" content=\"#000000\" />\n    <meta\n      name=\"description\"\n      content=\"Thorough analytics for your GitHub repos\"\n    />\n    <link rel=\"apple-touch-icon\" href=\"logo.png\" />\n    <!--\n      manifest.json provides metadata used when your web app is installed on a\n      user's mobile device or desktop. See https://developers.google.com/web/fundamentals/web-app-manifest/\n    -->\n    <link rel=\"manifest\" href=\"%PUBLIC_URL%/manifest.json\" />\n    <link rel=\"stylesheet\" type=\"text/css\" href=\"https://unpkg.com/notie/dist/notie.min.css\">\n    <!--\n      Notice the use of %PUBLIC_URL% in the tags above.\n      It will be replaced with the URL of the `public` folder during the build.\n      Only files inside the `public` folder can be referenced from the HTML.\n\n      Unlike \"/favicon.ico\" or \"favicon.ico\", \"%PUBLIC_URL%/favicon.ico\" will\n      work correctly both with client-side routing and a non-root public URL.\n      Learn how to configure a non-root public URL by running `npm run build`.\n    -->\n    <title>Repo Analytics</title>\n  </head>\n  <body>\n    <noscript>You need to enable JavaScript to run this app.</noscript>\n    <div id=\"root\"></div>\n    <!--\n      This HTML file is a template.\n      If you open it directly in the browser, you will see an empty page.\n\n      You can add webfonts, meta tags, or analytics to this file.\n      The build step will place the bundled scripts into the <body> tag.\n\n      To begin the development, run `npm start` or `yarn start`.\n      To create a production bundle, use `npm run build` or `yarn build`.\n    -->\n    \n    <!-- Start Single Page Apps for GitHub Pages -->\n    <script type=\"text/javascript\">\n      // Single Page Apps for GitHub Pages\n      // https://github.com/rafrex/spa-github-pages\n      // Copyright (c) 2016 Rafael Pedicini, licensed under the MIT License\n      // ----------------------------------------------------------------------\n      // This script checks to see if a redirect is present in the query string\n      // and converts it back into the correct url and adds it to the\n      // browser's history using window.history.replaceState(...),\n      // which won't cause the browser to attempt to load the new url.\n      // When the single page app is loaded further down in this file,\n      // the correct url will be waiting in the browser's history for\n      // the single page app to route accordingly.\n      (function(l) {\n        if (l.search) {\n          var q = {};\n          l.search.slice(1).split('&').forEach(function(v) {\n            var a = v.split('=');\n            q[a[0]] = a.slice(1).join('=').replace(/~and~/g, '&');\n          });\n          if (q.p !== undefined) {\n            window.history.replaceState(null, null,\n              l.pathname.slice(0, -1) + (q.p || '') +\n              (q.q ? ('?' + q.q) : '') +\n              l.hash\n            );\n          }\n        }\n      }(window.location))\n    </script>\n    <!-- End Single Page Apps for GitHub Pages -->\n  </body>\n</html>\n"
  },
  {
    "path": "frontend/public/manifest.json",
    "content": "{\n  \"short_name\": \"Repo Analytics\",\n  \"name\": \"Create React App Sample\",\n  \"icons\": [\n    {\n      \"src\": \"favicon.ico\",\n      \"type\": \"image/x-icon\"\n    },\n    {\n      \"src\": \"logo.png\",\n      \"type\": \"image/png\"\n    }\n  ],\n  \"start_url\": \".\",\n  \"display\": \"standalone\",\n  \"theme_color\": \"#000000\",\n  \"background_color\": \"#ffffff\"\n}\n"
  },
  {
    "path": "frontend/public/robots.txt",
    "content": "# https://www.robotstxt.org/robotstxt.html\nUser-agent: *\n"
  },
  {
    "path": "frontend/src/App.css",
    "content": "a {\n  color: #0366d6;\n  text-decoration: none;\n}\n\na:hover {\n  text-decoration: none;\n}\n\nheader {\n  display: flex;\n  justify-content: space-between;\n  align-items: center;\n  padding: 16px;\n  font-size: 15px;\n  line-height: 1.5;\n  color: hsla(0,0%,100%,.7);\n  background-color: #24292e;\n}\n\n.header-left {\n  display: flex;\n  align-items: center;\n}\n\n.header-link {\n  font-weight: 600;\n  color: #fff;\n  white-space: nowrap;\n  cursor: pointer;\n  user-select: none;\n}\n\n.header-link:hover {\n  color: #bbb;\n}\n\n\n.dropdown {\n  position: relative;\n  display: inline-block;\n}\n\n/* Dropdown Content (Hidden by Default) */\n.dropdown-content {\n  display: none;\n  position: absolute;\n  padding-top: 8px;\n  right: 0;\n  background-color: #ffffff00;\n  min-width: 120px;\n  box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);\n  z-index: 1;\n  border-radius: 5px;\n}\n\n/* Links inside the dropdown */\n.dropdown-content a {\n  color: black;\n  background-color: #f9f9f9;\n  padding: 5px 16px;\n  display: block;\n  cursor: pointer;\n}\n\n/* Change color of dropdown links on hover */\n.dropdown-content a:hover {\n  background-color: #0366d6;\n  color: white;\n}\n\n.dropdown-content hr {\n  margin: 0;\n  height: 0;\n  overflow: hidden;\n  background-color: #f9f9f9;\n  border: 0;\n  border-bottom: 1px solid #dfe2e5;\n}\n\n/* Show the dropdown menu on hover */\n.dropdown:hover .dropdown-content {\n  display: block;\n}\n"
  },
  {
    "path": "frontend/src/App.js",
    "content": "import React from \"react\";\nimport { BrowserRouter as Router, Route, Link } from \"react-router-dom\";\nimport './App.css';\nimport Home from './pages/Home';\nimport User from './pages/User';\nimport Repo from './pages/Repo';\nimport queryString from 'query-string';\nimport userSignedIn from './utils/userSignedIn';\n\nexport default function App() {\n  let user = userSignedIn.get();\n\n  if (window.location.search.length > 0) {\n    try {\n      const userFromSearch = queryString.parse(window.location.search);\n      userSignedIn.set({\n        username: userFromSearch.username,\n        token: userFromSearch.token,\n        photo: userFromSearch.photo\n      });\n      user = userSignedIn.get();\n      window.history.replaceState({}, document.title, window.location.origin + window.location.pathname);\n    } catch (err) {\n      console.log('bad query string');\n    }\n  }\n\n  function signout () {\n    userSignedIn.remove();\n    window.location.reload();\n  }\n\n  return (\n    <Router>\n      <header>\n        <div className=\"header-left\">\n          <img src=\"/logo.png\" alt=\"logo\" width=\"30px\"/>\n          &nbsp;\n          <Link to=\"/\" className=\"header-link\">Repo Analytics</Link>\n        </div>\n        <div>\n          {\n            user.username ? \n            <div className=\"dropdown\">\n              <a className=\"header-link\" href>{user.username} <span style={{fontSize:'10px'}}>▼</span></a>\n              <div className=\"dropdown-content\">\n                <a href={`/${user.username}`}>Your profile</a>\n                <a href={`/${user.username}`}>Add repo</a>\n                <a href=\"https://github.com/repo-analytics/repo-analytics.github.io/issues/1\">Pricing</a>\n                <hr/>\n                <a href onClick={signout} >Sign out</a>\n              </div>\n            </div>\n            :\n            <a className=\"header-link\" href=\"https://repo-analytics.t9t.io/auth/github\">Sign in with GitHub</a>\n          }\n          \n          {/* <Link to=\"/topics\">Topics</Link> */}\n        </div>\n      </header>\n      <Route exact path=\"/\" >\n        <Home user={user}/>\n      </Route>\n      <Route path=\"/topics\" component={Topics} />\n      <Route path=\"/about\" component={About} />\n\n      <Route exact path=\"/:username\" component={User} />\n      <Route path=\"/:username/:repo\" component={Repo} />\n    </Router>\n  );\n}\n\nfunction About() {\n  return (\n    <div>\n      <h2>About</h2>\n    </div>\n  );\n}\n\nfunction Topics({ match }) {\n  return (\n    <div>\n      <h2>Topics</h2>\n      <ul>\n        <li>\n          <Link to={`${match.url}/rendering`}>Rendering with React</Link>\n        </li>\n        <li>\n          <Link to={`${match.url}/components`}>Components</Link>\n        </li>\n        <li>\n          <Link to={`${match.url}/props-v-state`}>Props v. State</Link>\n        </li>\n      </ul>\n\n      <Route path={`${match.path}/:topicId`} component={Topic} />\n      <Route\n        exact\n        path={match.path}\n        render={() => <h3>Please select a topic.</h3>}\n      />\n    </div>\n  );\n}\n\nfunction Topic({ match }) {\n  return (\n    <div>\n      <h3>{match.params.topicId}</h3>\n    </div>\n  );\n}"
  },
  {
    "path": "frontend/src/App.test.js",
    "content": "import React from 'react';\nimport ReactDOM from 'react-dom';\nimport App from './App';\n\nit('renders without crashing', () => {\n  const div = document.createElement('div');\n  ReactDOM.render(<App />, div);\n  ReactDOM.unmountComponentAtNode(div);\n});\n"
  },
  {
    "path": "frontend/src/components/AddRepo.css",
    "content": ".add-new {\n  width: 100%;\n  height: 100%;\n  display:flex;\n  flex-direction: column;\n  align-items: center;\n  justify-content: center;\n  flex-wrap: wrap;\n  position: relative;\n}\n\n.add-new a {\n  font-size: 20px;\n  font-weight: 500;\n}\n\n.repo-input {\n  width: 270px;\n  background-color: #fafbfc;\n  padding: 10px 10px;\n  font-size: 16px;\n  color: #24292e;\n  border: 1px solid #d1d5da;\n  border-radius: 3px;\n  outline: none;\n  box-shadow: inset 0 1px 2px rgba(27,31,35,.075);\n}\n\n::placeholder { /* Chrome, Firefox, Opera, Safari 10.1+ */\n  color: #aaa;\n}\n\n.add-repo-btn {\n  border-radius: 3px;\n  background-color: #2ebc4f;\n  border: none;\n  padding: 10px 20px;\n  font-size: 16px;\n  font-weight: 550;\n  cursor: pointer;\n  color: white;\n  margin: 10px;\n}\n\nbutton:focus {\n  outline:none;\n}\n\n\n.add-repo-btn.isLoading {\n  background-color: #888;\n  pointer-events: none;\n}\n\n.add-repo-btn.isLoading {\n  animation: spin 1s linear infinite;\n}\n\n@keyframes spin {\n  0% { transform: rotate(0deg); }\n  25% { transform: rotate(10deg); }\n  50% { transform: rotate(0deg); }\n  75% { transform: rotate(-10deg); }\n  100% { transform: rotate(0deg); }\n}\n\n.add-new-footer {\n  position: absolute;\n  bottom: 8px;\n  right: 8px;\n\n}\n\n.add-new-footer a {\n  font-size: 14px;\n  font-weight: 500;\n}"
  },
  {
    "path": "frontend/src/components/AddRepo.js",
    "content": "import React, { useState } from \"react\";\nimport http from \"../utils/http\";\nimport userSignedIn from '../utils/userSignedIn';\nimport './AddRepo.css';\nimport { alert } from 'notie';\n\n\nconst AddRepo = () => {\n  const localUser = userSignedIn.get();\n  const [repoPath, setRepoPath] = useState();\n  const [isLoading, setIsLoading] = useState(false);\n\n  async function addRepo () {\n    try {\n      setIsLoading(true);\n      await http.addRepo({ username: localUser.username, repoPath, token: localUser.token });\n      window.location = `/${repoPath}`;\n    } catch (err) {\n      setIsLoading(false);\n      alert({\n        type: 'error', // optional, default = 4, enum: [1, 2, 3, 4, 5, 'success', 'warning', 'error', 'info', 'neutral']\n        text: `Failed: \"${err.response.data}\"`,\n        stay: false, // optional, default = false\n        time: 3, // optional, default = 3, minimum = 1,\n        position: 'top' // optional, default = 'top', enum: ['top', 'bottom']\n      })\n    }\n  }\n\n  return <div className=\"home-box\">\n    <div className=\"add-new\">\n\n      <input placeholder={`e.g. ${localUser.username}/repo-name`} className=\"repo-input\" onChange={(e) => setRepoPath(e.target.value)}></input>\n      <button className={`${isLoading ? 'isLoading' : ''} add-repo-btn`} onClick={() => addRepo()}>\n        {isLoading ? 'Adding' : 'Add repo'}\n      </button>\n      <div className=\"add-new-footer\">\n        <a href=\"https://github.com/repo-analytics/repo-analytics.github.io/issues/1\">Pricing</a>\n      </div>\n    </div>\n\n  </div>;\n}\n\nexport default AddRepo;"
  },
  {
    "path": "frontend/src/components/CardLoader.js",
    "content": "import React from \"react\"\nimport ContentLoader from \"react-content-loader\"\n\nconst MyLoader = () => (\n  <ContentLoader \n    height={220}\n    width={900}\n    speed={2}\n    primaryColor=\"#f3f3f3\"\n    secondaryColor=\"#d6d6d6\"\n  >\n    <rect x=\"9\" y=\"19\" rx=\"0\" ry=\"0\" width=\"432\" height=\"179\" /> \n    <rect x=\"460\" y=\"19\" rx=\"0\" ry=\"0\" width=\"426\" height=\"179\" /> \n    <rect x=\"494\" y=\"24\" rx=\"0\" ry=\"0\" width=\"0\" height=\"13\" /> \n    <rect x=\"394\" y=\"85\" rx=\"0\" ry=\"0\" width=\"0\" height=\"0\" />\n  </ContentLoader>\n)\n\nexport default MyLoader;"
  },
  {
    "path": "frontend/src/components/CloneChart.js",
    "content": "import React, { useEffect } from 'react';\nimport chartXkcd from 'chart.xkcd';\n\nconst VisitChart = ({ clones }) => {\n\n  const totalViewsData = clones.map(clone => ({\n    x: clone.timestamp,\n    y: clone.count,\n  }));\n  const uniqueViewsData = clones.map(clone => ({\n    x: clone.timestamp,\n    y: clone.uniques,\n  }));\n  useEffect(() => {\n    const svg = document.querySelector('.clone-chart');\n    new chartXkcd.XY(svg, {\n      // title: 'Git clones',\n      data: {\n        datasets: [{\n          label: 'Clones',\n          data: totalViewsData,\n        }, {\n          label: 'Unique Clones',\n          data: uniqueViewsData,\n        }],\n      },\n      options: {\n        xTickCount: 3,\n        yTickCount: 4,\n        legendPosition: chartXkcd.config.positionType.upLeft,\n        showLine: true,\n        timeFormat: 'MM/DD/YYYY',\n        dotSize: 0.5,\n        dataColors: ['#28a745', '#005cc5'],\n        // unxkcdify: true // TODO: configuable\n      },\n    });\n  }, []);\n\n  return <div className=\"chart-container\">\n    <h3 className=\"chart-container-header\"> Git clones </h3>\n    <div className=\"svg-container\">\n      <svg className=\"clone-chart\"></svg>\n    </div>\n  </div>\n}\n\nexport default VisitChart;\n"
  },
  {
    "path": "frontend/src/components/Footer.css",
    "content": "footer {\n  margin: 80px 0;\n  border-top: 1px solid #dfe2e5;\n  padding: 20px 8px;\n\n\n  display: flex;\n  justify-content: space-between;\n}\n\n.footer-content {\n  font-size: 16px;\n  color: #586069;\n}\n\n.footer-content a:hover {\n  text-decoration: underline;\n}\n\n\n.footer-contacts a {\n  font-size: 16px;\n  color: #586069;\n  padding-left: 4px;\n}\n\n.footer-contacts a:hover {\n  color: #888;\n}"
  },
  {
    "path": "frontend/src/components/Footer.js",
    "content": "import React from 'react';\nimport './Footer.css'\n\nconst Footer = () => (\n  <footer>\n    <div className=\"footer-content\">\n      A <a href=\"https://t9t.io\">t9t</a> project build by <a href=\"https://timqian.com\">timqian</a>\n    </div>\n    <div className=\"footer-contacts\">\n      <a href=\"https://github.com/timqian\"><i className=\"ri-github-line\"></i></a>\n      <a href=\"https://twitter.com/tim_qian\"><i className=\"ri-twitter-line\"></i></a>\n      <a href=\"https://raw.githubusercontent.com/timqian/images/master/3811553342733_.pic.jpg\"><i className=\"ri-wechat-2-line\"></i></a>\n      <a href=\"mailto:timqian@t9t.io\"><i className=\"ri-mail-line\"></i></a>\n    </div>\n  </footer>\n)\n\nexport default Footer;\n"
  },
  {
    "path": "frontend/src/components/PathChart.js",
    "content": "import React from 'react';\n\nconst Paths = ({paths}) => (\n  <div className=\"chart-container\">\n    <h3 className=\"chart-container-header\"> Popular content </h3>\n    <table>\n      <thead>\n        <tr>\n          <th>Content</th>\n          <th>Views</th>\n          <th>Unique visitors</th>\n        </tr>\n      </thead>\n      <tbody>\n        {paths.map(path => <tr>\n          <td><a href={`https://github.com/${path.path}`}>{path.path}</a></td>\n          <td>{path.count}</td>\n          <td>{path.uniques}</td>\n        </tr>)}\n      </tbody>\n    </table> \n  </div>\n);\n\nexport default Paths;\n"
  },
  {
    "path": "frontend/src/components/ProjectCard.css",
    "content": ".card-container {\n  margin: 15px;\n  font-size: 16px;\n  height: 100%;\n  position: relative;\n}\n\n.path-divider {\n  font-size: 16px;\n  /* line-height: 26px; */\n  color: #586069;\n  margin: 0 3px;\n}\n\n.project-trend {\n  /* TODO: for chart.xkcd: config padding; margin*/\n  height: 100%;\n  position: relative;\n  top: -26px;\n  z-index: 0;\n}\n\n.card-description a {\n  font-weight: 500;\n  font-size: 16px;\n  position: relative;\n  z-index: 1;\n}\n\n.card-description a:hover {\n  text-decoration: underline;\n}\n\n.card-footer {\n  position: absolute;\n  bottom: 18px;\n  right: 0;\n  font-size: 11px;\n  color: #888;\n}"
  },
  {
    "path": "frontend/src/components/ProjectCard.js",
    "content": "import React, { useRef, useEffect } from 'react';\nimport chartXkcd from 'chart.xkcd';\nimport './ProjectCard.css';\n\n\nconst ProjectCard = ({repo, createdAt, username, views}) => {\n\n  const ref = useRef();\n  const totalViewsData = views.map(view => ({\n    x: view.timestamp,\n    y: view.count,\n  }));\n  const uniqueViewsData = views.map(view => ({\n    x: view.timestamp,\n    y: view.uniques,\n  }));\n  \n  useEffect(() => {\n    if (ref.current) {\n      new chartXkcd.XY(ref.current, {\n        // title: 'Visitors',\n        data: {\n          datasets: [{\n            label: 'Views',\n            data: totalViewsData,\n          }, {\n            label: 'Unique Visitors',\n            data: uniqueViewsData,\n          }],\n        },\n        options: {\n          xTickCount: 3,\n          yTickCount: 4,\n          legendPosition: chartXkcd.config.positionType.upLeft,\n          showLine: true,\n          timeFormat: 'MM/DD/YYYY',\n          dotSize: 0.5,\n          dataColors: ['#28a745', '#005cc5'],\n          // unxkcdify: true\n        },\n      });\n    }\n  }, []);\n\n  return   <div className=\"card-container\">\n  <div className=\"card-description\">\n    <a href={`/${repo}`}>{repo}</a>\n  </div>\n\n  <div className=\"project-trend\">\n    <svg ref={ref}></svg>\n  </div>\n\n  <div className=\"card-footer\">\n    Recording analytics since {createdAt.slice(0, 10)}\n  </div>\n</div>\n};\n\nexport default ProjectCard;\n"
  },
  {
    "path": "frontend/src/components/ReferrerChart.js",
    "content": "import React from 'react';\n\nconst Referrer = ({referrers}) => {\n\n  console.log('referrers', referrers)\n  return (\n    <div className=\"chart-container\">\n      <h3 className=\"chart-container-header\"> Referring sites </h3>\n      <table>\n        <thead>\n          <tr>\n            <th>Site</th>\n            <th>Views</th>\n            <th>Unique visitors</th>\n          </tr>\n        </thead>\n        <tbody>\n          {referrers.map(referrer => <tr>\n            <td>{referrer.referrer}</td>\n            <td>{referrer.count}</td>\n            <td>{referrer.uniques}</td>\n          </tr>)}\n        </tbody>\n      </table>\n    </div>\n)};\n\nexport default Referrer;"
  },
  {
    "path": "frontend/src/components/RepoLoader.js",
    "content": "import React from 'react'\nimport ContentLoader from 'react-content-loader'\n\nconst Article = () => (\n  <ContentLoader\n    height={160}\n    width={400}\n    speed={1}\n    primaryColor=\"#f3f3f3\"\n    secondaryColor=\"#ecebeb\"\n  >\n    <rect x=\"0\" y=\"13\" rx=\"4\" ry=\"4\" width=\"400\" height=\"9\" />\n    <rect x=\"0\" y=\"29\" rx=\"4\" ry=\"4\" width=\"100\" height=\"8\" />\n    <rect x=\"0\" y=\"50\" rx=\"4\" ry=\"4\" width=\"400\" height=\"10\" />\n    <rect x=\"0\" y=\"65\" rx=\"4\" ry=\"4\" width=\"400\" height=\"10\" />\n    <rect x=\"0\" y=\"79\" rx=\"4\" ry=\"4\" width=\"100\" height=\"10\" />\n    <rect x=\"0\" y=\"99\" rx=\"5\" ry=\"5\" width=\"400\" height=\"200\" />\n  </ContentLoader>\n)\n\nexport default Article;"
  },
  {
    "path": "frontend/src/components/RepoNav.js",
    "content": "import React from \"react\";\nconst Nav = ({repoPath, selectedTab}) => {\n  return (\n    <div className=\"repo-header\">\n      <div className=\"repo-container\">\n        <h1 className=\"repo-title\">\n          <a className=\"user-link\" href={`/${repoPath}`}>\n            {repoPath}\n          </a>\n          <a className=\"user-github-link\" href={`https://github.com/${repoPath}`}>\n            <i className=\"ri-github-line\"></i>\n          </a>   \n        </h1>\n        <nav className=\"repo-nav\">\n          <a href className={selectedTab === 0 ? 'selected' : ''} href={`/${repoPath}/traffic`}>Traffic</a>\n          <a href className={selectedTab === 1 ? 'selected' : ''} href={`/${repoPath}/stars`}>Stars</a>\n          {/* <a href className={selectedTab === 2 ? 'selected' : ''} href={`/${repoPath}/settings`}>Settings</a> */}\n        </nav>\n      </div>\n    </div>\n  );\n};\n\nexport default Nav;"
  },
  {
    "path": "frontend/src/components/RepoSetting.css",
    "content": ".traffic-switch {\n  margin: 40px;\n  margin-top: 40px;\n  font-size: 20px;\n  font-weight: 300;\n  line-height: 25px;\n}\n\n\n/* The switch - the box around the slider */\n.switch {\n  position: relative;\n  display: inline-block;\n  width: 40px;\n  height: 24px;\n}\n\n/* Hide default HTML checkbox */\n.switch input {\n  opacity: 0;\n  width: 0;\n  height: 0;\n}\n\n/* The slider */\n.slider {\n  position: absolute;\n  cursor: pointer;\n  top: 0;\n  left: 0;\n  right: 0;\n  bottom: 0;\n  background-color: #ccc;\n  -webkit-transition: .4s;\n  transition: .4s;\n}\n\n.slider:before {\n  position: absolute;\n  content: \"\";\n  height: 16px;\n  width: 16px;\n  left: 4px;\n  bottom: 4px;\n  background-color: white;\n  -webkit-transition: .4s;\n  transition: .4s;\n}\n\ninput:checked + .slider {\n  background-color: #28a745;\n}\n\ninput:focus + .slider {\n  box-shadow: 0 0 1px #28a745;\n}\n\ninput:checked + .slider:before {\n  -webkit-transform: translateX(16px);\n  -ms-transform: translateX(16px);\n  transform: translateX(16px);\n}\n\n/* Rounded sliders */\n.slider.round {\n  border-radius: 24px;\n}\n\n.slider.round:before {\n  border-radius: 50%;\n}"
  },
  {
    "path": "frontend/src/components/RepoSetting.js",
    "content": "import React from 'react';\nimport './RepoSetting.css';\n\nconst Setting = () => (\n  <div className=\"repo-container\">\n    <div className=\"traffic-switch\">\n      <label className=\"switch\">\n        <input type=\"checkbox\"/>\n        <span className=\"slider round\"></span>\n      </label>\n      &nbsp; Make traffic data private\n    </div>\n  </div>\n)\n\nexport default Setting;\n"
  },
  {
    "path": "frontend/src/components/StarAnalytics.js",
    "content": "import React, { useEffect, useState } from \"react\";\nimport RepoLoader from \"./RepoLoader\";\nimport http from '../utils/http';\nimport StarHistoryChart from \"./StarHistoryChart\";\nimport StarLocationChart from \"./StarLocationChart\";\n\nconst Traffic = ({ repoPath }) => {\n  const [starData, setstarData] = useState();\n  const [isLoading, setIsLoading] = useState(false);\n\n  useEffect(() => {\n    setIsLoading(true);\n    http.getRepoStars({\n      repoPath,\n    })\n      .then(traffic => {\n        setstarData(traffic);\n        setIsLoading(false);\n      })\n      .catch(err => console.log(err));\n  }, []);\n\n  if (isLoading || !starData) {\n    return <div className=\"repo-container\">\n      <h2>Here we analyse history and location statics of your repo. </h2>\n      <p>You might need to wait for a minute or two and refresh the page if your repo have too many stars and it is the first time you open this page</p>\n      <RepoLoader/>\n    </div>\n  }\n\n  return (<div className=\"repo-container\">\n    <div className=\"dates-container\">\n      <p>Updated at {starData.updatedAt.slice(0,10)}</p>\n    </div> \n\n    <div className=\"repo-ref-paths-container\">\n      <div className=\"one-ref-path\">\n        {\n          Object.keys(starData.history).length !== 0 \n            ? <StarHistoryChart repo={starData.repo} history={starData.history}/>\n            : ''\n        }\n      </div>\n      <div className=\"one-ref-path\">\n      {\n          Object.keys(starData.locations).length !== 0 \n            ? <StarLocationChart locations={starData.locations}/>\n            : ''\n        }\n\n      </div>\n    </div>\n\n\n  </div>);\n}\n\nexport default Traffic;\n"
  },
  {
    "path": "frontend/src/components/StarHistoryChart.js",
    "content": "import React, { useState, useEffect } from 'react';\nimport chartXkcd from 'chart.xkcd';\nimport './VisitChart.css';\n\nconst StarHistoryChart = ({ repo, history, notAddingUp}) => {\n\n  const [isAdding, setIsAdding] = useState(true)\n  const dates = Object.keys(history);\n  let counts = Object.values(history);\n  if(isAdding) {\n    for(let i = 1; i < counts.length; i++) {\n      counts[i] = counts[i-1]+ counts[i]\n    }\n  }\n  const data = dates.map((date, i) => ({\n    x: date,\n    y: counts[i],\n  }));\n\n  useEffect(() => {\n    const svg = document.querySelector('.star-history-chart');\n    new chartXkcd.XY(svg, {\n      data: {\n        datasets: [{\n          label: repo,\n          data,\n        }],\n      },\n      options: {\n        xTickCount: 3,\n        yTickCount: 4,\n        legendPosition: chartXkcd.config.positionType.upLeft,\n        showLine: true,\n        timeFormat: 'YYYY-MM-DD',\n        dotSize: 0.3,\n        dataColors: ['#28a745'],\n        // unxkcdify: true\n      },\n    });\n  });\n\n  return <div className=\"chart-container\">\n  <h3 className=\"chart-container-header\"> \n    Star History   \n    <button onClick={() => setIsAdding(!isAdding)} style={{float:'right', backgroundColor:'white', borderRadius:'3px',border:'1px solid #ccc', color:'#555', cursor: 'pointer'}}> {isAdding ? 'Growth' : 'Total'} </button>\n  </h3>\n\n  <div className=\"svg-container\">\n    <svg className=\"star-history-chart\"></svg>\n  </div>\n</div>\n}\n\nexport default StarHistoryChart;\n"
  },
  {
    "path": "frontend/src/components/StarLocationChart.js",
    "content": "import React, { useEffect } from 'react';\nimport chartXkcd from 'chart.xkcd';\nimport './VisitChart.css';\n\nconst StarLocationChart = ({ locations }) => {\n\n  const locationsKeys = Object.keys(locations);\n  const counts = Object.values(locations);\n  const totalCount = counts.reduce((pre, cur) => pre + cur);\n  const topLocations = locationsKeys.sort((a, b)=> locations[b] - locations[a]).slice(0, 6);\n  const topCounts = counts.sort((a, b) => b - a).slice(0, 6);\n  const othersCount = totalCount - topCounts.reduce((pre, cur) => pre + cur);\n\n  useEffect(() => {\n    const svg = document.querySelector('.star-location-chart');\n    new chartXkcd.Pie(svg, {\n      data: {\n        labels: [...topLocations, 'others'],\n        datasets: [{\n          data: [...topCounts, othersCount],\n        }],\n      },\n      options: {\n        innerRadius: 0.5,\n        // unxkcdify: true\n      },\n    });\n  }, []);\n\n  return <div className=\"chart-container\">\n  <h3 className=\"chart-container-header\"> \n    Star Locations\n  </h3>\n\n  <p className=\"location-description\">{totalCount} valid locations detected</p>\n  <div className=\"svg-container\">\n    <svg className=\"star-location-chart\"></svg>\n  </div>\n</div>\n}\n\nexport default StarLocationChart;\n"
  },
  {
    "path": "frontend/src/components/TrafficAnalytics.js",
    "content": "import React, { useEffect, useState } from \"react\";\nimport VisitChart from './VisitChart';\nimport CloneChart from './CloneChart';\nimport RepoLoader from \"./RepoLoader\";\nimport ReferrerChart from \"./ReferrerChart\";\nimport PathChart from \"./PathChart\";\nimport http from '../utils/http';\n\nconst Traffic = ({ repoPath }) => {\n  const [trafficData, setTrafficData] = useState();\n  const [isLoading, setIsLoading] = useState(false);\n\n  useEffect(() => {\n    setIsLoading(true);\n    http.getRepoTraffic({\n      repoPath,\n    })\n      .then(traffic => {\n        setTrafficData(traffic);\n        setIsLoading(false);\n      })\n      .catch(err => console.log(err));\n  }, []);\n\n  if (isLoading || !trafficData) {\n    return <div className=\"repo-container\">\n      <RepoLoader/>\n    </div>\n  }\n\n  return (<div className=\"repo-container\">\n    <div className=\"dates-container\">\n      <p>Updated at {trafficData.date}</p>\n      <p>Recording analytics since {trafficData.repoCreatedAt.slice(0, 10)}</p>\n    </div> \n\n    <div className=\"repo-ref-paths-container\">\n      <div className=\"one-ref-path\">\n        <VisitChart views={trafficData.views}/> \n      </div>\n      <div className=\"one-ref-path\">\n        <CloneChart clones={trafficData.clones}/>\n      </div>\n    </div>\n\n\n    <div className=\"repo-ref-paths-container\">\n      <div className=\"one-ref-path\">\n        <ReferrerChart referrers={trafficData.referrers}/>\n      </div>\n      <div className=\"one-ref-path\">\n        <PathChart paths={trafficData.paths}/>\n      </div>\n    </div>\n  </div>);\n}\n\nexport default Traffic;\n"
  },
  {
    "path": "frontend/src/components/VisitChart.css",
    "content": ".chart-container {\n  border: 1px solid #d1d5da;\n  border-radius: 5px;\n  margin-bottom: 30px;\n  position: relative;\n}\n\n.svg-container {\n  height: 270px;\n  width: 100%;\n}\n\n\n.chart-container-header {\n  display: block;\n  padding: 13px 10px 14px;\n  margin: 0;\n  font-size: 16px;\n  line-height: 17px;\n  background-color: #f6f8fa;\n  border-bottom: 1px solid rgba(27,31,35,.15);\n  border-radius: 3px 3px 0 0;\n}\n\n.location-description {\n  position: absolute;\n  right: 3px;\n  font-size: 12px;\n  color: #888;\n}\n"
  },
  {
    "path": "frontend/src/components/VisitChart.js",
    "content": "import React, { useEffect } from 'react';\nimport chartXkcd from 'chart.xkcd';\nimport './VisitChart.css';\n\nconst VisitChart = ({ views }) => {\n  const totalViewsData = views.map(view => ({\n    x: view.timestamp,\n    y: view.count,\n  }));\n  const uniqueViewsData = views.map(view => ({\n    x: view.timestamp,\n    y: view.uniques,\n  }));\n  useEffect(() => {\n    const svg = document.querySelector('.visit-chart');\n    new chartXkcd.XY(svg, {\n      // title: 'Visitors',\n      data: {\n        datasets: [{\n          label: 'Views',\n          data: totalViewsData,\n        }, {\n          label: 'Unique Visitors',\n          data: uniqueViewsData,\n        }],\n      },\n      options: {\n        xTickCount: 3,\n        yTickCount: 4,\n        legendPosition: chartXkcd.config.positionType.upLeft,\n        showLine: true,\n        timeFormat: 'MM/DD/YYYY',\n        dotSize: 0.5,\n        dataColors: ['#28a745', '#005cc5'],\n        // unxkcdify: true\n      },\n    });\n  }, []);\n\n  return <div className=\"chart-container\">\n  <h3 className=\"chart-container-header\"> Visitors </h3>\n  <div className=\"svg-container\">\n    <svg className=\"visit-chart\"></svg>\n  </div>\n</div>\n}\n\nexport default VisitChart;\n"
  },
  {
    "path": "frontend/src/index.css",
    "content": "body {\n  margin: 0;\n  font-family: -apple-system, BlinkMacSystemFont, \"Segoe UI\", \"Roboto\", \"Oxygen\",\n    \"Ubuntu\", \"Cantarell\", \"Fira Sans\", \"Droid Sans\", \"Helvetica Neue\",\n    sans-serif;\n  -webkit-font-smoothing: antialiased;\n  -moz-osx-font-smoothing: grayscale;\n}\n\ncode {\n  font-family: source-code-pro, Menlo, Monaco, Consolas, \"Courier New\",\n    monospace;\n}\n"
  },
  {
    "path": "frontend/src/index.js",
    "content": "import React from 'react';\nimport ReactDOM from 'react-dom';\nimport './index.css';\nimport App from './App';\nimport * as serviceWorker from './serviceWorker';\nimport 'remixicon/fonts/remixicon.css'\n\nReactDOM.render(<App />, document.getElementById('root'));\n\n// If you want your app to work offline and load faster, you can change\n// unregister() to register() below. Note this comes with some pitfalls.\n// Learn more about service workers: https://bit.ly/CRA-PWA\nserviceWorker.unregister();\n"
  },
  {
    "path": "frontend/src/pages/Home.css",
    "content": ".home-container {\n  margin: 0 auto;\n  max-width: 900px;\n}\n\n.home-hero {\n  text-align: center;\n  padding: 30px 10px 130px 10px;;\n  background: url(https://raw.githubusercontent.com/timqian/images/master/20191013133125.gif),white;\n  background-position: left -55px bottom -35px;\n  background-size: 200px;\n  background-repeat: no-repeat;\n  border-bottom: 1px solid #dfe2e5;\n  position: relative;\n}\n\n.home-github-btn {\n  position: absolute;\n  left: 75px;\n  bottom: 45px;\n}\n\n.home-slogan {\n  font-size: 40px;\n  font-weight: 300;\n  padding: 40px 0!important;\n  margin: 0;\n}\n\n.home-features {\n  display: flex;\n  justify-content: center;\n  flex-wrap: wrap;\n  margin: 30px auto;\n}\n\n.home-feature {\n  width: 300px;\n  /* box-shadow: 0 1px 1px rgba(27,31,35,.1); */\n  margin: 0 20px;\n}\n\n.home-feature-title {\n  font-weight: 500;\n  font-size: 24px;\n  margin: 0;\n}\n\n.home-feature-description {\n  font-weight: 480;\n  font-size: 15px;\n  color: #586069;\n  line-height: 1.5;\n}\n\n.home-feature-description a:hover {\n  text-decoration: underline;\n}\n\n.home-signin-btn {\n  /* background-color: #24292e; */\n  border-radius: 3px;\n  background-color: #2ebc4f;\n  border: none;\n  padding: 20px 40px;\n  font-size: 16px;\n  font-weight: 550;\n  cursor: pointer;\n  color: white;\n}\n\n.home-signin-btn:hover {\n  background-color: #2ba046;\n}\n\n.home-hr {\n  height: 0;\n  margin: 15px 0;\n  overflow: hidden;\n  background: transparent;\n  border: 0;\n  border-bottom: 1px solid #dfe2e5;\n}\n\n.home-example-title {\n  font-size: 23px;\n  font-weight: 400;\n  color: #586069;\n  margin: 50px 0 30px 0;\n  text-align: center;\n}\n\n.home-examples {\n  display: flex;\n  justify-content: space-around;\n  flex-wrap: wrap; \n}\n\n.home-box {\n  width: 300px;\n  max-width: 430px;\n  height: 180px;\n  margin: 8px;\n  flex-grow: 100;\n  flex-shrink: 0;\n  flex-basis: 1;\n  background-color: #fff;\n  border: 1px solid #d1d5da;\n  border-radius: 3px;\n}\n\n"
  },
  {
    "path": "frontend/src/pages/Home.js",
    "content": "import React, { useEffect, useState } from \"react\";\nimport http from '../utils/http';\nimport ProjectCard from '../components/ProjectCard';\nimport './Home.css';\nimport Footer from '../components/Footer';\nimport GitHubButton from 'react-github-btn'\nimport CardLoader from '../components/CardLoader';\n\nfunction Home ({user}) {\n\n  const [repos, setRepos] = useState([]);\n\n  const [isLoading, setIsLoading] = useState(false);\n\n  useEffect(() => {\n    setIsLoading(true);\n    http.getUserRepos('timqian')\n      .then(repos => {\n        setRepos(repos);\n        setIsLoading(false);\n      });\n  }, []);\n\n  return (\n    <div className=\"home-main\">\n      <div className=\"home-hero\">\n        <div className=\"home-github-btn\">\n          <GitHubButton href=\"https://github.com/repo-analytics/repo-analytics.github.io\" data-show-count=\"true\" aria-label=\"Star repo-analytics/repo-analytics.github.io on GitHub\">Star</GitHubButton>\n        </div>\n        <h1 className=\"home-slogan\">\n          Thorough analytics for your GitHub repos\n        </h1>\n        <div className=\"home-features\">\n          <div className=\"home-feature\">\n            <h4 className=\"home-feature-title\">Better traffic data</h4>\n            <p className=\"home-feature-description\">\n              Track traffic to GitHub Repos for longer than 14 days.\n            </p>\n          </div>\n          <div className=\"home-feature\">\n            <h4 className=\"home-feature-title\">Understand your users</h4>\n            <p className=\"home-feature-description\">\n              Analyze history, locations of Star, Watch... data of your GitHub Repos\n            </p>\n          </div>\n          <div className=\"home-feature\">\n            <h4 className=\"home-feature-title\">What do you care?</h4>\n            <p className=\"home-feature-description\">\n              Suggest new features for Repo Analytics on \n              &nbsp;\n              <a href=\"https://github.com/repo-analytics/repo-analytics.github.io/issues\">GitHub</a>\n            </p>\n          </div>\n        </div>\n        <br/>\n        <br/>\n        {\n          !user.username ?\n          <a className=\"home-signin-btn\" href=\"https://repo-analytics.t9t.io/auth/github\">Sign in with GitHub</a>\n          : ''\n        }\n      </div>\n\n      <div className=\"home-container\">\n        <h2 className=\"home-example-title\">Example repos using <strong>Repo Analytics</strong></h2>\n        { isLoading ? <CardLoader/> : ''}\n\n        <div className=\"home-examples\">\n          {\n            repos.map(repo => <div className=\"home-box\">\n              <ProjectCard repo={repo.repo} username={repo.username} createdAt={repo.createdAt} views={repo.views}/>\n            </div>)\n          }\n\n        </div>\n\n        <Footer />\n      </div>\n    </div>\n  );\n}\n\nexport default Home;"
  },
  {
    "path": "frontend/src/pages/Repo.css",
    "content": ".repo-container {\n  margin: 0 auto;\n  max-width: 900px;\n  padding: 0 8px;\n}\n\n.repo-header {\n  width: 100vw;\n  background-color: #fafbfc;\n  border-bottom: 1px solid #e1e4e8;\n  position: relative;\n}\n\n.repo-title {\n  padding-top: 10px;\n  padding-bottom: 50px;\n  font-size: 22px;\n}\n\n.repo-title a:hover {\n  text-decoration: underline;\n}\n\n.repo-nav {\n  position: absolute;\n  bottom: -1px;\n}\n\n.repo-nav a {\n  color: #24292e;\n  float: left;\n  padding: 7px 15px 8px;\n  color: #586069;\n  white-space: nowrap;\n  border-radius: 3px 3px 0 0;\n  border-left: 1px solid transparent;\n  border-right: 1px solid transparent;\n  border-top: 3px solid transparent;\n  border-bottom: 1px solid transparent;\n  cursor: pointer;\n}\n\n.repo-nav .selected {\n  background-color: #fff;\n  border-left: 1px solid rgb(225, 228, 232);\n  border-right: 1px solid rgb(225, 228, 232);\n  border-top: 3px solid #e36209;\n  border-bottom: 1px solid white;\n}\n\n.dates-container {\n  display: flex;\n  justify-content: flex-end;\n  flex-direction: column;\n  align-items: flex-end;\n  padding: 15px 0;\n  font-weight: 400;\n  font-size: 12px;\n  color: #888\n}\n\n.dates-container p {\n  margin: 0;\n  padding: 2px 0;\n}\n\n.repo-ref-paths-container {\n  display: flex;\n  justify-content: space-around;\n  flex-wrap: wrap;\n}\n\n.one-ref-path {\n  width: 300px;\n  max-width: 430px;\n  flex-grow: 100;\n  flex-shrink: 0;\n  flex-basis: 1;\n  background-color: #fff;\n  margin-bottom: 10px;\n}\n\ntable {\n  width: 100%;\n  color: rgb(88, 96, 105);\n  border-collapse: collapse;\n  font-size: 14px;\n}\n\nthead {\n  background-color: rgb(246, 248, 250);\n}\n\ntr:nth-child(even){background-color: rgba(246, 248, 250, 0.4);}\n\ntd, th {\n  padding: 8px;\n  text-align: left;\n}\n\ntd {\n  word-break: break-word;\n}\n\ntr {\n  border-bottom: 1px solid #ddd;\n}\n\ntd a:hover {\n  text-decoration: underline;\n}"
  },
  {
    "path": "frontend/src/pages/Repo.js",
    "content": "import TrafficAnalytics from '../components/TrafficAnalytics'; \nimport StarAnalytics from '../components/StarAnalytics'; \nimport RepoSetting from '../components/RepoSetting'; \nimport RepoNav from '../components/RepoNav'; \n\nimport './Repo.css';\nimport React from \"react\";\nimport Footer from '../components/Footer';\n\nimport {\n  BrowserRouter as Router,\n  Switch,\n  Route,\n  Link,\n  useRouteMatch,\n  useParams,\n  useLocation,\n} from \"react-router-dom\";\n\nfunction Repo () {\n  const match = useRouteMatch();\n  const location = useLocation();\n  const username = match.params.username;\n  const repo = match.params.repo;\n  const repoPath = `${username}/${repo}`\n\n  return (\n    <div >\n      <Switch>\n        <Route path={`${match.path}/traffic`}>\n          <RepoNav repoPath={repoPath} selectedTab={0} />\n          <TrafficAnalytics repoPath={repoPath}/>\n        </Route>\n        <Route path={`${match.path}/stars`}>\n          <RepoNav repoPath={repoPath} selectedTab={1} />\n          <StarAnalytics repoPath={repoPath}/>\n        </Route>\n        <Route path={`${match.path}/settings`}>\n          <RepoNav repoPath={repoPath} selectedTab={2} />\n          <RepoSetting />\n        </Route>\n        <Route path={`${match.path}`}>\n          <RepoNav repoPath={repoPath} selectedTab={0} />\n          <TrafficAnalytics repoPath={repoPath}/>\n        </Route>\n      </Switch>\n\n      <div className=\"repo-container\">\n        <Footer />\n      </div>\n    </div>\n  );\n}\n\nexport default Repo;"
  },
  {
    "path": "frontend/src/pages/User.css",
    "content": ".user-title {\n  margin-left: 8px;\n  margin-top: 30px;\n  margin-bottom: 30px;\n  font-size: 25px;\n}\n\n.user-link {\n  font-weight: 500;\n}\n\n.user-github-link {\n  font-size: 20px;\n  font-weight: 500;\n  margin: 3px;\n}\n"
  },
  {
    "path": "frontend/src/pages/User.js",
    "content": "import React, { useEffect, useState } from \"react\";\nimport http from '../utils/http';\nimport ProjectCard from '../components/ProjectCard';\nimport './User.css';\nimport userSignedIn from '../utils/userSignedIn';\nimport CardLoader from '../components/CardLoader';\nimport AddRepo from '../components/AddRepo';\nimport Footer from '../components/Footer';\n\nfunction User ({ match }) {\n  const username = match.params.username;\n  const userLocal = userSignedIn.get();\n  const [repos, setRepos] = useState([]);\n  const [isLoading, setIsLoading] = useState(false);\n\n  useEffect(() => {\n    setIsLoading(true);\n    http.getUserRepos(username)\n      .then(repos => {\n        setRepos(repos);\n        setIsLoading(false);\n      });\n  }, []);\n\n  return (\n    <div className=\"home-container\">\n      <h1 className=\"user-title\">\n        Repos of&nbsp;\n        <a className=\"user-github-link\" href={`https://github.com/${username}`}>\n          {username}\n        </a>\n        <a className=\"user-github-link\" href={`https://github.com/${username}`}>\n          <i className=\"ri-github-line\"></i>\n        </a>\n      </h1>\n      { isLoading ? <CardLoader/> : ''}\n      <div className=\"home-examples\">\n        {\n          repos.map(repo => <div className=\"home-box\">\n            <ProjectCard repo={repo.repo} username={repo.username} createdAt={repo.createdAt} views={repo.views}/>\n          </div>)\n        }\n\n        {\n          userLocal.username === username ?\n            <AddRepo /> : ''\n        }\n      </div>\n\n      <Footer />\n    </div>\n  );\n}\n\nexport default User;"
  },
  {
    "path": "frontend/src/serviceWorker.js",
    "content": "// This optional code is used to register a service worker.\n// register() is not called by default.\n\n// This lets the app load faster on subsequent visits in production, and gives\n// it offline capabilities. However, it also means that developers (and users)\n// will only see deployed updates on subsequent visits to a page, after all the\n// existing tabs open on the page have been closed, since previously cached\n// resources are updated in the background.\n\n// To learn more about the benefits of this model and instructions on how to\n// opt-in, read https://bit.ly/CRA-PWA\n\nconst isLocalhost = Boolean(\n  window.location.hostname === 'localhost' ||\n    // [::1] is the IPv6 localhost address.\n    window.location.hostname === '[::1]' ||\n    // 127.0.0.1/8 is considered localhost for IPv4.\n    window.location.hostname.match(\n      /^127(?:\\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/\n    )\n);\n\nexport function register(config) {\n  if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {\n    // The URL constructor is available in all browsers that support SW.\n    const publicUrl = new URL(process.env.PUBLIC_URL, window.location.href);\n    if (publicUrl.origin !== window.location.origin) {\n      // Our service worker won't work if PUBLIC_URL is on a different origin\n      // from what our page is served on. This might happen if a CDN is used to\n      // serve assets; see https://github.com/facebook/create-react-app/issues/2374\n      return;\n    }\n\n    window.addEventListener('load', () => {\n      const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;\n\n      if (isLocalhost) {\n        // This is running on localhost. Let's check if a service worker still exists or not.\n        checkValidServiceWorker(swUrl, config);\n\n        // Add some additional logging to localhost, pointing developers to the\n        // service worker/PWA documentation.\n        navigator.serviceWorker.ready.then(() => {\n          console.log(\n            'This web app is being served cache-first by a service ' +\n              'worker. To learn more, visit https://bit.ly/CRA-PWA'\n          );\n        });\n      } else {\n        // Is not localhost. Just register service worker\n        registerValidSW(swUrl, config);\n      }\n    });\n  }\n}\n\nfunction registerValidSW(swUrl, config) {\n  navigator.serviceWorker\n    .register(swUrl)\n    .then(registration => {\n      registration.onupdatefound = () => {\n        const installingWorker = registration.installing;\n        if (installingWorker == null) {\n          return;\n        }\n        installingWorker.onstatechange = () => {\n          if (installingWorker.state === 'installed') {\n            if (navigator.serviceWorker.controller) {\n              // At this point, the updated precached content has been fetched,\n              // but the previous service worker will still serve the older\n              // content until all client tabs are closed.\n              console.log(\n                'New content is available and will be used when all ' +\n                  'tabs for this page are closed. See https://bit.ly/CRA-PWA.'\n              );\n\n              // Execute callback\n              if (config && config.onUpdate) {\n                config.onUpdate(registration);\n              }\n            } else {\n              // At this point, everything has been precached.\n              // It's the perfect time to display a\n              // \"Content is cached for offline use.\" message.\n              console.log('Content is cached for offline use.');\n\n              // Execute callback\n              if (config && config.onSuccess) {\n                config.onSuccess(registration);\n              }\n            }\n          }\n        };\n      };\n    })\n    .catch(error => {\n      console.error('Error during service worker registration:', error);\n    });\n}\n\nfunction checkValidServiceWorker(swUrl, config) {\n  // Check if the service worker can be found. If it can't reload the page.\n  fetch(swUrl)\n    .then(response => {\n      // Ensure service worker exists, and that we really are getting a JS file.\n      const contentType = response.headers.get('content-type');\n      if (\n        response.status === 404 ||\n        (contentType != null && contentType.indexOf('javascript') === -1)\n      ) {\n        // No service worker found. Probably a different app. Reload the page.\n        navigator.serviceWorker.ready.then(registration => {\n          registration.unregister().then(() => {\n            window.location.reload();\n          });\n        });\n      } else {\n        // Service worker found. Proceed as normal.\n        registerValidSW(swUrl, config);\n      }\n    })\n    .catch(() => {\n      console.log(\n        'No internet connection found. App is running in offline mode.'\n      );\n    });\n}\n\nexport function unregister() {\n  if ('serviceWorker' in navigator) {\n    navigator.serviceWorker.ready.then(registration => {\n      registration.unregister();\n    });\n  }\n}\n"
  },
  {
    "path": "frontend/src/utils/http.js",
    "content": "import axios from 'axios';\n\nconst userRaw = window.localStorage.getItem('user');\n\nlet token;\nif (userRaw) {\n  const user = JSON.parse(userRaw);\n  token = user.token;\n}\n\nconst http = axios.create({\n  baseURL: 'https://repo-analytics.t9t.io/',\n  // baseURL: 'http://localhost:8080/',\n  timeout: 20000,\n  headers: {\n    token,\n  },\n});\n \nconst getUserRepos = async (username) => {\n  const res = await http.get(`/user/${username}`);\n  return res.data.repos;\n}\n\n/**\n * \n * @param {String} repoPath \n * @param {String} startDate \n * @param {String} endDate \n */\nconst getRepoTraffic = async ({repoPath}) => {\n  const res = await http.get(`/repo/${repoPath}`);\n  return res.data.traffic;\n}\n\nconst getRepoStars = async ({repoPath}) => {\n  const res = await http.get(`/repo/${repoPath}/stars`);\n  return res.data;\n}\n\nconst addRepo = async ({username, repoPath, token}) => {\n  const res = await http.post('/repo/add', {\n    username, repoPath, token,\n  });\n  return res.data;\n}\n\nexport default {\n  getUserRepos,\n  getRepoTraffic,\n  getRepoStars,\n  addRepo,\n};\n\n\n// test\n// getRepoStars({repoPath: 'timqian/star-history'})"
  },
  {
    "path": "frontend/src/utils/trafficDateRangeToArray.js",
    "content": "/**\n * @param startDate\n * @param endDate\n * @returns array of required traffic dates\n * @example\n *   const dateArr = trafficDateRangeToArray('2019-10-01', '2019-10-20')\n */"
  },
  {
    "path": "frontend/src/utils/userSignedIn.js",
    "content": "/**\n * user: {\n *   username: 'timqian',\n *   token: '',\n *   photo: '',\n * }\n */\n\nfunction set({ username, token, photo }) {\n  window.localStorage.setItem('user', JSON.stringify({\n    username, token, photo\n  }))\n}\n\nfunction get() {\n  let user = {};\n  const userRaw = window.localStorage.getItem('user');\n  if (userRaw) {\n    try {\n      user = JSON.parse(userRaw);\n    } catch (err) {}\n  }\n  return user;\n}\n\nfunction remove() {\n  window.localStorage.removeItem('user');\n}\n\nmodule.exports = {\n  set,\n  get,\n  remove,\n};"
  }
]