From 7b15b2aa0b90c65dcff1799d01a2e51588f9b83a Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Sat, 10 Apr 2021 13:25:38 +0200 Subject: [PATCH 01/24] add start:production script --- package.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 1dbb43c..ca45a30 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,8 @@ "studio": "blitz prisma studio", "lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .", "test": "jest", - "test:watch": "jest --watch" + "test:watch": "jest --watch", + "start:production": "blitz start --port $PORT" }, "prisma": { "schema": "db/schema.prisma" From ca3b5eab69f3efe001f644a26e62e37492e53557 Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Sat, 10 Apr 2021 13:39:30 +0200 Subject: [PATCH 02/24] urgent: added preview mail --- package.json | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/package.json b/package.json index ca45a30..c2aed37 100644 --- a/package.json +++ b/package.json @@ -9,8 +9,7 @@ "studio": "blitz prisma studio", "lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .", "test": "jest", - "test:watch": "jest --watch", - "start:production": "blitz start --port $PORT" + "test:watch": "jest --watch" }, "prisma": { "schema": "db/schema.prisma" @@ -49,7 +48,9 @@ "react-icons": "4.2.0", "react-responsive": "8.2.0", "typescript": "~4.1", - "zod": "1.11.13" + "zod": "1.11.13", + "preview-email": "3.0.4", + "@types/preview-email": "2.0.0" }, "devDependencies": { "@types/preview-email": "2.0.0", From a0a589af2d46fb75c4cb8ccd8fed2c2043925aca Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Sat, 10 Apr 2021 13:47:54 +0200 Subject: [PATCH 03/24] urgent: added production script --- package.json | 1 + 1 file changed, 1 insertion(+) diff --git a/package.json b/package.json index c2aed37..975953c 100644 --- a/package.json +++ b/package.json @@ -9,6 +9,7 @@ "studio": "blitz prisma studio", "lint": "eslint --ignore-path .gitignore --ext .js,.ts,.tsx .", "test": "jest", + "start:production": "blitz start --port $PORT", "test:watch": "jest --watch" }, "prisma": { From c8148ec5a455327be7a186ac2d11774363fc443c Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Sat, 10 Apr 2021 21:29:51 +0200 Subject: [PATCH 04/24] add overflow-attribut, move scrolldown to useEffect --- app/pages/chats/[chatId].tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/pages/chats/[chatId].tsx b/app/pages/chats/[chatId].tsx index 4fc2607..6fbe084 100644 --- a/app/pages/chats/[chatId].tsx +++ b/app/pages/chats/[chatId].tsx @@ -50,12 +50,9 @@ export default function Chat() { useEffect(() => { markMessagesAsReadMutation({ chatId }) markAdminMessagesAsReadMutation({ chatId }) - }, [messages]) - - useLayoutEffect(() => { const message = document.getElementById("messages")! message.scrollTop = message.scrollHeight - }) + }, [messages]) const [hasUnreadMessage] = useQuery(checkIfUnreadMessage, null, { refetchInterval: 2000 }) @@ -71,6 +68,7 @@ export default function Chat() { width="full" maxWidth="600px" alignSelf="center" + style={{ maxHeight: "calc(100vh - 100px" }} > Date: Sun, 11 Apr 2021 12:59:15 -0500 Subject: [PATCH 05/24] Fixed list --- app/components/LandingPage/frontPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/components/LandingPage/frontPage.tsx b/app/components/LandingPage/frontPage.tsx index dac7cbb..94f0509 100644 --- a/app/components/LandingPage/frontPage.tsx +++ b/app/components/LandingPage/frontPage.tsx @@ -93,7 +93,7 @@ export default function FrontPage() { status={1} acceptedName="Antony" specialWish="as a 'Thank You' you will get a beer on the house" - itemsList={["wine (sub $5 Pinot Gris)", "condoms", "whip"]} + itemsList={["wine (sub $5 Pinot Gris)", "sausages", "coffee"]} /> Date: Tue, 13 Apr 2021 08:07:48 +0200 Subject: [PATCH 06/24] add "setup entel locally" to readme --- README.md | 92 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 92 insertions(+) diff --git a/README.md b/README.md index 22f528f..184a972 100644 --- a/README.md +++ b/README.md @@ -54,3 +54,95 @@ A hosted version can be found at [**entel.me**](https://www.entel.me/) Many thanks to Roman for creating the cute logo 💖 This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind welcome! + +## Setup entel locally + +To run entel locally, you need to install [NodeJS](https://nodejs.org/en/) and [npm](https://www.npmjs.com/). Additionally, you should be able to run PostgreSQL on your machine. You can achieve this by + +- installing it natively on your computer or +- via docker. + +### First steps ✨ + +But first of all, you have to clone and open this repository. + +```bash +git clone https://github.com/entel-me/entel.git +cd entel +``` + +After that, you should be able to install the dependencies with npm. + +```bash +npm i +``` + +Great! Let's start with setting up environment variables. 🔥 + +### Setup enviroment variables 📝 + +First, you have to create two empty files`.env.local` and `env.test.local`. You can specify environment variables in these files. Afterward, you call them with `process.env.`. + +`DATABASE_URL` is an important variable that connects the PostgreSQL database with our application. If you're running PostgreSQL in docker, you set + +- username, +- password, +- the name of the database + on your own and include them in a URL. Here is an example: + +```txt +POSTGRES_USER=entel +POSTGRES_PASSWORD=crazypassword +POSTGRES_DB=enteldb +DATABASE_URL=postgresql://entel:crazypassword@localhost:5432/enteldb +``` + +If you're running PostgreSQL natively on your computer, you have to enter the URL of your database in each `.local` file. Please be aware that you have to remove the [`predev` script](https://github.com/entel-me/entel/blob/1f352942b6f9cec4aabad566766f752c4c3c82f5/package.json#L5) from package.json to run entel without errors. + +```txt +DATABASE_URL=postgresql://entel:crazypassword@localhost:5432/enteldb +``` + +If you want to test the mailer in [`mailers/`](https://github.com/entel-me/entel/tree/develop/mailers), you have to add your + +- mail, +- password, +- and mail host + to the `.local` files too: + +```txt +MAIL_HOST=mail.privateemail.com +MAIL_MAIL=info@antonykamp.de +MAIL_PASSWORD=crazypassword +``` + +Great! After that, we take care of the database itself. + +### Run the database 📋 + +The last thing we have to do is migrating the database with [prisma](https://www.prisma.io/). For the following step, the database should already be running. You can achieve this with docker with the command: + +```bash +docker-compose up -d +``` + +Now you can set up the database by entering: + +```bash +blitz prisma migrate dev --preview-feature +``` + +Btw, if you change something in [schema.prisma](https://github.com/entel-me/entel/blob/develop/db/schema.prisma) you have to re-run the last command. +Now we can try out our application. 🥳 + +### Run the application + +To run entel you execute + +```bash +blitz dev +``` + +and view your new app at [http://localhost:3000/](http://localhost:3000/)! Perfect 🎉 + +Have fun with the app :) From 8c4fed6d521db8ee21a86b6c4254dcda20d4a91a Mon Sep 17 00:00:00 2001 From: Antony Date: Tue, 13 Apr 2021 08:36:50 +0200 Subject: [PATCH 07/24] Create LICENSE --- LICENSE | 339 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 339 insertions(+) create mode 100644 LICENSE diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..d159169 --- /dev/null +++ b/LICENSE @@ -0,0 +1,339 @@ + GNU GENERAL PUBLIC LICENSE + Version 2, June 1991 + + Copyright (C) 1989, 1991 Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + Preamble + + The licenses for most software are designed to take away your +freedom to share and change it. By contrast, the GNU General Public +License is intended to guarantee your freedom to share and change free +software--to make sure the software is free for all its users. This +General Public License applies to most of the Free Software +Foundation's software and to any other program whose authors commit to +using it. (Some other Free Software Foundation software is covered by +the GNU Lesser General Public License instead.) You can apply it to +your programs, too. + + When we speak of free software, we are referring to freedom, not +price. Our General Public Licenses are designed to make sure that you +have the freedom to distribute copies of free software (and charge for +this service if you wish), that you receive source code or can get it +if you want it, that you can change the software or use pieces of it +in new free programs; and that you know you can do these things. + + To protect your rights, we need to make restrictions that forbid +anyone to deny you these rights or to ask you to surrender the rights. +These restrictions translate to certain responsibilities for you if you +distribute copies of the software, or if you modify it. + + For example, if you distribute copies of such a program, whether +gratis or for a fee, you must give the recipients all the rights that +you have. You must make sure that they, too, receive or can get the +source code. And you must show them these terms so they know their +rights. + + We protect your rights with two steps: (1) copyright the software, and +(2) offer you this license which gives you legal permission to copy, +distribute and/or modify the software. + + Also, for each author's protection and ours, we want to make certain +that everyone understands that there is no warranty for this free +software. If the software is modified by someone else and passed on, we +want its recipients to know that what they have is not the original, so +that any problems introduced by others will not reflect on the original +authors' reputations. + + Finally, any free program is threatened constantly by software +patents. We wish to avoid the danger that redistributors of a free +program will individually obtain patent licenses, in effect making the +program proprietary. To prevent this, we have made it clear that any +patent must be licensed for everyone's free use or not licensed at all. + + The precise terms and conditions for copying, distribution and +modification follow. + + GNU GENERAL PUBLIC LICENSE + TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION + + 0. This License applies to any program or other work which contains +a notice placed by the copyright holder saying it may be distributed +under the terms of this General Public License. The "Program", below, +refers to any such program or work, and a "work based on the Program" +means either the Program or any derivative work under copyright law: +that is to say, a work containing the Program or a portion of it, +either verbatim or with modifications and/or translated into another +language. (Hereinafter, translation is included without limitation in +the term "modification".) Each licensee is addressed as "you". + +Activities other than copying, distribution and modification are not +covered by this License; they are outside its scope. The act of +running the Program is not restricted, and the output from the Program +is covered only if its contents constitute a work based on the +Program (independent of having been made by running the Program). +Whether that is true depends on what the Program does. + + 1. You may copy and distribute verbatim copies of the Program's +source code as you receive it, in any medium, provided that you +conspicuously and appropriately publish on each copy an appropriate +copyright notice and disclaimer of warranty; keep intact all the +notices that refer to this License and to the absence of any warranty; +and give any other recipients of the Program a copy of this License +along with the Program. + +You may charge a fee for the physical act of transferring a copy, and +you may at your option offer warranty protection in exchange for a fee. + + 2. You may modify your copy or copies of the Program or any portion +of it, thus forming a work based on the Program, and copy and +distribute such modifications or work under the terms of Section 1 +above, provided that you also meet all of these conditions: + + a) You must cause the modified files to carry prominent notices + stating that you changed the files and the date of any change. + + b) You must cause any work that you distribute or publish, that in + whole or in part contains or is derived from the Program or any + part thereof, to be licensed as a whole at no charge to all third + parties under the terms of this License. + + c) If the modified program normally reads commands interactively + when run, you must cause it, when started running for such + interactive use in the most ordinary way, to print or display an + announcement including an appropriate copyright notice and a + notice that there is no warranty (or else, saying that you provide + a warranty) and that users may redistribute the program under + these conditions, and telling the user how to view a copy of this + License. (Exception: if the Program itself is interactive but + does not normally print such an announcement, your work based on + the Program is not required to print an announcement.) + +These requirements apply to the modified work as a whole. If +identifiable sections of that work are not derived from the Program, +and can be reasonably considered independent and separate works in +themselves, then this License, and its terms, do not apply to those +sections when you distribute them as separate works. But when you +distribute the same sections as part of a whole which is a work based +on the Program, the distribution of the whole must be on the terms of +this License, whose permissions for other licensees extend to the +entire whole, and thus to each and every part regardless of who wrote it. + +Thus, it is not the intent of this section to claim rights or contest +your rights to work written entirely by you; rather, the intent is to +exercise the right to control the distribution of derivative or +collective works based on the Program. + +In addition, mere aggregation of another work not based on the Program +with the Program (or with a work based on the Program) on a volume of +a storage or distribution medium does not bring the other work under +the scope of this License. + + 3. You may copy and distribute the Program (or a work based on it, +under Section 2) in object code or executable form under the terms of +Sections 1 and 2 above provided that you also do one of the following: + + a) Accompany it with the complete corresponding machine-readable + source code, which must be distributed under the terms of Sections + 1 and 2 above on a medium customarily used for software interchange; or, + + b) Accompany it with a written offer, valid for at least three + years, to give any third party, for a charge no more than your + cost of physically performing source distribution, a complete + machine-readable copy of the corresponding source code, to be + distributed under the terms of Sections 1 and 2 above on a medium + customarily used for software interchange; or, + + c) Accompany it with the information you received as to the offer + to distribute corresponding source code. (This alternative is + allowed only for noncommercial distribution and only if you + received the program in object code or executable form with such + an offer, in accord with Subsection b above.) + +The source code for a work means the preferred form of the work for +making modifications to it. For an executable work, complete source +code means all the source code for all modules it contains, plus any +associated interface definition files, plus the scripts used to +control compilation and installation of the executable. However, as a +special exception, the source code distributed need not include +anything that is normally distributed (in either source or binary +form) with the major components (compiler, kernel, and so on) of the +operating system on which the executable runs, unless that component +itself accompanies the executable. + +If distribution of executable or object code is made by offering +access to copy from a designated place, then offering equivalent +access to copy the source code from the same place counts as +distribution of the source code, even though third parties are not +compelled to copy the source along with the object code. + + 4. You may not copy, modify, sublicense, or distribute the Program +except as expressly provided under this License. Any attempt +otherwise to copy, modify, sublicense or distribute the Program is +void, and will automatically terminate your rights under this License. +However, parties who have received copies, or rights, from you under +this License will not have their licenses terminated so long as such +parties remain in full compliance. + + 5. You are not required to accept this License, since you have not +signed it. However, nothing else grants you permission to modify or +distribute the Program or its derivative works. These actions are +prohibited by law if you do not accept this License. Therefore, by +modifying or distributing the Program (or any work based on the +Program), you indicate your acceptance of this License to do so, and +all its terms and conditions for copying, distributing or modifying +the Program or works based on it. + + 6. Each time you redistribute the Program (or any work based on the +Program), the recipient automatically receives a license from the +original licensor to copy, distribute or modify the Program subject to +these terms and conditions. You may not impose any further +restrictions on the recipients' exercise of the rights granted herein. +You are not responsible for enforcing compliance by third parties to +this License. + + 7. If, as a consequence of a court judgment or allegation of patent +infringement or for any other reason (not limited to patent issues), +conditions are imposed on you (whether by court order, agreement or +otherwise) that contradict the conditions of this License, they do not +excuse you from the conditions of this License. If you cannot +distribute so as to satisfy simultaneously your obligations under this +License and any other pertinent obligations, then as a consequence you +may not distribute the Program at all. For example, if a patent +license would not permit royalty-free redistribution of the Program by +all those who receive copies directly or indirectly through you, then +the only way you could satisfy both it and this License would be to +refrain entirely from distribution of the Program. + +If any portion of this section is held invalid or unenforceable under +any particular circumstance, the balance of the section is intended to +apply and the section as a whole is intended to apply in other +circumstances. + +It is not the purpose of this section to induce you to infringe any +patents or other property right claims or to contest validity of any +such claims; this section has the sole purpose of protecting the +integrity of the free software distribution system, which is +implemented by public license practices. Many people have made +generous contributions to the wide range of software distributed +through that system in reliance on consistent application of that +system; it is up to the author/donor to decide if he or she is willing +to distribute software through any other system and a licensee cannot +impose that choice. + +This section is intended to make thoroughly clear what is believed to +be a consequence of the rest of this License. + + 8. If the distribution and/or use of the Program is restricted in +certain countries either by patents or by copyrighted interfaces, the +original copyright holder who places the Program under this License +may add an explicit geographical distribution limitation excluding +those countries, so that distribution is permitted only in or among +countries not thus excluded. In such case, this License incorporates +the limitation as if written in the body of this License. + + 9. The Free Software Foundation may publish revised and/or new versions +of the General Public License from time to time. Such new versions will +be similar in spirit to the present version, but may differ in detail to +address new problems or concerns. + +Each version is given a distinguishing version number. If the Program +specifies a version number of this License which applies to it and "any +later version", you have the option of following the terms and conditions +either of that version or of any later version published by the Free +Software Foundation. If the Program does not specify a version number of +this License, you may choose any version ever published by the Free Software +Foundation. + + 10. If you wish to incorporate parts of the Program into other free +programs whose distribution conditions are different, write to the author +to ask for permission. For software which is copyrighted by the Free +Software Foundation, write to the Free Software Foundation; we sometimes +make exceptions for this. Our decision will be guided by the two goals +of preserving the free status of all derivatives of our free software and +of promoting the sharing and reuse of software generally. + + NO WARRANTY + + 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY +FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN +OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES +PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED +OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF +MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS +TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE +PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, +REPAIR OR CORRECTION. + + 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING +WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR +REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, +INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING +OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED +TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY +YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER +PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE +POSSIBILITY OF SUCH DAMAGES. + + END OF TERMS AND CONDITIONS + + How to Apply These Terms to Your New Programs + + If you develop a new program, and you want it to be of the greatest +possible use to the public, the best way to achieve this is to make it +free software which everyone can redistribute and change under these terms. + + To do so, attach the following notices to the program. It is safest +to attach them to the start of each source file to most effectively +convey the exclusion of warranty; and each file should have at least +the "copyright" line and a pointer to where the full notice is found. + + + Copyright (C) + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +Also add information on how to contact you by electronic and paper mail. + +If the program is interactive, make it output a short notice like this +when it starts in an interactive mode: + + Gnomovision version 69, Copyright (C) year name of author + Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. + This is free software, and you are welcome to redistribute it + under certain conditions; type `show c' for details. + +The hypothetical commands `show w' and `show c' should show the appropriate +parts of the General Public License. Of course, the commands you use may +be called something other than `show w' and `show c'; they could even be +mouse-clicks or menu items--whatever suits your program. + +You should also get your employer (if you work as a programmer) or your +school, if any, to sign a "copyright disclaimer" for the program, if +necessary. Here is a sample; alter the names: + + Yoyodyne, Inc., hereby disclaims all copyright interest in the program + `Gnomovision' (which makes passes at compilers) written by James Hacker. + + , 1 April 1989 + Ty Coon, President of Vice + +This General Public License does not permit incorporating your program into +proprietary programs. If your program is a subroutine library, you may +consider it more useful to permit linking proprietary applications with the +library. If this is what you want to do, use the GNU Lesser General +Public License instead of this License. From b55375c70a6583d77c2f9226dcab6ea3cb8ca02b Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Wed, 14 Apr 2021 07:53:42 +0200 Subject: [PATCH 08/24] fixed size problem of logo in header --- app/components/layout.tsx | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/app/components/layout.tsx b/app/components/layout.tsx index c7128b5..85d2474 100644 --- a/app/components/layout.tsx +++ b/app/components/layout.tsx @@ -75,12 +75,16 @@ export default function Layout({ alignItems="flex-end" marginTop="5px" > - - entel logo - - entel - - + + + {(user || !isMobile) && ( + entel logo + )} + + entel + + + Date: Wed, 14 Apr 2021 07:54:09 +0200 Subject: [PATCH 09/24] replace with by style prop --- app/components/LandingPage/frontPage.tsx | 11 ++++++++--- app/components/LandingPage/frontPageChat.tsx | 8 +++++++- app/components/LandingPage/frontPageOwnedList.tsx | 2 +- app/components/LandingPage/frontPagePublicList.tsx | 2 +- app/components/acceptedList.tsx | 2 +- app/components/ownedList.tsx | 2 +- app/components/publicList.tsx | 2 +- 7 files changed, 20 insertions(+), 9 deletions(-) diff --git a/app/components/LandingPage/frontPage.tsx b/app/components/LandingPage/frontPage.tsx index 94f0509..e9d0685 100644 --- a/app/components/LandingPage/frontPage.tsx +++ b/app/components/LandingPage/frontPage.tsx @@ -71,7 +71,7 @@ export default function FrontPage() { alignItems="Start" justifyContent="center" > - + Share your needs @@ -110,7 +110,7 @@ export default function FrontPage() { specialWish="Buy only Bio and vegan products please :)" itemsList={["Bread", "Jam (Strawberry)", "Agave sirup (from Alnatura)"]} /> - + Help others! @@ -130,7 +130,12 @@ export default function FrontPage() { alignItems="Start" justifyContent="center" > - + Chat to connect diff --git a/app/components/LandingPage/frontPageChat.tsx b/app/components/LandingPage/frontPageChat.tsx index 716062d..a382955 100644 --- a/app/components/LandingPage/frontPageChat.tsx +++ b/app/components/LandingPage/frontPageChat.tsx @@ -32,7 +32,13 @@ export default function Chat() { let date8 = new Date() return ( - + Date: Wed, 14 Apr 2021 08:17:36 +0200 Subject: [PATCH 10/24] add build workflow --- .github/workflows/build.yml | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 .github/workflows/build.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..3c09697 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,37 @@ +name: Build applicaiton + +on: + push: + branches: + - master + pull_request: + branches: + - master + +jobs: + build: + name: Build + runs-on: ubuntu-latest + env: + DATABASE_URL: postgresql://entel:crazypassword@localhost:5432/enteldb + POSTGRES_USER: entel + POSTGRES_PASSWORD: crazypassword + POSTGRES_DB: enteldb + steps: + - uses: actions/checkout@v2 + - name: Use Node.js + uses: actions/setup-node@v1 + with: + node-version: "12.x" + - name: Install dependencies + id: install-dependencies + run: npm i + - name: Start docker + id: start-docker + run: docker-compose up -d + - name: Migrate database + id: migrate-database + run: blitz prisma migrate deploy --preview-feature + - name: Build application + id: build-application + run: blitz build From 46560e7449b46a8633b8965556bd8fe069779ea4 Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Wed, 14 Apr 2021 14:52:52 +0200 Subject: [PATCH 11/24] install tslog --- package-lock.json | 91 +++++++++++------------------------------------ package.json | 7 ++-- 2 files changed, 24 insertions(+), 74 deletions(-) diff --git a/package-lock.json b/package-lock.json index 64c5877..402317a 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3062,7 +3062,6 @@ "version": "6.4.1", "resolved": "https://registry.npmjs.org/@types/nodemailer/-/nodemailer-6.4.1.tgz", "integrity": "sha512-8081UY/0XTTDpuGqCnDc8IY+Q3DSg604wB3dBH0CaZlj4nZWHWuxtZ3NRZ9c9WUrz1Vfm6wioAUnqL3bsh49uQ==", - "dev": true, "requires": { "@types/node": "*" } @@ -3091,7 +3090,6 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/@types/preview-email/-/preview-email-2.0.0.tgz", "integrity": "sha512-23VWTBGp8vrvTT4g833CbMRml0HC7azDUY2n2UF4v3ueWVh/DKLUAxlYAaeew3VarJz7PQH4C0H5nCoBBGkUTA==", - "dev": true, "requires": { "@types/nodemailer": "*" } @@ -3571,8 +3569,7 @@ "asap": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/asap/-/asap-2.0.6.tgz", - "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=", - "dev": true + "integrity": "sha1-5QNHYR1+aQlDIIu9r+vLwvuGbUY=" }, "asn1": { "version": "0.2.4", @@ -3627,8 +3624,7 @@ "assert-never": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/assert-never/-/assert-never-1.2.1.tgz", - "integrity": "sha512-TaTivMB6pYI1kXwrFlEhLeGfOqoDNdTxjCdwRfFFkEA30Eu+k48W34nlok2EYWJfFFzqaEmichdNM7th6M5HNw==", - "dev": true + "integrity": "sha512-TaTivMB6pYI1kXwrFlEhLeGfOqoDNdTxjCdwRfFFkEA30Eu+k48W34nlok2EYWJfFFzqaEmichdNM7th6M5HNw==" }, "assert-plus": { "version": "1.0.0", @@ -3855,7 +3851,6 @@ "version": "3.0.0-canary-5", "resolved": "https://registry.npmjs.org/babel-walk/-/babel-walk-3.0.0-canary-5.tgz", "integrity": "sha512-GAwkz0AihzY5bkwIY5QDR+LvsRQgB/B+1foMPvi0FZPMl5fjD7ICiznUiBdLYMH1QYe6vqu4gWYytZOccLouFw==", - "dev": true, "requires": { "@babel/types": "^7.9.6" } @@ -4306,7 +4301,6 @@ "version": "2.2.0", "resolved": "https://registry.npmjs.org/character-parser/-/character-parser-2.2.0.tgz", "integrity": "sha1-x84o821LzZdE5f/CxfzeHHMmH8A=", - "dev": true, "requires": { "is-regex": "^1.0.3" } @@ -4739,7 +4733,6 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/constantinople/-/constantinople-4.0.1.tgz", "integrity": "sha512-vCrqcSIq4//Gx74TXXCGnHpulY1dskqLTFGDmhrGxzeXL8lF8kvXv6mpNWlJj1uD4DW23D4ljAqbY4RRaaUZIw==", - "dev": true, "requires": { "@babel/parser": "^7.6.0", "@babel/types": "^7.6.1" @@ -5307,8 +5300,7 @@ "dayjs": { "version": "1.10.4", "resolved": "https://registry.npmjs.org/dayjs/-/dayjs-1.10.4.tgz", - "integrity": "sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw==", - "dev": true + "integrity": "sha512-RI/Hh4kqRc1UKLOAf/T5zdMMX5DQIlDxwUe3wSyMMnEbGunnpENCdbUgM+dW7kXidZqCttBrmw7BhN4TMddkCw==" }, "debug": { "version": "4.3.1", @@ -5547,8 +5539,7 @@ "doctypes": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/doctypes/-/doctypes-1.1.0.tgz", - "integrity": "sha1-6oCxBqh1OHdOijpKWv4pPeSJ4Kk=", - "dev": true + "integrity": "sha1-6oCxBqh1OHdOijpKWv4pPeSJ4Kk=" }, "dom-accessibility-api": { "version": "0.5.4", @@ -5559,7 +5550,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/dom-serializer/-/dom-serializer-1.2.0.tgz", "integrity": "sha512-n6kZFH/KlCrqs/1GHMOd5i2fd/beQHuehKdWvNNffbGHTr/almdhuVvTVFb3V7fglz+nC50fFusu3lY33h12pA==", - "dev": true, "requires": { "domelementtype": "^2.0.1", "domhandler": "^4.0.0", @@ -5574,8 +5564,7 @@ "domelementtype": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/domelementtype/-/domelementtype-2.1.0.tgz", - "integrity": "sha512-LsTgx/L5VpD+Q8lmsXSHW2WpA+eBlZ9HPf3erD1IoPF00/3JKHZ3BknUVA2QGDNu69ZNmyFmCWBSO45XjYKC5w==", - "dev": true + "integrity": "sha512-LsTgx/L5VpD+Q8lmsXSHW2WpA+eBlZ9HPf3erD1IoPF00/3JKHZ3BknUVA2QGDNu69ZNmyFmCWBSO45XjYKC5w==" }, "domexception": { "version": "2.0.1", @@ -5596,7 +5585,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/domhandler/-/domhandler-4.0.0.tgz", "integrity": "sha512-KPTbnGQ1JeEMQyO1iYXoagsI6so/C96HZiFyByU3T6iAzpXn8EGEvct6unm1ZGoed8ByO2oirxgwxBmqKF9haA==", - "dev": true, "requires": { "domelementtype": "^2.1.0" } @@ -5605,7 +5593,6 @@ "version": "2.5.0", "resolved": "https://registry.npmjs.org/domutils/-/domutils-2.5.0.tgz", "integrity": "sha512-Ho16rzNMOFk2fPwChGh3D2D9OEHAfG19HgmRR2l+WLSsIstNsAYBzePH412bL0y5T44ejABIVfTHQ8nqi/tBCg==", - "dev": true, "requires": { "dom-serializer": "^1.0.1", "domelementtype": "^2.0.1", @@ -5710,8 +5697,7 @@ "encoding-japanese": { "version": "1.0.30", "resolved": "https://registry.npmjs.org/encoding-japanese/-/encoding-japanese-1.0.30.tgz", - "integrity": "sha512-bd/DFLAoJetvv7ar/KIpE3CNO8wEuyrt9Xuw6nSMiZ+Vrz/Q21BPsMHvARL2Wz6IKHKXgb+DWZqtRg1vql9cBg==", - "dev": true + "integrity": "sha512-bd/DFLAoJetvv7ar/KIpE3CNO8wEuyrt9Xuw6nSMiZ+Vrz/Q21BPsMHvARL2Wz6IKHKXgb+DWZqtRg1vql9cBg==" }, "end-of-stream": { "version": "1.4.4", @@ -5732,8 +5718,7 @@ "entities": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/entities/-/entities-2.2.0.tgz", - "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==", - "dev": true + "integrity": "sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==" }, "env-paths": { "version": "2.2.0", @@ -7539,7 +7524,6 @@ "version": "7.0.0", "resolved": "https://registry.npmjs.org/html-to-text/-/html-to-text-7.0.0.tgz", "integrity": "sha512-UR/WMSHRN8m+L7qQUhbSoxylwBovNPS+xURn/pHeJvbnemhyMiuPYBTBGqB6s8ajAARN5jzKfF0d3CY86VANpA==", - "dev": true, "requires": { "deepmerge": "^4.2.2", "he": "^1.2.0", @@ -7556,7 +7540,6 @@ "version": "6.0.1", "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-6.0.1.tgz", "integrity": "sha512-GDKPd+vk4jvSuvCbyuzx/unmXkk090Azec7LovXP8as1Hn8q9p3hbjmDGbUqqhknw0ajwit6LiiWqfiTUPMK7w==", - "dev": true, "requires": { "domelementtype": "^2.0.1", "domhandler": "^4.0.0", @@ -8124,7 +8107,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/is-expression/-/is-expression-4.0.0.tgz", "integrity": "sha512-zMIXX63sxzG3XrkHkrAPvm/OVZVSCPNkwMHU8oTX7/U3AL78I0QXCEICXUM13BIa8TYGZ68PiTKfQz3yaTNr4A==", - "dev": true, "requires": { "acorn": "^7.1.1", "object-assign": "^4.1.1" @@ -8133,8 +8115,7 @@ "acorn": { "version": "7.4.1", "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.4.1.tgz", - "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==", - "dev": true + "integrity": "sha512-nQyp0o1/mNdbTO1PO6kHkwSrmgZ0MT/jCCpNiwbUjGoRN4dlBhqJtoQuCnEOKzgTVwg0ZWiCoQy6SxMebQVh8A==" } } }, @@ -8230,8 +8211,7 @@ "is-promise": { "version": "2.2.2", "resolved": "https://registry.npmjs.org/is-promise/-/is-promise-2.2.2.tgz", - "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==", - "dev": true + "integrity": "sha512-+lP4/6lKUBfQjZ2pdxThZvLUAafmZb8OAxFb8XXtiQmS35INgr85hdOGoEs124ez1FCnZJt6jau/T+alh58QFQ==" }, "is-regex": { "version": "1.1.2", @@ -9704,8 +9684,7 @@ "js-stringify": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/js-stringify/-/js-stringify-1.0.2.tgz", - "integrity": "sha1-Fzb939lyTyijaCrcYjCufk6Weds=", - "dev": true + "integrity": "sha1-Fzb939lyTyijaCrcYjCufk6Weds=" }, "js-tokens": { "version": "4.0.0", @@ -10008,7 +9987,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/jstransformer/-/jstransformer-1.0.0.tgz", "integrity": "sha1-7Yvwkh4vPx7U1cGkT2hwntJHIsM=", - "dev": true, "requires": { "is-promise": "^2.0.0", "promise": "^7.0.1" @@ -10224,14 +10202,12 @@ "libbase64": { "version": "1.2.1", "resolved": "https://registry.npmjs.org/libbase64/-/libbase64-1.2.1.tgz", - "integrity": "sha512-l+nePcPbIG1fNlqMzrh68MLkX/gTxk/+vdvAb388Ssi7UuUN31MI44w4Yf33mM3Cm4xDfw48mdf3rkdHszLNew==", - "dev": true + "integrity": "sha512-l+nePcPbIG1fNlqMzrh68MLkX/gTxk/+vdvAb388Ssi7UuUN31MI44w4Yf33mM3Cm4xDfw48mdf3rkdHszLNew==" }, "libmime": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/libmime/-/libmime-5.0.0.tgz", "integrity": "sha512-2Bm96d5ktnE217Ib1FldvUaPAaOst6GtZrsxJCwnJgi9lnsoAKIHyU0sae8rNx6DNYbjdqqh8lv5/b9poD8qOg==", - "dev": true, "requires": { "encoding-japanese": "1.0.30", "iconv-lite": "0.6.2", @@ -10243,7 +10219,6 @@ "version": "0.6.2", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.2.tgz", "integrity": "sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==", - "dev": true, "requires": { "safer-buffer": ">= 2.1.2 < 3.0.0" } @@ -10253,8 +10228,7 @@ "libqp": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/libqp/-/libqp-1.1.0.tgz", - "integrity": "sha1-9ebgatdLeU+1tbZpiL9yjvHe2+g=", - "dev": true + "integrity": "sha1-9ebgatdLeU+1tbZpiL9yjvHe2+g=" }, "line-column": { "version": "1.0.2", @@ -10274,7 +10248,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-3.0.2.tgz", "integrity": "sha512-gDBO4aHNZS6coiZCKVhSNh43F9ioIL4JwRjLZPkoLIY4yZFwg264Y5lu2x6rb1Js42Gh6Yqm2f6L2AJcnkzinQ==", - "dev": true, "requires": { "uc.micro": "^1.0.1" } @@ -10586,7 +10559,6 @@ "version": "3.1.0", "resolved": "https://registry.npmjs.org/mailparser/-/mailparser-3.1.0.tgz", "integrity": "sha512-XW8aZ649hdgIxWIiHVsgaX7hUwf3eD4KJvtYOonssDuJHQpFJSqKWvTO5XjclNBF5ARWPFDq5OzBPTYH2i57fg==", - "dev": true, "requires": { "encoding-japanese": "1.0.30", "he": "1.2.0", @@ -10603,7 +10575,6 @@ "version": "0.6.2", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.6.2.tgz", "integrity": "sha512-2y91h5OpQlolefMPmUlivelittSWy0rP+oYVpn6A7GwVHNE8AWzoYOBNmlwks3LobaJxgHCYZAnyNo2GgpNRNQ==", - "dev": true, "requires": { "safer-buffer": ">= 2.1.2 < 3.0.0" } @@ -10611,8 +10582,7 @@ "nodemailer": { "version": "6.4.18", "resolved": "https://registry.npmjs.org/nodemailer/-/nodemailer-6.4.18.tgz", - "integrity": "sha512-ht9cXxQ+lTC+t00vkSIpKHIyM4aXIsQ1tcbQCn5IOnxYHi81W2XOaU66EQBFFpbtzLEBTC94gmkbD4mGZQzVpA==", - "dev": true + "integrity": "sha512-ht9cXxQ+lTC+t00vkSIpKHIyM4aXIsQ1tcbQCn5IOnxYHi81W2XOaU66EQBFFpbtzLEBTC94gmkbD4mGZQzVpA==" } } }, @@ -10620,7 +10590,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/mailsplit/-/mailsplit-5.0.1.tgz", "integrity": "sha512-CcGy1sv8j9jdjKiNIuMZYIKhq4s47nUj9Q98BZfptabH/whmiQX7EvrHx36O4DcyPEsnG152GVNyvqPi9FNIew==", - "dev": true, "requires": { "libbase64": "1.2.1", "libmime": "5.0.0", @@ -11505,7 +11474,6 @@ "version": "7.4.2", "resolved": "https://registry.npmjs.org/open/-/open-7.4.2.tgz", "integrity": "sha512-MVHddDVweXZF3awtlAS+6pgKLlm/JgxZ90+/NBurBoQctVOOB/zDdVjcyPzQ+0laDGbsWgrRkflI65sQeOgT9Q==", - "dev": true, "requires": { "is-docker": "^2.0.0", "is-wsl": "^2.1.1" @@ -12464,7 +12432,6 @@ "version": "3.0.4", "resolved": "https://registry.npmjs.org/preview-email/-/preview-email-3.0.4.tgz", "integrity": "sha512-g9jbnFHI8QfQAcKeCsZpSzMJT/CeGuJoV311R/NLS6PTsalJkMKkUeirSJJgMJBUYOGJLrhM7MsNVWgk1b13BA==", - "dev": true, "requires": { "dayjs": "^1.10.4", "debug": "^4.3.1", @@ -12507,7 +12474,6 @@ "version": "7.3.1", "resolved": "https://registry.npmjs.org/promise/-/promise-7.3.1.tgz", "integrity": "sha512-nolQXZ/4L+bP/UGlkfaIujX9BKxGwmQ9OT4mOt5yvy8iK1h3wqTEJCijzGANTCCl9nWjY41juyAn2K3Q1hLLTg==", - "dev": true, "requires": { "asap": "~2.0.3" } @@ -12567,7 +12533,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/pug/-/pug-3.0.2.tgz", "integrity": "sha512-bp0I/hiK1D1vChHh6EfDxtndHji55XP/ZJKwsRqrz6lRia6ZC2OZbdAymlxdVFwd1L70ebrVJw4/eZ79skrIaw==", - "dev": true, "requires": { "pug-code-gen": "^3.0.2", "pug-filters": "^4.0.0", @@ -12583,7 +12548,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/pug-attrs/-/pug-attrs-3.0.0.tgz", "integrity": "sha512-azINV9dUtzPMFQktvTXciNAfAuVh/L/JCl0vtPCwvOA21uZrC08K/UnmrL+SXGEVc1FwzjW62+xw5S/uaLj6cA==", - "dev": true, "requires": { "constantinople": "^4.0.1", "js-stringify": "^1.0.2", @@ -12594,7 +12558,6 @@ "version": "3.0.2", "resolved": "https://registry.npmjs.org/pug-code-gen/-/pug-code-gen-3.0.2.tgz", "integrity": "sha512-nJMhW16MbiGRiyR4miDTQMRWDgKplnHyeLvioEJYbk1RsPI3FuA3saEP8uwnTb2nTJEKBU90NFVWJBk4OU5qyg==", - "dev": true, "requires": { "constantinople": "^4.0.1", "doctypes": "^1.1.0", @@ -12609,14 +12572,12 @@ "pug-error": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/pug-error/-/pug-error-2.0.0.tgz", - "integrity": "sha512-sjiUsi9M4RAGHktC1drQfCr5C5eriu24Lfbt4s+7SykztEOwVZtbFk1RRq0tzLxcMxMYTBR+zMQaG07J/btayQ==", - "dev": true + "integrity": "sha512-sjiUsi9M4RAGHktC1drQfCr5C5eriu24Lfbt4s+7SykztEOwVZtbFk1RRq0tzLxcMxMYTBR+zMQaG07J/btayQ==" }, "pug-filters": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/pug-filters/-/pug-filters-4.0.0.tgz", "integrity": "sha512-yeNFtq5Yxmfz0f9z2rMXGw/8/4i1cCFecw/Q7+D0V2DdtII5UvqE12VaZ2AY7ri6o5RNXiweGH79OCq+2RQU4A==", - "dev": true, "requires": { "constantinople": "^4.0.1", "jstransformer": "1.0.0", @@ -12629,7 +12590,6 @@ "version": "5.0.1", "resolved": "https://registry.npmjs.org/pug-lexer/-/pug-lexer-5.0.1.tgz", "integrity": "sha512-0I6C62+keXlZPZkOJeVam9aBLVP2EnbeDw3An+k0/QlqdwH6rv8284nko14Na7c0TtqtogfWXcRoFE4O4Ff20w==", - "dev": true, "requires": { "character-parser": "^2.2.0", "is-expression": "^4.0.0", @@ -12640,7 +12600,6 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/pug-linker/-/pug-linker-4.0.0.tgz", "integrity": "sha512-gjD1yzp0yxbQqnzBAdlhbgoJL5qIFJw78juN1NpTLt/mfPJ5VgC4BvkoD3G23qKzJtIIXBbcCt6FioLSFLOHdw==", - "dev": true, "requires": { "pug-error": "^2.0.0", "pug-walk": "^2.0.0" @@ -12650,7 +12609,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/pug-load/-/pug-load-3.0.0.tgz", "integrity": "sha512-OCjTEnhLWZBvS4zni/WUMjH2YSUosnsmjGBB1An7CsKQarYSWQ0GCVyd4eQPMFJqZ8w9xgs01QdiZXKVjk92EQ==", - "dev": true, "requires": { "object-assign": "^4.1.1", "pug-walk": "^2.0.0" @@ -12660,7 +12618,6 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/pug-parser/-/pug-parser-6.0.0.tgz", "integrity": "sha512-ukiYM/9cH6Cml+AOl5kETtM9NR3WulyVP2y4HOU45DyMim1IeP/OOiyEWRr6qk5I5klpsBnbuHpwKmTx6WURnw==", - "dev": true, "requires": { "pug-error": "^2.0.0", "token-stream": "1.0.0" @@ -12669,14 +12626,12 @@ "pug-runtime": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/pug-runtime/-/pug-runtime-3.0.1.tgz", - "integrity": "sha512-L50zbvrQ35TkpHwv0G6aLSuueDRwc/97XdY8kL3tOT0FmhgG7UypU3VztfV/LATAvmUfYi4wNxSajhSAeNN+Kg==", - "dev": true + "integrity": "sha512-L50zbvrQ35TkpHwv0G6aLSuueDRwc/97XdY8kL3tOT0FmhgG7UypU3VztfV/LATAvmUfYi4wNxSajhSAeNN+Kg==" }, "pug-strip-comments": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/pug-strip-comments/-/pug-strip-comments-2.0.0.tgz", "integrity": "sha512-zo8DsDpH7eTkPHCXFeAk1xZXJbyoTfdPlNR0bK7rpOMuhBYb0f5qUVCO1xlsitYd3w5FQTK7zpNVKb3rZoUrrQ==", - "dev": true, "requires": { "pug-error": "^2.0.0" } @@ -12684,8 +12639,7 @@ "pug-walk": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/pug-walk/-/pug-walk-2.0.0.tgz", - "integrity": "sha512-yYELe9Q5q9IQhuvqsZNwA5hfPkMJ8u92bQLIMcsMxf/VADjNtEYptU+inlufAFYcWdHlwNfZOEnOOQrZrcyJCQ==", - "dev": true + "integrity": "sha512-yYELe9Q5q9IQhuvqsZNwA5hfPkMJ8u92bQLIMcsMxf/VADjNtEYptU+inlufAFYcWdHlwNfZOEnOOQrZrcyJCQ==" }, "pump": { "version": "3.0.0", @@ -14775,8 +14729,7 @@ "tlds": { "version": "1.217.0", "resolved": "https://registry.npmjs.org/tlds/-/tlds-1.217.0.tgz", - "integrity": "sha512-iRVizGqUFSBRwScghTSJyRkkEXqLAO17nFwlVcmsNHPDdpE+owH91wDUmZXZfJ4UdBYuVSm7kyAXZo0c4X7GFQ==", - "dev": true + "integrity": "sha512-iRVizGqUFSBRwScghTSJyRkkEXqLAO17nFwlVcmsNHPDdpE+owH91wDUmZXZfJ4UdBYuVSm7kyAXZo0c4X7GFQ==" }, "tmp": { "version": "0.2.1", @@ -14906,8 +14859,7 @@ "token-stream": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/token-stream/-/token-stream-1.0.0.tgz", - "integrity": "sha1-zCAOqyYT9BZtJ/+a/HylbUnfbrQ=", - "dev": true + "integrity": "sha1-zCAOqyYT9BZtJ/+a/HylbUnfbrQ=" }, "tough-cookie": { "version": "4.0.0", @@ -15199,8 +15151,7 @@ "uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", - "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==", - "dev": true + "integrity": "sha512-8Y75pvTYkLJW2hWQHXxoqRgV7qb9B+9vFEtidML+7koHUFapnVJAZ6cKs+Qjz5Aw3aZWHMC6u0wJE3At+nSGwA==" }, "unbox-primitive": { "version": "1.0.1", @@ -15688,8 +15639,7 @@ "void-elements": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/void-elements/-/void-elements-3.1.0.tgz", - "integrity": "sha1-YU9/v42AHwu18GYfWy9XhXUOTwk=", - "dev": true + "integrity": "sha1-YU9/v42AHwu18GYfWy9XhXUOTwk=" }, "w3c-hr-time": { "version": "1.0.2", @@ -15850,7 +15800,6 @@ "version": "7.0.2", "resolved": "https://registry.npmjs.org/with/-/with-7.0.2.tgz", "integrity": "sha512-RNGKj82nUPg3g5ygxkQl0R937xLyho1J24ItRCBTr/m1YnZkzJy1hUiHUJrc/VlsDQzsCnInEGSg3bci0Lmd4w==", - "dev": true, "requires": { "@babel/parser": "^7.9.6", "@babel/types": "^7.9.6", diff --git a/package.json b/package.json index 975953c..0a9adcd 100644 --- a/package.json +++ b/package.json @@ -37,10 +37,12 @@ "@emotion/styled": "11.1.5", "@prisma/client": "~2.19", "@react-icons/all-files": "4.1.0", + "@types/preview-email": "2.0.0", "blitz": "0.33.1", "final-form": "4.20.2", "framer-motion": "4.0.3", "nodemailer": "6.5.0", + "preview-email": "3.0.4", "prisma": "~2.19", "react": ">=0.14.0", "react-dom": "0.0.0-experimental-6a589ad71", @@ -48,10 +50,9 @@ "react-final-form": "6.5.3", "react-icons": "4.2.0", "react-responsive": "8.2.0", + "tslog": "3.1.2", "typescript": "~4.1", - "zod": "1.11.13", - "preview-email": "3.0.4", - "@types/preview-email": "2.0.0" + "zod": "1.11.13" }, "devDependencies": { "@types/preview-email": "2.0.0", From ba85faeb069d4c6da1c70570a2e2097a02ff92de Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Wed, 14 Apr 2021 14:53:22 +0200 Subject: [PATCH 12/24] Add some log statements to components --- app/auth/components/LoginForm.tsx | 5 +++++ app/auth/components/SignupForm.tsx | 8 +++++--- app/components/acceptedList.tsx | 5 ++++- app/components/changePasswordModal.tsx | 7 +++++++ app/components/createLists.tsx | 10 +++++++++- app/components/editList.tsx | 10 +++++++++- app/components/ownedList.tsx | 7 +++++++ app/components/publicList.tsx | 4 ++++ app/components/removeListModal.tsx | 4 ++++ 9 files changed, 54 insertions(+), 6 deletions(-) diff --git a/app/auth/components/LoginForm.tsx b/app/auth/components/LoginForm.tsx index e1b459c..63bed6a 100644 --- a/app/auth/components/LoginForm.tsx +++ b/app/auth/components/LoginForm.tsx @@ -5,6 +5,7 @@ import login from "app/auth/mutations/login" import { Login } from "app/auth/validations" import { Flex, Heading, Button, useDisclosure, Box } from "@chakra-ui/react" import ForgotPasswordPage from "app/auth/pages/forgot-password" +import { Logger } from "tslog" type LoginFormProps = { onSuccess?: () => Promise | void @@ -13,6 +14,7 @@ type LoginFormProps = { export const LoginForm = (props: LoginFormProps) => { const [loginMutation] = useMutation(login) const { isOpen, onOpen, onClose } = useDisclosure() + const log: Logger = new Logger() return ( @@ -41,10 +43,13 @@ export const LoginForm = (props: LoginFormProps) => { try { await loginMutation(values) await props.onSuccess?.() + log.info("Login was successfull.") } catch (error) { if (error instanceof AuthenticationError) { + log.warn("Login failed, because of invalid credentials.") return { [FORM_ERROR]: "Sorry, those credentials are invalid" } } else { + log.error("Login failed, because of an unexpected error.", { error: error }) return { [FORM_ERROR]: "Sorry, we had an unexpected error. Please try again. - " + error.toString(), diff --git a/app/auth/components/SignupForm.tsx b/app/auth/components/SignupForm.tsx index c444a6a..abe8cc6 100644 --- a/app/auth/components/SignupForm.tsx +++ b/app/auth/components/SignupForm.tsx @@ -4,7 +4,7 @@ import { Form, FORM_ERROR } from "app/core/components/Form" import signup from "app/auth/mutations/signup" import { Signup } from "app/auth/validations" import { Heading, Flex, Button, useDisclosure, Box } from "@chakra-ui/react" - +import { Logger } from "tslog" type SignupFormProps = { onSuccess?: () => Promise } @@ -12,7 +12,7 @@ type SignupFormProps = { export const SignupForm = (props: SignupFormProps) => { const [signupMutation] = useMutation(signup) const { isOpen, onOpen, onClose } = useDisclosure() - + const log: Logger = new Logger() return ( { try { await signupMutation(values) await props.onSuccess?.() + log.info("Sign up was successfull.") } catch (error) { if (error.code === "P2002" && error.meta?.target?.includes("email")) { - // This error comes from Prisma + log.warn("Login failed, because the email is already being used.") return { email: "This email is already being used" } } else { + log.error("Login failed, because of an unexpected error.", { error: error }) return { [FORM_ERROR]: error.toString() } } } diff --git a/app/components/acceptedList.tsx b/app/components/acceptedList.tsx index 83ba26b..0cdefef 100644 --- a/app/components/acceptedList.tsx +++ b/app/components/acceptedList.tsx @@ -23,7 +23,7 @@ import getChatByParticipants from "app/queries/getChatByParticipants" import { BiShoppingBag, BiUserCircle, BiStore } from "react-icons/bi" import { Link as BlitzLink } from "blitz" import { getDistanceString, useCurrentPosition } from "app/lib/position" -import { useEffect } from "react" +import { Logger } from "tslog" interface AcceptedListProps { distance: Number @@ -52,6 +52,7 @@ export default function AcceptedList({ const router = useRouter() const toast = createStandaloneToast() useCurrentPosition() + const log: Logger = new Logger() return ( {" "} @@ -156,6 +158,7 @@ export default function AcceptedList({ duration: 7000, isClosable: true, }) + log.info("The status of a shoppinglist changed from 'in progress' to 'pending'") }} > {" "} diff --git a/app/components/changePasswordModal.tsx b/app/components/changePasswordModal.tsx index 8cf44e2..8020d01 100644 --- a/app/components/changePasswordModal.tsx +++ b/app/components/changePasswordModal.tsx @@ -19,10 +19,12 @@ import changePassword from "app/auth/mutations/changePassword" import { Form, Field } from "react-final-form" import { FORM_ERROR } from "final-form" import * as z from "zod" +import { Logger } from "tslog" export function ChangePassword({ isOpen, onClose }) { const [changePasswordMutation] = useMutation(changePassword) const toast = useToast() + const log: Logger = new Logger() return ( @@ -43,10 +45,15 @@ export function ChangePassword({ isOpen, onClose }) { isClosable: true, }) onClose() + log.info("A user changed her/his password successfully.") } catch (error) { if (error instanceof AuthenticationError) { + log.warn("Password change failed, because of invalid credentials.") return { [FORM_ERROR]: "Sorry, those credentials are invalid" } } else { + log.error("Password change failed, because of an unexpected error.", { + error: error, + }) toast({ title: "Sorry", description: "Something went wrong. Please try again.", diff --git a/app/components/createLists.tsx b/app/components/createLists.tsx index 3602f66..4591f24 100644 --- a/app/components/createLists.tsx +++ b/app/components/createLists.tsx @@ -25,6 +25,7 @@ import { AddIcon, DeleteIcon } from "@chakra-ui/icons" import { useState, useEffect } from "react" import { Form, Field } from "react-final-form" import addItem from "../mutations/addItem" +import { Logger } from "tslog" export default function CreateLists() { const [createListMutation] = useMutation(createList) @@ -34,6 +35,7 @@ export default function CreateLists() { const [idList, setIdList] = useState([0]) const { isOpen, onOpen, onClose } = useDisclosure() const toast = createStandaloneToast() + const log: Logger = new Logger() useEffect(() => { try { @@ -88,6 +90,8 @@ export default function CreateLists() { setIdList([0]) setCountItems(1) onClose() + log.info("A new shoppinglist was created successfully.") + toast({ title: "Successfully Created List", description: "You will find your created lists under 'Home'", @@ -95,7 +99,11 @@ export default function CreateLists() { duration: 5000, isClosable: true, }) - } catch (error) {} + } catch (error) { + log.error("Creating a new shoppinglist failed, because of an unexpected error.", { + error: error, + }) + } }} validate={(values) => { const errors = {} diff --git a/app/components/editList.tsx b/app/components/editList.tsx index 7c6500a..e32cb8a 100644 --- a/app/components/editList.tsx +++ b/app/components/editList.tsx @@ -26,6 +26,7 @@ import { Form, Field } from "react-final-form" import addItem from "../mutations/addItem" import updateStoreComment from "../mutations/updateStoreComment" import removeAllItems from "../mutations/removeAllItems" +import { Logger } from "tslog" export default function EditLists({ getList }) { const { isOpen, onOpen, onClose } = useDisclosure() @@ -50,6 +51,8 @@ export default function EditLists({ getList }) { } catch {} }, [countItems]) + const log: Logger = new Logger() + return ( <> { const errors = {} diff --git a/app/components/ownedList.tsx b/app/components/ownedList.tsx index 92e0243..5233594 100644 --- a/app/components/ownedList.tsx +++ b/app/components/ownedList.tsx @@ -21,6 +21,7 @@ import { BsArchive } from "react-icons/bs" import archiveList from "../mutations/archiveList" import BrandBadge from "./BrandBadge" import { Link as BlitzLink } from "blitz" +import { Logger } from "tslog" interface OwnedListProps { marketName: String @@ -47,6 +48,8 @@ export default function OwnedList({ const router = useRouter() const [archiveListMutation] = useMutation(archiveList) const toast = createStandaloneToast() + const log: Logger = new Logger() + return ( { await archiveListMutation(listId) + log.info("The status of a shoppinglist changed from 'pending' to 'archived'") + toast({ title: "Successfully Archived List", description: "You will find your archived lists under 'Menu/Archived Lists'", @@ -136,6 +141,8 @@ export default function OwnedList({ onClick={async () => { await renewListMutation(listId) refetch() + log.info("The status of a shoppinglist changed from 'archived' to 'pending'") + toast({ title: "Successfully Renewed List", description: "You will find your published lists under 'Home'", diff --git a/app/components/publicList.tsx b/app/components/publicList.tsx index c8f9002..0b7b399 100644 --- a/app/components/publicList.tsx +++ b/app/components/publicList.tsx @@ -23,6 +23,7 @@ import createChat from "../mutations/createChat" import createAdminMessage from "../mutations/createAdminMessage" import getChatByParticipants from "../queries/getChatByParticipants" import { getDistanceString } from "app/lib/position" +import { Logger } from "tslog" interface PublicListProps { distance: Number @@ -50,6 +51,8 @@ export default function PublicList({ const [createAdminMessageMutation] = useMutation(createAdminMessage) const [chat] = useQuery(getChatByParticipants, { ownerId }) const toast = createStandaloneToast() + const log: Logger = new Logger() + return ( { const { isOpen, onOpen, onClose } = useDisclosure() const [removeShoppinglistMutation] = useMutation(removeShoppinglist) const toast = createStandaloneToast() + const log: Logger = new Logger() return ( <> { onClick={async () => { onClose() await removeShoppinglistMutation({ id: modalFooter }) + log.info("A shoppinglist was deleted permanently.") + toast({ title: "Successfully Deleted List", description: "This list is permanently deleted from your records", From f4724063bdd8dc4d439575e38aa5c4f6e8ebacf0 Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Wed, 14 Apr 2021 14:53:38 +0200 Subject: [PATCH 13/24] add some log statements to mutations --- app/mutations/acceptList.tsx | 3 +++ app/mutations/addItem.tsx | 3 +++ app/mutations/archiveList.tsx | 3 +++ app/mutations/createAdminMessage.tsx | 4 ++++ app/mutations/createChat.tsx | 3 +++ app/mutations/createList.tsx | 3 +++ app/mutations/doneList.tsx | 3 +++ app/mutations/markAdminAsRead.tsx | 3 +++ app/mutations/markMessagesAsRead.tsx | 3 +++ app/mutations/removeAllItems.tsx | 3 +++ app/mutations/removeShoppinglist.tsx | 3 +++ app/mutations/renewList.tsx | 3 +++ app/mutations/sendMessage.tsx | 3 +++ app/mutations/updatePoisition.tsx | 3 +++ app/mutations/updateStoreComment.tsx | 3 +++ 15 files changed, 46 insertions(+) diff --git a/app/mutations/acceptList.tsx b/app/mutations/acceptList.tsx index b34d34c..f071e78 100644 --- a/app/mutations/acceptList.tsx +++ b/app/mutations/acceptList.tsx @@ -1,5 +1,6 @@ import db from "db" import { Ctx } from "blitz" +import { Logger } from "tslog" export default async function acceptList(listId, context: Ctx) { context.session.$authorize() @@ -7,4 +8,6 @@ export default async function acceptList(listId, context: Ctx) { where: { id: listId }, data: { status: 1, acceptedBy: { connect: { id: context.session.userId } } }, }) + const log: Logger = new Logger({ name: "db" }) + log.info("List changed status to '2'.") } diff --git a/app/mutations/addItem.tsx b/app/mutations/addItem.tsx index 9dc9bab..a1b0073 100644 --- a/app/mutations/addItem.tsx +++ b/app/mutations/addItem.tsx @@ -1,9 +1,12 @@ import db from "db" import { Ctx } from "blitz" +import { Logger } from "tslog" export default async function addItem({ listId, itemName }, context: Ctx) { context.session.$authorize() await db.item.create({ data: { name: itemName, listedIn: { connect: { id: listId } } }, }) + const log: Logger = new Logger({ name: "db" }) + log.info("New item was created.") } diff --git a/app/mutations/archiveList.tsx b/app/mutations/archiveList.tsx index ed33f92..29ee3d4 100644 --- a/app/mutations/archiveList.tsx +++ b/app/mutations/archiveList.tsx @@ -1,5 +1,6 @@ import db from "db" import { Ctx } from "blitz" +import { Logger } from "tslog" export default async function archiveList(listId, context: Ctx) { context.session.$authorize() @@ -7,4 +8,6 @@ export default async function archiveList(listId, context: Ctx) { where: { id: listId }, data: { status: 2 }, }) + const log: Logger = new Logger({ name: "db" }) + log.info("List changed status to '2'.") } diff --git a/app/mutations/createAdminMessage.tsx b/app/mutations/createAdminMessage.tsx index 1d03a04..207178f 100644 --- a/app/mutations/createAdminMessage.tsx +++ b/app/mutations/createAdminMessage.tsx @@ -1,6 +1,7 @@ import db from "db" import { Ctx } from "blitz" import { newMessageMailer } from "mailers/newMessageMailer" +import { Logger } from "tslog" export default async function createAdminMessage({ content, chatId }, context: Ctx) { context.session.$authorize() @@ -8,6 +9,9 @@ export default async function createAdminMessage({ content, chatId }, context: C data: { content: content, sentIn: { connect: { id: chatId } } }, }) await sentMail(chatId, content) + + const log: Logger = new Logger() + log.info("AdminMessage was sent") } async function sentMail(chatId, content) { diff --git a/app/mutations/createChat.tsx b/app/mutations/createChat.tsx index a652239..5bd62e4 100644 --- a/app/mutations/createChat.tsx +++ b/app/mutations/createChat.tsx @@ -1,5 +1,6 @@ import db from "db" import { Ctx } from "blitz" +import { Logger } from "tslog" export default async function createChat({ opponentId }, context: Ctx) { context.session.$authorize() @@ -10,5 +11,7 @@ export default async function createChat({ opponentId }, context: Ctx) { select: { id: true }, }) + const log: Logger = new Logger({ name: "db" }) + log.debug("Created new chat.") return lists } diff --git a/app/mutations/createList.tsx b/app/mutations/createList.tsx index 9c28544..d92278d 100644 --- a/app/mutations/createList.tsx +++ b/app/mutations/createList.tsx @@ -1,5 +1,6 @@ import db from "db" import { Ctx } from "blitz" +import { Logger } from "tslog" export default async function createList({ store, specialWish }, context: Ctx) { context.session.$authorize() @@ -12,5 +13,7 @@ export default async function createList({ store, specialWish }, context: Ctx) { }, select: { id: true }, }) + const log: Logger = new Logger({ name: "db" }) + log.debug("Created new shoppinglist.") return lists } diff --git a/app/mutations/doneList.tsx b/app/mutations/doneList.tsx index 7019df0..3a77766 100644 --- a/app/mutations/doneList.tsx +++ b/app/mutations/doneList.tsx @@ -1,5 +1,6 @@ import db from "db" import { Ctx } from "blitz" +import { Logger } from "tslog" export default async function doneList(listId, context: Ctx) { context.session.$authorize() @@ -7,4 +8,6 @@ export default async function doneList(listId, context: Ctx) { where: { id: listId }, data: { status: 2, acceptedBy: { disconnect: true } }, }) + const log: Logger = new Logger({ name: "db" }) + log.debug("List changed status to '2'.") } diff --git a/app/mutations/markAdminAsRead.tsx b/app/mutations/markAdminAsRead.tsx index c92ea4a..40bcf25 100644 --- a/app/mutations/markAdminAsRead.tsx +++ b/app/mutations/markAdminAsRead.tsx @@ -1,5 +1,6 @@ import db from "db" import { Ctx } from "blitz" +import { Logger } from "tslog" export default async function markAdminMessagesAsRead({ chatId }, context: Ctx) { context.session.$authorize() @@ -14,4 +15,6 @@ export default async function markAdminMessagesAsRead({ chatId }, context: Ctx) }) }) await Promise.all(promisses) + const log: Logger = new Logger({ name: "db" }) + log.debug("AdminMessages marked as read.") } diff --git a/app/mutations/markMessagesAsRead.tsx b/app/mutations/markMessagesAsRead.tsx index acf0a52..5e8b07f 100644 --- a/app/mutations/markMessagesAsRead.tsx +++ b/app/mutations/markMessagesAsRead.tsx @@ -1,5 +1,6 @@ import db from "db" import { Ctx } from "blitz" +import { Logger } from "tslog" export default async function markMessagesAsRead({ chatId }, context: Ctx) { context.session.$authorize() @@ -7,4 +8,6 @@ export default async function markMessagesAsRead({ chatId }, context: Ctx) { where: { sentInId: chatId, sentToId: context.session.userId }, data: { wasRead: true }, }) + const log: Logger = new Logger({ name: "db" }) + log.debug("Messages marked as read.") } diff --git a/app/mutations/removeAllItems.tsx b/app/mutations/removeAllItems.tsx index 6d988c4..86bb4b5 100644 --- a/app/mutations/removeAllItems.tsx +++ b/app/mutations/removeAllItems.tsx @@ -1,9 +1,12 @@ import db from "db" import { Ctx } from "blitz" +import { Logger } from "tslog" export default async function removeAllItems({ id }, context: Ctx) { context.session.$authorize() await db.item.deleteMany({ where: { listId: id }, }) + const log: Logger = new Logger({ name: "db" }) + log.debug("Items were removed.") } diff --git a/app/mutations/removeShoppinglist.tsx b/app/mutations/removeShoppinglist.tsx index 0ca577a..cf57c02 100644 --- a/app/mutations/removeShoppinglist.tsx +++ b/app/mutations/removeShoppinglist.tsx @@ -1,5 +1,6 @@ import db from "db" import { Ctx } from "blitz" +import { Logger } from "tslog" export default async function removeShoppinglist({ id }, context: Ctx) { context.session.$authorize() @@ -10,4 +11,6 @@ export default async function removeShoppinglist({ id }, context: Ctx) { await db.shoppinglist.delete({ where: { id: id }, }) + const log: Logger = new Logger({ name: "db" }) + log.debug("A shoopinglist was removed.") } diff --git a/app/mutations/renewList.tsx b/app/mutations/renewList.tsx index 6005f2e..64e5a14 100644 --- a/app/mutations/renewList.tsx +++ b/app/mutations/renewList.tsx @@ -1,5 +1,6 @@ import db from "db" import { Ctx } from "blitz" +import { Logger } from "tslog" export default async function renewList(listId, context: Ctx) { context.session.$authorize() @@ -7,4 +8,6 @@ export default async function renewList(listId, context: Ctx) { where: { id: listId }, data: { status: 0 }, }) + const log: Logger = new Logger({ name: "db" }) + log.debug("List changed status to '0'.") } diff --git a/app/mutations/sendMessage.tsx b/app/mutations/sendMessage.tsx index f35d7e2..07de6ec 100644 --- a/app/mutations/sendMessage.tsx +++ b/app/mutations/sendMessage.tsx @@ -1,6 +1,7 @@ import db from "db" import { Ctx } from "blitz" import { newMessageMailer } from "mailers/newMessageMailer" +import { Logger } from "tslog" export default async function sendMessage({ content, chatId, partId }, context: Ctx) { context.session.$authorize() @@ -14,6 +15,8 @@ export default async function sendMessage({ content, chatId, partId }, context: }) sentMail(chatId, partId, content, context) + const log: Logger = new Logger({ name: "db" }) + log.info("A Message was sent.") } async function sentMail(chatId, partId, content, context: Ctx) { diff --git a/app/mutations/updatePoisition.tsx b/app/mutations/updatePoisition.tsx index 2b02425..33bae9d 100644 --- a/app/mutations/updatePoisition.tsx +++ b/app/mutations/updatePoisition.tsx @@ -1,5 +1,6 @@ import db from "db" import { Ctx } from "blitz" +import { Logger } from "tslog" export default async function updatePosition({ new_longitude, new_latitude }, context: Ctx) { context.session.$authorize() @@ -7,4 +8,6 @@ export default async function updatePosition({ new_longitude, new_latitude }, co where: { id: context.session.userId }, data: { last_latitude: new_latitude, last_longitude: new_longitude }, }) + const log: Logger = new Logger({ name: "db" }) + log.info("A Position was updated.") } diff --git a/app/mutations/updateStoreComment.tsx b/app/mutations/updateStoreComment.tsx index c8742bf..566e21b 100644 --- a/app/mutations/updateStoreComment.tsx +++ b/app/mutations/updateStoreComment.tsx @@ -1,5 +1,6 @@ import db from "db" import { Ctx } from "blitz" +import { Logger } from "tslog" export default async function updateStoreComment({ id, store, comment }, context: Ctx) { context.session.$authorize() @@ -7,4 +8,6 @@ export default async function updateStoreComment({ id, store, comment }, context where: { id: id }, data: { store: store, comment: comment }, }) + const log: Logger = new Logger({ name: "db" }) + log.info("A store or/and comment of a shoppinglist were updated.") } From d537cbc96418302a7608494067c74c718b4076cc Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Wed, 14 Apr 2021 14:53:54 +0200 Subject: [PATCH 14/24] add some logstatements to pages and mailers --- app/pages/chats/[chatId].tsx | 5 +++++ mailers/forgotPasswordMailer.ts | 5 +++++ mailers/newMessageMailer.ts | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/app/pages/chats/[chatId].tsx b/app/pages/chats/[chatId].tsx index 6fbe084..d3fc7cb 100644 --- a/app/pages/chats/[chatId].tsx +++ b/app/pages/chats/[chatId].tsx @@ -27,6 +27,7 @@ import { RiMailSendLine } from "react-icons/ri" import { BiUserCircle } from "react-icons/bi" import markAdminMessagesAsRead from "app/mutations/markAdminAsRead" import checkIfUnreadMessage from "app/queries/checkIfUnreadMessages" +import { Logger } from "tslog" export default function Chat() { const chatId = useParam("chatId", "number") @@ -56,6 +57,8 @@ export default function Chat() { const [hasUnreadMessage] = useQuery(checkIfUnreadMessage, null, { refetchInterval: 2000 }) + const log: Logger = new Logger() + return ( <> @@ -133,6 +136,8 @@ export default function Chat() { chatId: chatId, partId: oppositeName.id, }) + log.warn("A message was sent successfully.") + messagesExtra.refetch() }} initialValues={{ content: "" }} diff --git a/mailers/forgotPasswordMailer.ts b/mailers/forgotPasswordMailer.ts index a95c48d..669b3de 100644 --- a/mailers/forgotPasswordMailer.ts +++ b/mailers/forgotPasswordMailer.ts @@ -6,6 +6,7 @@ */ import previewEmail from "preview-email" import nodemailer from "nodemailer" +import { Logger } from "tslog" type ResetPasswordMailer = { to: string token: string @@ -38,13 +39,17 @@ export function forgotPasswordMailer({ to, token }: ResetPasswordMailer) { `, } + const log: Logger = new Logger({ name: "mailer" }) + return { async send() { if (process.env.NODE_ENV === "production") { await smtp.sendMail(msg) + log.info("An email was sent.") } else { // Preview email in the browser await previewEmail(msg) + log.info("An preview mail was created.") } }, } diff --git a/mailers/newMessageMailer.ts b/mailers/newMessageMailer.ts index ae57715..92abd1d 100644 --- a/mailers/newMessageMailer.ts +++ b/mailers/newMessageMailer.ts @@ -6,6 +6,7 @@ */ import previewEmail from "preview-email" import nodemailer from "nodemailer" +import { Logger } from "tslog" type NewMessageMailerProps = { to: string from: string @@ -39,14 +40,17 @@ export function newMessageMailer({ to, chatid, from, messageContent }: NewMessag

${chatUrl}

`, } + const log: Logger = new Logger({ name: "mailer" }) return { async send() { if (process.env.NODE_ENV === "production") { await smtp.sendMail(msg) + log.info("An email was sent.") } else { // Preview email in the browser await previewEmail(msg) + log.info("An preview mail was created.") } }, } From bd689c2abc79ce790545d514470c158a67665f8b Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Wed, 14 Apr 2021 15:30:46 +0200 Subject: [PATCH 15/24] improved error handling --- app/pages/_app.tsx | 10 ++++++++-- app/pages/chats/[chatId].tsx | 4 ++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/app/pages/_app.tsx b/app/pages/_app.tsx index 2988844..4b1aa0c 100644 --- a/app/pages/_app.tsx +++ b/app/pages/_app.tsx @@ -5,6 +5,7 @@ import { AuthenticationError, AuthorizationError, ErrorFallbackProps, + Router, } from "blitz" import { Suspense } from "react" import { ErrorBoundary } from "react-error-boundary" @@ -135,12 +136,17 @@ export default function App({ Component, pageProps }: AppProps) { function RootErrorFallback({ error, resetErrorBoundary }: ErrorFallbackProps) { if (error instanceof AuthenticationError) { - return + return ( + + ) } else if (error instanceof AuthorizationError) { return ( ) } else { diff --git a/app/pages/chats/[chatId].tsx b/app/pages/chats/[chatId].tsx index 6fbe084..13485f2 100644 --- a/app/pages/chats/[chatId].tsx +++ b/app/pages/chats/[chatId].tsx @@ -16,7 +16,7 @@ import StrangeMessage from "app/components/chats/strangeMessage" import Layout from "app/components/layout" import { useCurrentUser } from "app/core/hooks/useCurrentUser" import getMessagesByChat from "app/queries/getMessagesByChat" -import { useQuery, useParam, useMutation, Head } from "blitz" +import { useQuery, useParam, useMutation, Head, AuthorizationError } from "blitz" import { Form, Field } from "react-final-form" import { FORM_ERROR } from "final-form" import getParticipantsByChatId from "../../queries/getParticipantsByChatId" @@ -34,7 +34,7 @@ export default function Chat() { const [participants] = useQuery(getParticipantsByChatId, { id: chatId! }) if (!participants.map((part) => part.id).includes(currentUser!.id)) { - window.location.href = "/" + throw new AuthorizationError("You're not part of this chat.") } const oppositeName = participants.filter((part) => part.id != currentUser?.id)[0] From 4832ec1a399d5b736c112ccbedfcadfd56ed1c8c Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Wed, 14 Apr 2021 17:31:56 +0200 Subject: [PATCH 16/24] added bracket --- app/components/LandingPage/frontPage.tsx | 6 +++--- app/components/LandingPage/frontPageChat.tsx | 2 +- app/components/LandingPage/frontPageOwnedList.tsx | 2 +- app/components/LandingPage/frontPagePublicList.tsx | 2 +- app/components/acceptedList.tsx | 2 +- app/components/ownedList.tsx | 2 +- app/components/publicList.tsx | 2 +- 7 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/components/LandingPage/frontPage.tsx b/app/components/LandingPage/frontPage.tsx index e9d0685..5949b25 100644 --- a/app/components/LandingPage/frontPage.tsx +++ b/app/components/LandingPage/frontPage.tsx @@ -71,7 +71,7 @@ export default function FrontPage() { alignItems="Start" justifyContent="center" > - + Share your needs @@ -110,7 +110,7 @@ export default function FrontPage() { specialWish="Buy only Bio and vegan products please :)" itemsList={["Bread", "Jam (Strawberry)", "Agave sirup (from Alnatura)"]} /> - + Help others! @@ -131,7 +131,7 @@ export default function FrontPage() { justifyContent="center" > diff --git a/app/components/LandingPage/frontPageOwnedList.tsx b/app/components/LandingPage/frontPageOwnedList.tsx index 10d6fca..1e42f5b 100644 --- a/app/components/LandingPage/frontPageOwnedList.tsx +++ b/app/components/LandingPage/frontPageOwnedList.tsx @@ -39,7 +39,7 @@ export default function OwnedList({ Date: Wed, 14 Apr 2021 17:36:03 +0200 Subject: [PATCH 17/24] fix install error --- .github/workflows/build.yml | 36 +++++++++++++++++++++++++++--------- 1 file changed, 27 insertions(+), 9 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 3c09697..485fc67 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -4,19 +4,37 @@ on: push: branches: - master + - develop pull_request: branches: - master + - develop jobs: build: name: Build runs-on: ubuntu-latest + services: + # Label used to access the service container + postgres: + # Docker Hub image + image: postgres + # Provide the password for postgres + env: + POSTGRES_USER: entel + POSTGRES_PASSWORD: crazypassword + POSTGRES_DB: enteldb + # Set health checks to wait until postgres has started + options: >- + --health-cmd pg_isready + --health-interval 10s + --health-timeout 5s + --health-retries 5 + ports: + # Maps tcp port 5432 on service container to the host + - 5432:5432 env: DATABASE_URL: postgresql://entel:crazypassword@localhost:5432/enteldb - POSTGRES_USER: entel - POSTGRES_PASSWORD: crazypassword - POSTGRES_DB: enteldb steps: - uses: actions/checkout@v2 - name: Use Node.js @@ -25,13 +43,13 @@ jobs: node-version: "12.x" - name: Install dependencies id: install-dependencies - run: npm i - - name: Start docker - id: start-docker - run: docker-compose up -d + run: yarn install - name: Migrate database id: migrate-database - run: blitz prisma migrate deploy --preview-feature + run: npx blitz prisma migrate deploy --preview-feature - name: Build application id: build-application - run: blitz build + run: npm run build + - name: Run unittests + id: run-unittests + run: npm run test From 9479605f015689618b9c6757a54b18d6221cc16d Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Wed, 14 Apr 2021 19:30:58 +0200 Subject: [PATCH 18/24] add hint to relead page --- app/pages/_app.tsx | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/pages/_app.tsx b/app/pages/_app.tsx index 4b1aa0c..591a0c2 100644 --- a/app/pages/_app.tsx +++ b/app/pages/_app.tsx @@ -139,7 +139,9 @@ function RootErrorFallback({ error, resetErrorBoundary }: ErrorFallbackProps) { return ( ) } else if (error instanceof AuthorizationError) { From faf1832d6e17b515c77de011343b050341224642 Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Wed, 14 Apr 2021 19:36:54 +0200 Subject: [PATCH 19/24] improve log messages --- app/mutations/acceptList.tsx | 2 +- app/mutations/archiveList.tsx | 2 +- app/mutations/renewList.tsx | 2 +- mailers/forgotPasswordMailer.ts | 4 ++-- mailers/newMessageMailer.ts | 4 ++-- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/app/mutations/acceptList.tsx b/app/mutations/acceptList.tsx index f071e78..d41a63a 100644 --- a/app/mutations/acceptList.tsx +++ b/app/mutations/acceptList.tsx @@ -9,5 +9,5 @@ export default async function acceptList(listId, context: Ctx) { data: { status: 1, acceptedBy: { connect: { id: context.session.userId } } }, }) const log: Logger = new Logger({ name: "db" }) - log.info("List changed status to '2'.") + log.info("List changed status to 'in progress'.") } diff --git a/app/mutations/archiveList.tsx b/app/mutations/archiveList.tsx index 29ee3d4..445bcb1 100644 --- a/app/mutations/archiveList.tsx +++ b/app/mutations/archiveList.tsx @@ -9,5 +9,5 @@ export default async function archiveList(listId, context: Ctx) { data: { status: 2 }, }) const log: Logger = new Logger({ name: "db" }) - log.info("List changed status to '2'.") + log.info("List changed status to 'archived'.") } diff --git a/app/mutations/renewList.tsx b/app/mutations/renewList.tsx index 64e5a14..1eb42ba 100644 --- a/app/mutations/renewList.tsx +++ b/app/mutations/renewList.tsx @@ -9,5 +9,5 @@ export default async function renewList(listId, context: Ctx) { data: { status: 0 }, }) const log: Logger = new Logger({ name: "db" }) - log.debug("List changed status to '0'.") + log.debug("List changed status to 'in progress'.") } diff --git a/mailers/forgotPasswordMailer.ts b/mailers/forgotPasswordMailer.ts index 669b3de..8820837 100644 --- a/mailers/forgotPasswordMailer.ts +++ b/mailers/forgotPasswordMailer.ts @@ -45,11 +45,11 @@ export function forgotPasswordMailer({ to, token }: ResetPasswordMailer) { async send() { if (process.env.NODE_ENV === "production") { await smtp.sendMail(msg) - log.info("An email was sent.") + log.info("An email was sent by fotgotPasswordMailer.") } else { // Preview email in the browser await previewEmail(msg) - log.info("An preview mail was created.") + log.info("An preview mail was created by fotgotPasswordMailer.") } }, } diff --git a/mailers/newMessageMailer.ts b/mailers/newMessageMailer.ts index 92abd1d..a47972a 100644 --- a/mailers/newMessageMailer.ts +++ b/mailers/newMessageMailer.ts @@ -46,11 +46,11 @@ export function newMessageMailer({ to, chatid, from, messageContent }: NewMessag async send() { if (process.env.NODE_ENV === "production") { await smtp.sendMail(msg) - log.info("An email was sent.") + log.info("An email was sent by newMessageMailer.") } else { // Preview email in the browser await previewEmail(msg) - log.info("An preview mail was created.") + log.info("An preview mail was created by newMessageMailer.") } }, } From a1f57863c937b14f5c98ce3f7fd6b3a23e8abeb9 Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Wed, 14 Apr 2021 20:49:18 +0200 Subject: [PATCH 20/24] replace tslog by custom logger --- app/auth/components/LoginForm.tsx | 3 +-- app/auth/components/SignupForm.tsx | 3 +-- app/components/acceptedList.tsx | 3 +-- app/components/changePasswordModal.tsx | 3 +-- app/components/createLists.tsx | 3 +-- app/components/editList.tsx | 4 +--- app/components/ownedList.tsx | 3 +-- app/components/publicList.tsx | 3 +-- app/components/removeListModal.tsx | 4 ++-- app/lib/logger.tsx | 33 ++++++++++++++++++++++++++ app/mutations/acceptList.tsx | 3 +-- app/mutations/addItem.tsx | 3 +-- app/mutations/archiveList.tsx | 3 +-- app/mutations/createAdminMessage.tsx | 3 +-- app/mutations/createChat.tsx | 3 +-- app/mutations/createList.tsx | 3 +-- app/mutations/doneList.tsx | 3 +-- app/mutations/markAdminAsRead.tsx | 3 +-- app/mutations/markMessagesAsRead.tsx | 3 +-- app/mutations/removeAllItems.tsx | 3 +-- app/mutations/removeShoppinglist.tsx | 3 +-- app/mutations/renewList.tsx | 3 +-- app/mutations/sendMessage.tsx | 3 +-- app/mutations/updatePoisition.tsx | 3 +-- app/mutations/updateStoreComment.tsx | 3 +-- app/pages/chats/[chatId].tsx | 4 +--- blitz.config.js | 10 ++++++++ mailers/forgotPasswordMailer.ts | 5 ++-- mailers/newMessageMailer.ts | 4 ++-- package-lock.json | 5 ++++ package.json | 3 ++- 31 files changed, 80 insertions(+), 58 deletions(-) create mode 100644 app/lib/logger.tsx diff --git a/app/auth/components/LoginForm.tsx b/app/auth/components/LoginForm.tsx index 63bed6a..22969b0 100644 --- a/app/auth/components/LoginForm.tsx +++ b/app/auth/components/LoginForm.tsx @@ -5,7 +5,7 @@ import login from "app/auth/mutations/login" import { Login } from "app/auth/validations" import { Flex, Heading, Button, useDisclosure, Box } from "@chakra-ui/react" import ForgotPasswordPage from "app/auth/pages/forgot-password" -import { Logger } from "tslog" +import { appLogger as log } from "app/lib/logger" type LoginFormProps = { onSuccess?: () => Promise | void @@ -14,7 +14,6 @@ type LoginFormProps = { export const LoginForm = (props: LoginFormProps) => { const [loginMutation] = useMutation(login) const { isOpen, onOpen, onClose } = useDisclosure() - const log: Logger = new Logger() return ( diff --git a/app/auth/components/SignupForm.tsx b/app/auth/components/SignupForm.tsx index abe8cc6..98a6d7d 100644 --- a/app/auth/components/SignupForm.tsx +++ b/app/auth/components/SignupForm.tsx @@ -4,7 +4,7 @@ import { Form, FORM_ERROR } from "app/core/components/Form" import signup from "app/auth/mutations/signup" import { Signup } from "app/auth/validations" import { Heading, Flex, Button, useDisclosure, Box } from "@chakra-ui/react" -import { Logger } from "tslog" +import { appLogger as log } from "app/lib/logger" type SignupFormProps = { onSuccess?: () => Promise } @@ -12,7 +12,6 @@ type SignupFormProps = { export const SignupForm = (props: SignupFormProps) => { const [signupMutation] = useMutation(signup) const { isOpen, onOpen, onClose } = useDisclosure() - const log: Logger = new Logger() return ( diff --git a/app/components/createLists.tsx b/app/components/createLists.tsx index 4591f24..116e7fe 100644 --- a/app/components/createLists.tsx +++ b/app/components/createLists.tsx @@ -25,7 +25,7 @@ import { AddIcon, DeleteIcon } from "@chakra-ui/icons" import { useState, useEffect } from "react" import { Form, Field } from "react-final-form" import addItem from "../mutations/addItem" -import { Logger } from "tslog" +import { appLogger as log } from "app/lib/logger" export default function CreateLists() { const [createListMutation] = useMutation(createList) @@ -35,7 +35,6 @@ export default function CreateLists() { const [idList, setIdList] = useState([0]) const { isOpen, onOpen, onClose } = useDisclosure() const toast = createStandaloneToast() - const log: Logger = new Logger() useEffect(() => { try { diff --git a/app/components/editList.tsx b/app/components/editList.tsx index e32cb8a..338eb16 100644 --- a/app/components/editList.tsx +++ b/app/components/editList.tsx @@ -26,7 +26,7 @@ import { Form, Field } from "react-final-form" import addItem from "../mutations/addItem" import updateStoreComment from "../mutations/updateStoreComment" import removeAllItems from "../mutations/removeAllItems" -import { Logger } from "tslog" +import { appLogger as log } from "app/lib/logger" export default function EditLists({ getList }) { const { isOpen, onOpen, onClose } = useDisclosure() @@ -51,8 +51,6 @@ export default function EditLists({ getList }) { } catch {} }, [countItems]) - const log: Logger = new Logger() - return ( <> { const { isOpen, onOpen, onClose } = useDisclosure() const [removeShoppinglistMutation] = useMutation(removeShoppinglist) const toast = createStandaloneToast() - const log: Logger = new Logger() return ( <> { + newLog("db", "info", message, extra) + }, + warn: (message, extra?) => { + newLog("db", "warn", message, extra) + }, + error: (message, extra?) => { + newLog("db", "error", message, extra) + }, + debug: (message, extra?) => { + newLog("db", "debug", message, extra) + }, +} + +export const appLogger = { + info: (message, extra?) => { + newLog("app", "info", message, extra) + }, + warn: (message, extra?) => { + newLog("app", "warn", message, extra) + }, + error: (message, extra?) => { + newLog("app", "error", message, extra) + }, + debug: (message, extra?) => { + newLog("app", "debug", message, extra) + }, +} + +const newLog = (logger, level: string, message, extra = "") => { + console.log(`$${logger.toUpperCase()} $ ${level.toUpperCase()}$ - ${message} ${extra}`) +} diff --git a/app/mutations/acceptList.tsx b/app/mutations/acceptList.tsx index d41a63a..3bab03a 100644 --- a/app/mutations/acceptList.tsx +++ b/app/mutations/acceptList.tsx @@ -1,6 +1,6 @@ import db from "db" import { Ctx } from "blitz" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function acceptList(listId, context: Ctx) { context.session.$authorize() @@ -8,6 +8,5 @@ export default async function acceptList(listId, context: Ctx) { where: { id: listId }, data: { status: 1, acceptedBy: { connect: { id: context.session.userId } } }, }) - const log: Logger = new Logger({ name: "db" }) log.info("List changed status to 'in progress'.") } diff --git a/app/mutations/addItem.tsx b/app/mutations/addItem.tsx index a1b0073..b60aade 100644 --- a/app/mutations/addItem.tsx +++ b/app/mutations/addItem.tsx @@ -1,12 +1,11 @@ import db from "db" import { Ctx } from "blitz" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function addItem({ listId, itemName }, context: Ctx) { context.session.$authorize() await db.item.create({ data: { name: itemName, listedIn: { connect: { id: listId } } }, }) - const log: Logger = new Logger({ name: "db" }) log.info("New item was created.") } diff --git a/app/mutations/archiveList.tsx b/app/mutations/archiveList.tsx index 445bcb1..ea4e2b8 100644 --- a/app/mutations/archiveList.tsx +++ b/app/mutations/archiveList.tsx @@ -1,6 +1,6 @@ import db from "db" import { Ctx } from "blitz" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function archiveList(listId, context: Ctx) { context.session.$authorize() @@ -8,6 +8,5 @@ export default async function archiveList(listId, context: Ctx) { where: { id: listId }, data: { status: 2 }, }) - const log: Logger = new Logger({ name: "db" }) log.info("List changed status to 'archived'.") } diff --git a/app/mutations/createAdminMessage.tsx b/app/mutations/createAdminMessage.tsx index 207178f..c269ef4 100644 --- a/app/mutations/createAdminMessage.tsx +++ b/app/mutations/createAdminMessage.tsx @@ -1,7 +1,7 @@ import db from "db" import { Ctx } from "blitz" import { newMessageMailer } from "mailers/newMessageMailer" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function createAdminMessage({ content, chatId }, context: Ctx) { context.session.$authorize() @@ -10,7 +10,6 @@ export default async function createAdminMessage({ content, chatId }, context: C }) await sentMail(chatId, content) - const log: Logger = new Logger() log.info("AdminMessage was sent") } diff --git a/app/mutations/createChat.tsx b/app/mutations/createChat.tsx index 5bd62e4..972f096 100644 --- a/app/mutations/createChat.tsx +++ b/app/mutations/createChat.tsx @@ -1,6 +1,6 @@ import db from "db" import { Ctx } from "blitz" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function createChat({ opponentId }, context: Ctx) { context.session.$authorize() @@ -11,7 +11,6 @@ export default async function createChat({ opponentId }, context: Ctx) { select: { id: true }, }) - const log: Logger = new Logger({ name: "db" }) log.debug("Created new chat.") return lists } diff --git a/app/mutations/createList.tsx b/app/mutations/createList.tsx index d92278d..f8c7968 100644 --- a/app/mutations/createList.tsx +++ b/app/mutations/createList.tsx @@ -1,6 +1,6 @@ import db from "db" import { Ctx } from "blitz" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function createList({ store, specialWish }, context: Ctx) { context.session.$authorize() @@ -13,7 +13,6 @@ export default async function createList({ store, specialWish }, context: Ctx) { }, select: { id: true }, }) - const log: Logger = new Logger({ name: "db" }) log.debug("Created new shoppinglist.") return lists } diff --git a/app/mutations/doneList.tsx b/app/mutations/doneList.tsx index 3a77766..8d6120d 100644 --- a/app/mutations/doneList.tsx +++ b/app/mutations/doneList.tsx @@ -1,6 +1,6 @@ import db from "db" import { Ctx } from "blitz" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function doneList(listId, context: Ctx) { context.session.$authorize() @@ -8,6 +8,5 @@ export default async function doneList(listId, context: Ctx) { where: { id: listId }, data: { status: 2, acceptedBy: { disconnect: true } }, }) - const log: Logger = new Logger({ name: "db" }) log.debug("List changed status to '2'.") } diff --git a/app/mutations/markAdminAsRead.tsx b/app/mutations/markAdminAsRead.tsx index 40bcf25..0aa5c40 100644 --- a/app/mutations/markAdminAsRead.tsx +++ b/app/mutations/markAdminAsRead.tsx @@ -1,6 +1,6 @@ import db from "db" import { Ctx } from "blitz" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function markAdminMessagesAsRead({ chatId }, context: Ctx) { context.session.$authorize() @@ -15,6 +15,5 @@ export default async function markAdminMessagesAsRead({ chatId }, context: Ctx) }) }) await Promise.all(promisses) - const log: Logger = new Logger({ name: "db" }) log.debug("AdminMessages marked as read.") } diff --git a/app/mutations/markMessagesAsRead.tsx b/app/mutations/markMessagesAsRead.tsx index 5e8b07f..da32293 100644 --- a/app/mutations/markMessagesAsRead.tsx +++ b/app/mutations/markMessagesAsRead.tsx @@ -1,6 +1,6 @@ import db from "db" import { Ctx } from "blitz" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function markMessagesAsRead({ chatId }, context: Ctx) { context.session.$authorize() @@ -8,6 +8,5 @@ export default async function markMessagesAsRead({ chatId }, context: Ctx) { where: { sentInId: chatId, sentToId: context.session.userId }, data: { wasRead: true }, }) - const log: Logger = new Logger({ name: "db" }) log.debug("Messages marked as read.") } diff --git a/app/mutations/removeAllItems.tsx b/app/mutations/removeAllItems.tsx index 86bb4b5..86a00ed 100644 --- a/app/mutations/removeAllItems.tsx +++ b/app/mutations/removeAllItems.tsx @@ -1,12 +1,11 @@ import db from "db" import { Ctx } from "blitz" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function removeAllItems({ id }, context: Ctx) { context.session.$authorize() await db.item.deleteMany({ where: { listId: id }, }) - const log: Logger = new Logger({ name: "db" }) log.debug("Items were removed.") } diff --git a/app/mutations/removeShoppinglist.tsx b/app/mutations/removeShoppinglist.tsx index cf57c02..45c6bd1 100644 --- a/app/mutations/removeShoppinglist.tsx +++ b/app/mutations/removeShoppinglist.tsx @@ -1,6 +1,6 @@ import db from "db" import { Ctx } from "blitz" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function removeShoppinglist({ id }, context: Ctx) { context.session.$authorize() @@ -11,6 +11,5 @@ export default async function removeShoppinglist({ id }, context: Ctx) { await db.shoppinglist.delete({ where: { id: id }, }) - const log: Logger = new Logger({ name: "db" }) log.debug("A shoopinglist was removed.") } diff --git a/app/mutations/renewList.tsx b/app/mutations/renewList.tsx index 1eb42ba..869a1fa 100644 --- a/app/mutations/renewList.tsx +++ b/app/mutations/renewList.tsx @@ -1,6 +1,6 @@ import db from "db" import { Ctx } from "blitz" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function renewList(listId, context: Ctx) { context.session.$authorize() @@ -8,6 +8,5 @@ export default async function renewList(listId, context: Ctx) { where: { id: listId }, data: { status: 0 }, }) - const log: Logger = new Logger({ name: "db" }) log.debug("List changed status to 'in progress'.") } diff --git a/app/mutations/sendMessage.tsx b/app/mutations/sendMessage.tsx index 07de6ec..016faf5 100644 --- a/app/mutations/sendMessage.tsx +++ b/app/mutations/sendMessage.tsx @@ -1,7 +1,7 @@ import db from "db" import { Ctx } from "blitz" import { newMessageMailer } from "mailers/newMessageMailer" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function sendMessage({ content, chatId, partId }, context: Ctx) { context.session.$authorize() @@ -15,7 +15,6 @@ export default async function sendMessage({ content, chatId, partId }, context: }) sentMail(chatId, partId, content, context) - const log: Logger = new Logger({ name: "db" }) log.info("A Message was sent.") } diff --git a/app/mutations/updatePoisition.tsx b/app/mutations/updatePoisition.tsx index 33bae9d..9df828f 100644 --- a/app/mutations/updatePoisition.tsx +++ b/app/mutations/updatePoisition.tsx @@ -1,6 +1,6 @@ import db from "db" import { Ctx } from "blitz" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function updatePosition({ new_longitude, new_latitude }, context: Ctx) { context.session.$authorize() @@ -8,6 +8,5 @@ export default async function updatePosition({ new_longitude, new_latitude }, co where: { id: context.session.userId }, data: { last_latitude: new_latitude, last_longitude: new_longitude }, }) - const log: Logger = new Logger({ name: "db" }) log.info("A Position was updated.") } diff --git a/app/mutations/updateStoreComment.tsx b/app/mutations/updateStoreComment.tsx index 566e21b..8214baf 100644 --- a/app/mutations/updateStoreComment.tsx +++ b/app/mutations/updateStoreComment.tsx @@ -1,6 +1,6 @@ import db from "db" import { Ctx } from "blitz" -import { Logger } from "tslog" +import { dbLogger as log } from "app/lib/logger" export default async function updateStoreComment({ id, store, comment }, context: Ctx) { context.session.$authorize() @@ -8,6 +8,5 @@ export default async function updateStoreComment({ id, store, comment }, context where: { id: id }, data: { store: store, comment: comment }, }) - const log: Logger = new Logger({ name: "db" }) log.info("A store or/and comment of a shoppinglist were updated.") } diff --git a/app/pages/chats/[chatId].tsx b/app/pages/chats/[chatId].tsx index d3fc7cb..a603386 100644 --- a/app/pages/chats/[chatId].tsx +++ b/app/pages/chats/[chatId].tsx @@ -27,7 +27,7 @@ import { RiMailSendLine } from "react-icons/ri" import { BiUserCircle } from "react-icons/bi" import markAdminMessagesAsRead from "app/mutations/markAdminAsRead" import checkIfUnreadMessage from "app/queries/checkIfUnreadMessages" -import { Logger } from "tslog" +import { appLogger as log } from "app/lib/logger" export default function Chat() { const chatId = useParam("chatId", "number") @@ -57,8 +57,6 @@ export default function Chat() { const [hasUnreadMessage] = useQuery(checkIfUnreadMessage, null, { refetchInterval: 2000 }) - const log: Logger = new Logger() - return ( <> diff --git a/blitz.config.js b/blitz.config.js index ce62177..3c11d0f 100644 --- a/blitz.config.js +++ b/blitz.config.js @@ -6,6 +6,16 @@ module.exports = { isAuthorized: simpleRolesIsAuthorized, }), ], + webpack: (config, { isServer }) => { + // Fixes npm packages that depend on `fs` module + if (!isServer) { + config.node = { + fs: "empty", + } + } + + return config + }, /* Uncomment this to customize the webpack config webpack: (config, { buildId, dev, isServer, defaultLoaders, webpack }) => { // Note: we provide webpack above so you should not `require` it diff --git a/mailers/forgotPasswordMailer.ts b/mailers/forgotPasswordMailer.ts index 8820837..b8e6aed 100644 --- a/mailers/forgotPasswordMailer.ts +++ b/mailers/forgotPasswordMailer.ts @@ -6,7 +6,8 @@ */ import previewEmail from "preview-email" import nodemailer from "nodemailer" -import { Logger } from "tslog" +import { appLogger as log } from "app/lib/logger" + type ResetPasswordMailer = { to: string token: string @@ -39,8 +40,6 @@ export function forgotPasswordMailer({ to, token }: ResetPasswordMailer) { `, } - const log: Logger = new Logger({ name: "mailer" }) - return { async send() { if (process.env.NODE_ENV === "production") { diff --git a/mailers/newMessageMailer.ts b/mailers/newMessageMailer.ts index a47972a..52246d3 100644 --- a/mailers/newMessageMailer.ts +++ b/mailers/newMessageMailer.ts @@ -6,7 +6,8 @@ */ import previewEmail from "preview-email" import nodemailer from "nodemailer" -import { Logger } from "tslog" +import { appLogger as log } from "app/lib/logger" + type NewMessageMailerProps = { to: string from: string @@ -40,7 +41,6 @@ export function newMessageMailer({ to, chatid, from, messageContent }: NewMessag

${chatUrl}

`, } - const log: Logger = new Logger({ name: "mailer" }) return { async send() { diff --git a/package-lock.json b/package-lock.json index 402317a..e41b36f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -6934,6 +6934,11 @@ } } }, + "fs": { + "version": "0.0.1-security", + "resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz", + "integrity": "sha1-invTcYa23d84E/I4WLV+yq9eQdQ=" + }, "fs-constants": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/fs-constants/-/fs-constants-1.0.0.tgz", diff --git a/package.json b/package.json index 0a9adcd..95d3533 100644 --- a/package.json +++ b/package.json @@ -41,6 +41,8 @@ "blitz": "0.33.1", "final-form": "4.20.2", "framer-motion": "4.0.3", + "fs": "0.0.1-security", + "fs-extra": "9.1.0", "nodemailer": "6.5.0", "preview-email": "3.0.4", "prisma": "~2.19", @@ -50,7 +52,6 @@ "react-final-form": "6.5.3", "react-icons": "4.2.0", "react-responsive": "8.2.0", - "tslog": "3.1.2", "typescript": "~4.1", "zod": "1.11.13" }, From dce44a3131bef833ad88161d2f8f667b40fbb0c2 Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Thu, 15 Apr 2021 08:40:15 +0200 Subject: [PATCH 21/24] add information to header --- app/components/layout.tsx | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/app/components/layout.tsx b/app/components/layout.tsx index 85d2474..93c39f8 100644 --- a/app/components/layout.tsx +++ b/app/components/layout.tsx @@ -58,6 +58,17 @@ export default function Layout({ <> + + + + + From 8d311e87ffd3f0959976f2dc2f382af79abb052b Mon Sep 17 00:00:00 2001 From: DuckNrOne Date: Thu, 15 Apr 2021 08:40:25 +0200 Subject: [PATCH 22/24] add sitemap for search engines --- public/robots.txt | 9 +++++++++ public/sitemap.xml | 4 ++++ 2 files changed, 13 insertions(+) create mode 100644 public/robots.txt create mode 100644 public/sitemap.xml diff --git a/public/robots.txt b/public/robots.txt new file mode 100644 index 0000000..3339e8d --- /dev/null +++ b/public/robots.txt @@ -0,0 +1,9 @@ +# * +User-agent: * +Allow: / + +# Host +Host: https://entel.me + +# Sitemaps +Sitemap: https://entel.me/sitemap.xml \ No newline at end of file diff --git a/public/sitemap.xml b/public/sitemap.xml new file mode 100644 index 0000000..0b74b16 --- /dev/null +++ b/public/sitemap.xml @@ -0,0 +1,4 @@ + + +https://entel.medaily0.72021-04-15T06:26:10+00:00 + \ No newline at end of file From 5e4d62461f1a8c0fc7eb048711307c6866ebafc7 Mon Sep 17 00:00:00 2001 From: Till-B Date: Thu, 15 Apr 2021 11:35:35 +0200 Subject: [PATCH 23/24] Datenschutz issue --- app/pages/datenschutz.tsx | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/pages/datenschutz.tsx b/app/pages/datenschutz.tsx index 77a6d78..afcbb7e 100644 --- a/app/pages/datenschutz.tsx +++ b/app/pages/datenschutz.tsx @@ -14,17 +14,17 @@ import checkIfUnreadMessage from "app/queries/checkIfUnreadMessages" import { useCurrentUser } from "app/core/hooks/useCurrentUser" function DatenschutzLoggedOut() { - const [hasUnreadMessage] = useQuery(checkIfUnreadMessage, null, { refetchInterval: 5000 }) return ( - + ) } function DatenschutzLoggedIn() { + const [hasUnreadMessage] = useQuery(checkIfUnreadMessage, null, { refetchInterval: 5000 }) return ( - + ) From d934ec57850ac64a4eed386df004b133996cd98f Mon Sep 17 00:00:00 2001 From: Till-B Date: Thu, 15 Apr 2021 11:47:55 +0200 Subject: [PATCH 24/24] Git Link improved --- app/components/layout.tsx | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/app/components/layout.tsx b/app/components/layout.tsx index 85d2474..9a1d7a4 100644 --- a/app/components/layout.tsx +++ b/app/components/layout.tsx @@ -290,14 +290,12 @@ export default function Layout({ textAlign="center" alignItems="center" > - - - - - This project is open source. Feel free reach out. - - - + + + + This project is open source. Feel free reach out. + + Impressum