mirror of
https://github.com/turbomaster95/coderrrrr.git
synced 2025-05-12 04:50:13 +00:00
ssss
This commit is contained in:
parent
1b51bafee1
commit
85dd0b35f1
@ -1,12 +1,13 @@
|
|||||||
import type { VercelRequest, VercelResponse } from '@vercel/node';
|
import type { VercelRequest, VercelResponse } from "@vercel/node";
|
||||||
import admin from 'firebase-admin';
|
import admin from "firebase-admin";
|
||||||
|
|
||||||
|
// Initialize Firebase Admin if not already initialized.
|
||||||
if (!admin.apps.length) {
|
if (!admin.apps.length) {
|
||||||
admin.initializeApp({
|
admin.initializeApp({
|
||||||
credential: admin.credential.cert({
|
credential: admin.credential.cert({
|
||||||
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
projectId: process.env.NEXT_PUBLIC_FIREBASE_PROJECT_ID,
|
||||||
clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
|
clientEmail: process.env.FIREBASE_CLIENT_EMAIL,
|
||||||
privateKey: process.env.FIREBASE_PRIVATE_KEY?.replace(/\\n/g, '\n')
|
privateKey: process.env.FIREBASE_PRIVATE_KEY?.replace(/\\n/g, "\n")
|
||||||
})
|
})
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -15,18 +16,25 @@ const db = admin.firestore();
|
|||||||
|
|
||||||
export default async function (req: VercelRequest, res: VercelResponse) {
|
export default async function (req: VercelRequest, res: VercelResponse) {
|
||||||
try {
|
try {
|
||||||
const collection = db.collection('followers');
|
const collection = db.collection("followers");
|
||||||
const actors = await collection.select("actor").get();
|
const snapshot = await collection.select("actor").get();
|
||||||
|
|
||||||
|
// Map each document's "actor" field and filter out any null values.
|
||||||
|
const actors = snapshot.docs
|
||||||
|
.map(doc => doc.get("actor"))
|
||||||
|
.filter(actor => actor != null);
|
||||||
|
|
||||||
const output = {
|
const output = {
|
||||||
"@context": "https://www.w3.org/ns/activitystreams",
|
"@context": "https://www.w3.org/ns/activitystreams",
|
||||||
"id": "https://coderrrrr.site/api/activitypub/followers",
|
"id": "https://coderrrrr.site/api/activitypub/followers",
|
||||||
"type": "OrderedCollection",
|
"type": "OrderedCollection",
|
||||||
"totalItems": actors.docs.length,
|
"totalItems": actors.length,
|
||||||
"orderedItems": actors.docs.map(item => item.get("actor"))
|
"orderedItems": actors
|
||||||
};
|
};
|
||||||
|
|
||||||
res.status(200).setHeader("Content-Type", "application/activity+json").json(output);
|
res.status(200)
|
||||||
|
.setHeader("Content-Type", "application/activity+json")
|
||||||
|
.json(output);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error("Error fetching followers:", error);
|
console.error("Error fetching followers:", error);
|
||||||
res.status(500).json({ error: "Internal Server Error" });
|
res.status(500).json({ error: "Internal Server Error" });
|
||||||
|
@ -24,5 +24,8 @@
|
|||||||
"node-fetch": "^3.3.2",
|
"node-fetch": "^3.3.2",
|
||||||
"uuid": "^11.0.5",
|
"uuid": "^11.0.5",
|
||||||
"vercel": "^41.0.2"
|
"vercel": "^41.0.2"
|
||||||
}
|
},
|
||||||
|
"trustedDependencies": [
|
||||||
|
"protobufjs"
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user