From c57f30d45e6734b02bcbf814edfcdb00197e2aac Mon Sep 17 00:00:00 2001 From: Deva Midhun Date: Sat, 8 Feb 2025 20:58:52 +0000 Subject: [PATCH] update --- .gitignore | 177 +++++++++++++++++++++++++++++++++++ api/activitypub/followers.ts | 27 +++--- api/activitypub/following.ts | 15 ++- package.json | 29 ++++++ 4 files changed, 233 insertions(+), 15 deletions(-) create mode 100644 .gitignore create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fd0ad52 --- /dev/null +++ b/.gitignore @@ -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 diff --git a/api/activitypub/followers.ts b/api/activitypub/followers.ts index ae81f08..195d395 100644 --- a/api/activitypub/followers.ts +++ b/api/activitypub/followers.ts @@ -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); }; diff --git a/api/activitypub/following.ts b/api/activitypub/following.ts index 3a69ebd..6411324 100644 --- a/api/activitypub/following.ts +++ b/api/activitypub/following.ts @@ -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); }; diff --git a/package.json b/package.json new file mode 100644 index 0000000..829a386 --- /dev/null +++ b/package.json @@ -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" + } +}