A simple Express API written in TypeScript for guest comments on my static site @ rusingh.com.
Comments should be a part of my static site repository and handled at the static site level. This is most performant and keeps data in one place. There is no API endpoint to fetch comments as the app does not store any data by itself, for example, in a database.
All operations (well, just the three) interact with my GitHub repository. Currently only GitHub is supported but I may be open to adding support for Gitea or Codeberg should I switch to such options in the future.
The following environment variables are necessary:
NODE_ENV
(optional) - defaults toproduction
SENDGRID_API_KEY
- SendGrid API key used for sending notification emailsGITHUB_PAT
- GitHub personal access token
Accepts URL encoded requests. Redirects to ${origin}/thank-you/
or ${origin}/error
. If the origin is not available, it simply responds with a 200/500 HTTP response.
-
name
-
email
-
site
-
comment
-
age
(honeypot) -
fallback-referer
: Some browsers do not add referer headers to form submission requests. We rely on this as a fallback. Requires JavaScript client-side.const target = document.querySelector( "form > input[name='fallback-referer']" ); if (target) target.setAttribute("value", window.location.href);
Accepts URL encoded requests. Responds with a plain-text message upon success.
comment_id
action
:approve
ordelete
You may also be interested in checking open-jamstack-comments, which runs serverless.