|
4 months ago | |
---|---|---|
bin | 5 months ago | |
src | 4 months ago | |
.editorconfig | 5 months ago | |
.env.example | 5 months ago | |
.gitignore | 5 months ago | |
.prettierrc | 5 months ago | |
LICENSE | 5 months ago | |
README.md | 4 months ago | |
docker-compose.yml.example | 5 months ago | |
gulpfile.esm.js | 5 months ago | |
package-lock.json | 4 months ago | |
package.json | 4 months ago | |
tsconfig.js | 5 months ago |
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 to production
SENDGRID_API_KEY
- SendGrid API key used for sending notification emailsGITHUB_PAT
- GitHub personal access token/api/v1/comment/new
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);
/api/v1/comment/moderate
Accepts URL encoded requests. Responds with a plain-text message upon success.
comment_id
action
: approve
or delete
You may also be interested in checking open-jamstack-comments, which runs serverless.