News for hackers. Stuff that matters.
Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by sntran on Monday September 28, 2020 @11:25AM (#24617635)
I may be missing something here, but... all that for a hit counter? Even using React for the front-end seems overkill for a little widget.
Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by prezjordan on Monday September 28, 2020 @11:39AM (#24617796)
The hit counter is merely an example! I see this blog post as an intro to how-to-connect React up to a hosted database over this fancy serverless paradigm thingy.
Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by Royalaid on Monday September 28, 2020 @01:20PM (#24619000)
And more importantly this is what a lot of people are doing in industry, for better or worse, and so seeing this all laid out together is important IMO.
Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by vsdvvsderer on Monday September 28, 2020 @11:29AM (#24617675)
these days the hard part isn't the view counter logic, it's managing the 395,000 dependencies in your project
Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by dclowd9901 on Monday September 28, 2020 @11:57AM (#24618025)
I used to be “dependency-first” for library code, but I’ve noticed lately that my first question has been “why wouldn’t it be a good idea to build in house?”
Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by notJim on Monday September 28, 2020 @12:01PM (#24618080)
Hard same. After having a few experiences where a dependency hardly does anything, my approach is to read the docs first and see if I can implement the parts I need in a couple of hours. Often I can.
Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by joshmanders on Monday September 28, 2020 @02:30PM (#24619819)
Two reasons not to build in house:

1. Edge cases. You cannot possibly cover every possible edge case. This is why back in the day we had "Site works best on IE". Libraries are often used by a lot of people thus edge cases you couldn't possibly think about are covered.

2. Someone else maintains it. If your job is to build an application, why are you spending all your time maintaining a library that just facilitates your application? If I'm building a racecar, I'm not gonna make the wheels in house, let people who are better at that do that while I focus on what I do best.

Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by vsdvvsderer on Tuesday September 29, 2020 @12:31PM (#24629871)
One reason to not not build-in house:

1. Edge cases. Chances are you do not need to cover every edge case, at least when building an MVP. It can take more time to learn a complex API than to build in house. See also premature optimization.

2. Someone else maintains it. In the event you decide to use someone's dependency and they decide to unpublish it with the click of a button.... (ok at least this one has been fixed, but API versioning can still be a bear).

Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by joshwcomeau on Monday September 28, 2020 @12:35PM (#24618457)
To be clear I am not advocating switching to React in order to add a hit counter. The article is meant for folks who already have a Gatsby/Next site.
Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by tyingq on Monday September 28, 2020 @11:28AM (#24617665)
I don't see any locking either, so I imagine it misses some counts.
Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by tyingq on Monday September 28, 2020 @01:34PM (#24619185)
The right way to do it with FaunaDB: https://news.ycombinator.com/item?id=24618998
Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by reaperducer on Monday September 28, 2020 @12:34PM (#24618451)
I may be missing something here, but... all that for a hit counter?

Up next, the Angular-powered guestbook in just 10k lines of code.

Then stay tuned for the Go-powered e-card sender in just 50k lines of code.

And then, the Typescript web ring... the cloud... using BespokeDB... and service workers... in WebASM!

Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by gibs0ns on Monday September 28, 2020 @11:34AM (#24617728)
It reads to me more like a sponsored blog post by the db saas mentioned in the article.
Re:Build a hit counter for Gatsby with React, AWS Lambda, an... by thrownaway954 on Monday September 28, 2020 @11:29AM (#24617680)
i totally agree. plus the fact that he's using a DAS for storing the data. if there is one thing i refuse to do is not be in charge of my database or using something proprietary.