Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/0xadada/vital-cause
Koa.js app to handle IFTTT webhooks and output markdown files to a GitHub repo.
https://github.com/0xadada/vital-cause
github github-api http-server ifttt koa koajs markdown nodejs
Last synced: 15 days ago
JSON representation
Koa.js app to handle IFTTT webhooks and output markdown files to a GitHub repo.
- Host: GitHub
- URL: https://github.com/0xadada/vital-cause
- Owner: 0xadada
- License: mit
- Created: 2019-09-24T02:22:22.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-04T22:13:58.000Z (almost 2 years ago)
- Last Synced: 2024-10-18T08:24:58.303Z (26 days ago)
- Topics: github, github-api, http-server, ifttt, koa, koajs, markdown, nodejs
- Language: JavaScript
- Homepage:
- Size: 394 KB
- Stars: 1
- Watchers: 3
- Forks: 4
- Open Issues: 12
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# vital-cause
[![CircleCI](https://img.shields.io/circleci/project/github/0xadada/vital-cause/master.svg?style=flat-square)](https://circleci.com/gh/0xadada/vital-cause/tree/master)
_Koa.js app to handle IFTTT webhooks and output markdown files to a GitHub repo._
## Get Started
You'll need these tools installed
* [Node.js LTS/10.x](https://nodejs.org/)
* [Yarn](https://yarnpkg.com/)```bash
git clone && cd vital-cause
yarn
```## Environment variables
Set your environment variables, copy them from the `.env.example` file and edit
as necessary:```bash
cp .env.example .env
````AUTH_TOKEN` acts as an API token, all requests must send the `?token=` query
parameter that will be compared against the value set in this variable. It should
be set to a value with a high degree of entropy. I suggest a 32 character random
string:```bash
base64 < /dev/urandom | tr -d 'O0Il1+\/' | head -c 32 # generate a 32-char string
```You will need to create a [GitHub Personal Access
Token](https://github.com/settings/tokens) if you want to write files to your repo.`GITHUB_TOKEN` is a personal access token that will grant access to this app
to create new files in your repo. It *only* needs to be granted the
`repo:public_repo` scope.## Running
This will run the server on port `3000` with the `.env` file settings.
```bash
export $(cat .env | xargs) && node index
```There are 2 endpoints available to make requests. You must send send the `token`
query parameter equal to the value set in the `AUTH_TOKEN` environment variable.* health check: `curl -i http://localhost:3000/health?token=changeme`
* post new file: `curl -i -H 'Content-Type: application/json' http://localhost:3000/post?token=changeme`## Example posts
Create a Youtube post:
For this JSON data:
```JSON
{
"layout": "webmention-like",
"date": "2021-09-22 17:55:32",
"generator": "youtube.com",
"target": "https://www.youtube.com/watch?v=9bZkp7q19f0",
"title": "PSY - GANGNAM STYLE(강남스타일) M/V",
"content": ""
}
```Use curl to make a POST request:
```bash
curl \
-H 'Content-Type: application/json' \
--data '{"layout": "webmention-like", "date": "2021-09-22 17:55:32", "generator": "youtube.com", "target": "https://www.youtube.com/watch?v=9bZkp7q19f0", "title": "PSY - GANGNAM STYLE(강남스타일) M/V", "content": ""}' \
http://localhost:3000/post?token=changeme
```## IFTTT Recipes
On IFTTT, the recipe would look like this:
Make a web hook request:
* URL: `https://.glitch.me/post?token=changeme`
* Method: `POST`
* Content-type: `application/json`
* Body:
```JSON
{
"layout": "webmention-like",
"date": "{{LikedAt}}",
"generator": "youtube.com",
"target": "{{Url}}",
"title": "{{Title}}",
"content": "<<<{{EmbedCode}}>>>"
}
```