A minimial activitypub server written for Bun.js
Find a file
Gordon Pedersen fd8c2073f0 pivot away from 11ty and instead store data in sqlite
The idea is going to be to build an 11ty frontend that pulls from this back-end
(or perhaps just the database, we'll see)
Also considering a mastodon-compatible api wrapper, or at the very least creating a separate wrapper and completely dropping the existing admin routes.
... ooh, I could do a micropub wrapper, too...

tl;dr: microservices. This is just the activitypub server now.
2023-10-11 16:25:14 +11:00
.vscode Initial commit 2023-09-16 10:28:06 +10:00
src pivot away from 11ty and instead store data in sqlite 2023-10-11 16:25:14 +11:00
.gitignore pivot away from 11ty and instead store data in sqlite 2023-10-11 16:25:14 +11:00
actor.ts pivot away from 11ty and instead store data in sqlite 2023-10-11 16:25:14 +11:00
bun.lockb pivot away from 11ty and instead store data in sqlite 2023-10-11 16:25:14 +11:00
CNAME Added eleventy templates from death.id.au 2023-09-27 17:06:56 +10:00
package.json pivot away from 11ty and instead store data in sqlite 2023-10-11 16:25:14 +11:00
README.md Added eleventy templates from death.id.au 2023-09-27 17:06:56 +10:00
tsconfig.json Initial commit 2023-09-16 10:28:06 +10:00

bun-activitypub

This is a basic ActivityPub server written in JavaScript, using Bun.
It is very much based on existing work but has been re-written to work with Bun instead of Node/Express. This is as much about a personal learning experience as anything.

In the beginning, this server only supports following/unfollowing (and being followed/unfollowed in return), as well as posting simple notes - which do get sent out to followers.

Rather than store data in a database, it currently stores create activity data in json files, and created posts in markdown files with YAML frontmatter for metadata.
The hope is this will allow me to use something like 11ty to generate my own website for people to view and interact with my posts in the future.
I may also experiment with pushing the content to a seperate git repository so I can utilize automated scripts to build and publish the web front-end.

Dependencies

  • Bun has it's own built-in http server, so this project uses that rather than something like Express.
  • It uses node-forge for signing and verifying signed posts, as Bun does not yet implement the required node:crypto methods
  • It uses gray-matter for writing and parsing YAML frontmatter in Markdown files
  • It uses 11ty to compile those Markdown files into a static website Note: there is an error with 11ty in Bun, tracked here. Until there is a fix, there is a workaround: node_modules/graceful-fs/graceful-fs.js:299 — remove the , this from the end of the line
    • The RSS Plugin for 11ty is also used to generate RSS feeds of the posts

Development

To install dependencies:

bun install

To run:

bun run start

This project was created using bun init in bun v1.0.0. Bun is a fast all-in-one JavaScript runtime.