TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Build a hit counter for Gatsby with React, AWS Lambda, and FaunaDB

45 点作者 joshwcomeau超过 4 年前

12 条评论

sntran超过 4 年前
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.
评论 #24617796 未加载
评论 #24617675 未加载
评论 #24618457 未加载
评论 #24617665 未加载
评论 #24618451 未加载
评论 #24617728 未加载
评论 #24617680 未加载
joshwcomeau超过 4 年前
Hey folks! Author here. Just a quick clarification, this is NOT a sponsored post by Fauna, as some have claimed. As the article states, the choice for database is somewhat arbitrary, you can swap it out for Mongo or whatever else you’d like and not much code would need to change.
评论 #24621329 未加载
duxup超过 4 年前
I suspect this is intended to be just an example tutorial that isn&#x27;t intended to be &quot;this is how a hit counter SHOULD BE&quot;.<p>Queue the OMG modern web complaints that are correct that this is a lot for a hit counter, but this also I don&#x27;t think that&#x27;s the point here.<p>If someone were to take this article and think &quot;oh this is how to build a web counter&quot; that&#x27;s not OMG modern web, that&#x27;s a different problem.
grawprog超过 4 年前
I can&#x27;t help but feel like this article is a good summary of what&#x27;s wrong with the modern internet. It&#x27;s not a bad article, it just feels like a parody.<p>&#x27;Ok guys, now here&#x27;s the modern way to make one of the more simple things from yesteryear.<p>First, lets bust out react....<p>A few hundred loc later...<p>Ok guys the database...<p>Sign up for account<p>Several more hundred loc later...<p>&#x27;Now to actually write our functions&#x27;<p>Download some dependencies Several hundred loc later...<p>And...here&#x27;s your hit counter guys...<p>This whole article just captures perfectly the essence of all the things we complain about with the modern web.<p>Overengineered, convoluted solutions to simple problems.<p>Honestly, it would be nice sometimes if modern solutions remembered sometimes, it&#x27;s ok to just keep it simple.<p>I did have a quick look around to see if i could find a simple, &#x27;modern&#x27; hit counter.<p><a href="https:&#x2F;&#x2F;www.codementor.io&#x2F;@jamesezechukwu&#x2F;how-to-create-a-simple-counter-using-javascript-html-css-bxcjgbbxa" rel="nofollow">https:&#x2F;&#x2F;www.codementor.io&#x2F;@jamesezechukwu&#x2F;how-to-create-a-si...</a><p>Personally, I prefer the simplicity of this to the article myself.
评论 #24618436 未加载
评论 #24618580 未加载
评论 #24618120 未加载
评论 #24618128 未加载
评论 #24619963 未加载
评论 #24618881 未加载
Whitespace超过 4 年前
I don&#x27;t think this is at all in the spirit of hit counters of the past; IIRC they were an img tag that would be dynamically rendered serverside. Static markup » dynamic content.<p>Perhaps a more apples-to-apples comparison would be an img tag that returns an SVG, allowing CSS styling. You can still choose serverless backend, or you can use the tried-and-true apache&#x2F;nginx with memcache, just like the 90s.
评论 #24618300 未加载
klysm超过 4 年前
Taking a step back, it’s truly insane that it is standard practice to apply this level of complexity to the storage, incrementing, and rendering of a <i></i>single integer<i></i>. The number of dependencies involved is surely enormous. Perhaps I am underestimating the complexity of the task at hand, but how is this not like a 2 line flask app or something comparable.
评论 #24618953 未加载
schemescape超过 4 年前
&gt; q.Update(document.ref, { data: { hits: document.data.hits + 1, ...<p>Does FaunaDB have an &quot;atomic increment&quot; a la Firestore? Knowing nothing about FaunaDB, I suspect this code in the blog post has the potential to &quot;lose&quot; hits that come in at roughly the same time...
评论 #24618322 未加载
ticmasta超过 4 年前
Pretty funny that the push towards static serverless has made something you used to get essentially for free on your dynamic client-server app into quite a complex undertaking.<p>Static compile-time sites are fantastic for a huge swath of applications, but this is a good reminder that you can shift the work around and even come up with better isolated, decoupled approaches but somewhere it still has to get done. Introducing functionality that is dynamic outside the browser and requires state (i.e. persistence) is definitely an area that seems to &quot;fight&quot; the natural inclinations of frameworks like Gatsby et al.
MartinMond超过 4 年前
Now compare this with Elixir + a good old database: <a href="https:&#x2F;&#x2F;dashbit.co&#x2F;blog&#x2F;homemade-analytics-with-ecto-and-elixir" rel="nofollow">https:&#x2F;&#x2F;dashbit.co&#x2F;blog&#x2F;homemade-analytics-with-ecto-and-eli...</a>
chopraaa超过 4 年前
I&#x27;d just like to say that this is one of the most beautiful websites I&#x27;ve ever seen!
butz超过 4 年前
Wouldn&#x27;t it be easier to access Google Analytics using API and pull data from there?
nurgasemetey超过 4 年前
Paid article of Fauna.