shadowfacts.net/lib/activitypub/followers.ts

23 lines
584 B
TypeScript

import express, { Router } from "express";
import { Database } from "sqlite3";
const domain = process.env.DOMAIN;
export default function followers(router: Router) {
router.get("/ap/actor/followers", (req, res) => {
const db = <Database>req.app.get("db");
db.all("SELECT id FROM followers", (err, rows) => {
res.json({
"@context": [
"https://www.w3.org/ns/activitystreams"
],
"type": "OrderedCollection",
"id": `https://${domain}/ap/actor/followers`,
"totalItems": rows.length,
"items": rows.map(row => row.id)
});
res.end();
});
});
}