forked from shadowfacts/shadowfacts.net
27 lines
622 B
TypeScript
27 lines
622 B
TypeScript
|
import express, { Router } from "express";
|
||
|
import { Database } from "sqlite3";
|
||
|
|
||
|
const domain = process.env.DOMAIN;
|
||
|
|
||
|
export default function followers(): Router {
|
||
|
const 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();
|
||
|
});
|
||
|
});
|
||
|
|
||
|
return router;
|
||
|
}
|