zanechua/comment-worker

Meta

zanechua opened this issue · 3 comments

Why?

Staticman hasn't had an update in >= 3 years at this point and I don't really want to fork and inherit the existing code.

Heroku no longer has a free tier and it is expensive to maintain such a service.

This would be easier deploying to a Cloudflare Worker or Google App Script which are essentially free Lambdas.

I rewrote the existing code to be config file compatible with the staticman.yml at the moment but will likely make breaking changes/modifications in the future.

Changes

  • Support both normal form requests and api requests based on the application/x-www-form-urlencoded and application/json content types
  • Transforms now supports other algorithms such as SHA 1, SHA 256, SHA 384, SHA 512 via WebCrypto and escape
  • allowedOrigins is removed from the staticman.yml and moved to the worker environment variables as CW_ALLOWED_ORIGINS
  • allowedOrigins is now implemented for CORS whitelisting, it was not being implemented at all in staticman (docs were just not updated)
  • Changed to just a simple endpoint instead of having to specify the organiation, repository and branch in the endpoint url
  • pullRequestBody now supports placeholders
  • pullRequestBody handles multi-line strings properly for the table display
  • id is now generated with cuid2
  • Input validation and transformation is handled by zod

State

  • No docs
  • No tests
  • No support for json/frontmatter format
  • No support for github api token auth, only via github apps
  • No support for notifications
  • No anti-spam support, Akismet/Recaptcha
  • No auth support
  • No support for generatedFields
  • No support for OneDev, GitLab
  • All posts will come with the date field now

Would it be possible to use this on ReactJS sites deployed on Netlify or similar? I've got no real experience with lambdas, but this seems like one of the only solutions for static site comments that's free, customisable and still working.

@ladyisak yes it will work as long as you hook it up in your code.

Here's my website which contains the implementation: https://github.com/zanechua/website/blob/master/src/components/CommentForm.jsx

Here's the commit where I switched from staticman to comment-worker :
zanechua/website@8f67de0

Oh amazing, thanks for this @zanechua. I have a blog on GitHub using staticman (v3) with Heroku and after forgetting about it I found that my Heroku account has been deleted (on the free tier just for staticman).

Now I'll try to switch over from staticman to comment-worker and Cloudflare worker as well. The issue is that it has been so long I don't even remember how I got it working on Heroku! I'll try to follow via the setup step and your example above.

Is the Manual Deployment and Development setup steps relevant to what I'm doing here?

Once again, thank you so much!