This commit is contained in:
Deva Midhun 2025-02-08 20:58:52 +00:00
parent cec716472e
commit c57f30d45e
4 changed files with 233 additions and 15 deletions

177
.gitignore vendored Normal file
View File

@ -0,0 +1,177 @@
# Based on https://raw.githubusercontent.com/github/gitignore/main/Node.gitignore
# Logs
logs
_.log
npm-debug.log_
yarn-debug.log*
yarn-error.log*
lerna-debug.log*
.pnpm-debug.log*
# Caches
.cache
# Diagnostic reports (https://nodejs.org/api/report.html)
report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# Runtime data
pids
_.pid
_.seed
*.pid.lock
# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov
# Coverage directory used by tools like istanbul
coverage
*.lcov
# nyc test coverage
.nyc_output
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
.grunt
# Bower dependency directory (https://bower.io/)
bower_components
# node-waf configuration
.lock-wscript
# Compiled binary addons (https://nodejs.org/api/addons.html)
build/Release
# Dependency directories
node_modules/
jspm_packages/
# Snowpack dependency directory (https://snowpack.dev/)
web_modules/
# TypeScript cache
*.tsbuildinfo
# Optional npm cache directory
.npm
# Optional eslint cache
.eslintcache
# Optional stylelint cache
.stylelintcache
# Microbundle cache
.rpt2_cache/
.rts2_cache_cjs/
.rts2_cache_es/
.rts2_cache_umd/
# Optional REPL history
.node_repl_history
# Output of 'npm pack'
*.tgz
# Yarn Integrity file
.yarn-integrity
# dotenv environment variable files
.env
.env.development.local
.env.test.local
.env.production.local
.env.local
# parcel-bundler cache (https://parceljs.org/)
.parcel-cache
# Next.js build output
.next
out
# Nuxt.js build / generate output
.nuxt
dist
# Gatsby files
# Comment in the public line in if your project uses Gatsby and not Next.js
# https://nextjs.org/blog/next-9-1#public-directory-support
# public
# vuepress build output
.vuepress/dist
# vuepress v2.x temp and cache directory
.temp
# Docusaurus cache and generated files
.docusaurus
# Serverless directories
.serverless/
# FuseBox cache
.fusebox/
# DynamoDB Local files
.dynamodb/
# TernJS port file
.tern-port
# Stores VSCode versions used for testing VSCode extensions
.vscode-test
# yarn v2
.yarn/cache
.yarn/unplugged
.yarn/build-state.yml
.yarn/install-state.gz
.pnp.*
# IntelliJ based IDEs
.idea
# Finder (MacOS) folder config
.DS_Store
bun.lockb

View File

@ -14,18 +14,21 @@ if (!admin.apps.length) {
const db = admin.firestore();
export default async function (req: VercelRequest, res: VercelResponse) {
const collection = db.collection('followers');
const actors = await collection.select("actor").get();
try {
const collection = db.collection('followers');
const actors = await collection.select("actor").get();
const output = {
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://usr.cloud/@coder/following?page=1",
"type": "OrderedCollectionPage",
"totalItems": actors.docs.length,
"orderedItems": actors.docs.map(item=>item.get("actor"))
const output = {
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://coderrrrr.site/api/activitypub/followers",
"type": "OrderedCollection",
"totalItems": actors.docs.length,
"orderedItems": actors.docs.map(item => item.get("actor"))
};
res.status(200).setHeader("Content-Type", "application/activity+json").json(output);
} catch (error) {
console.error("Error fetching followers:", error);
res.status(500).json({ error: "Internal Server Error" });
}
res.statusCode = 200;
res.setHeader("Content-Type", `application/activity+json`);
res.json(output);
};

View File

@ -1,7 +1,16 @@
import type { VercelRequest, VercelResponse } from '@vercel/node';
export default function (req: VercelRequest, res: VercelResponse) {
res.statusCode = 200;
res.setHeader("Content-Type", `application/activity+json`);
res.end('ok');
const output = {
"@context": "https://www.w3.org/ns/activitystreams",
"id": "https://coderrrrr.site/api/activitypub/following",
"type": "OrderedCollection",
"totalItems": 2,
"orderedItems": [
"https://mastodon.social/users/coderrrrr",
"https://usr.cloud/users/coder"
]
};
res.status(200).setHeader("Content-Type", "application/activity+json").json(output);
};

29
package.json Normal file
View File

@ -0,0 +1,29 @@
{
"name": "coderrrrr.site",
"type": "module",
"devDependencies": {
"@types/bun": "latest"
},
"peerDependencies": {
"typescript": "^5.7.3"
},
"dependencies": {
"@firebase/app-types": "^0.9.3",
"@types/multiparty": "^4.2.1",
"@types/node": "^22.13.1",
"@types/uuid": "^10.0.0",
"@vercel/analytics": "^1.4.1",
"@vercel/edge": "^1.2.1",
"@vercel/kv": "^3.0.0",
"@vercel/node": "^5.1.2",
"@vercel/og": "^0.6.5",
"activitypub-core-types": "^0.3.2",
"ava": "^6.2.0",
"file-drop-element": "^1.0.1",
"firebase-admin": "^13.1.0",
"multiparty": "^4.2.3",
"node-fetch": "^3.3.2",
"uuid": "^11.0.5",
"vercel": "^41.0.2"
}
}