[READ ONLY MIRROR] Spark Social AppView Server github.com/sprksocial/server
atproto deno hono lexicon
5
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix local stuff

+68 -35
-1
.gitignore
··· 10 10 *.log 11 11 *.tsbuildinfo 12 12 .*.env 13 - .env.* 14 13 .env 15 14 \#*\# 16 15 *~
+16
services/appview/.env.example
··· 1 + # Generated by `openssl ecparam --name secp256k1 --genkey --noout --outform DER | tail --bytes=+8 | head --bytes=32 | xxd --plain --cols 32` 2 + APPVIEW_K256_PRIVATE_KEY_HEX= 3 + 4 + # Database 5 + DB_HOST=localhost 6 + DB_PORT=27017 7 + DB_NAME=dev 8 + DB_USER=mongo 9 + DB_PASSWORD=mongo 10 + 11 + # Server 12 + HOST=0.0.0.0 13 + NODE_ENV=development 14 + PORT=3000 15 + PUBLIC_URL=http://localhost:3000 16 + SERVICE_DID=did:web:localhost
+37
services/appview/README.md
··· 1 1 # Appview 2 + 3 + ## Running 4 + 5 + To run for development, first install dependencies. 6 + `pnpm install` 7 + 8 + To run in Docker, first build the image: 9 + `docker build -t appview .` 10 + 11 + Then run the container: 12 + `pnpm docker-dev` 13 + 14 + For development without Docker, copy the .env.example file into a .env file and follow the instructions to generate a key, then start the development server: 15 + `pnpm dev` 16 + 17 + This will start the server in development mode with hot reloading enabled. 18 + 19 + ## Environment Variables 20 + 21 + The following environment variables are required: 22 + 23 + - `PORT` - Port to run the server on (default: 3000) 24 + - `DATABASE_URL` - MongoDB connection string 25 + - `DID_RESOLVER_URL` - URL of the DID resolver service 26 + - `CDN_URL` - URL of the CDN service for serving media 27 + 28 + ## API Routes 29 + 30 + The service exposes the following API routes: 31 + 32 + ### Actor Routes 33 + - `GET /xrpc/so.sprk.actor.getProfile` - Get profile details for an actor 34 + - `GET /xrpc/so.sprk.actor.searchActors` - Search for actors 35 + 36 + ### Feed Routes 37 + - `GET /xrpc/so.sprk.feed.getPosts` - Get post objects from URIs 38 + - `GET /xrpc/so.sprk.feed.getAuthorFeed` - Get a post and all replies to it
+1 -1
services/appview/compose.dev.yaml
··· 28 28 DB_PORT: 27017 29 29 DB_USER: mongo 30 30 DB_PASSWORD: mongo 31 - DB_NAME: appviewdev 31 + DB_NAME: dev 32 32 COOKIE_SECRET: "00000000000000000000000000000000" 33 33 ports: 34 34 - "4000:3000"
+7 -33
services/appview/src/routes/actor/getProfile.ts
··· 49 49 profile.authorDid, 50 50 ) 51 51 52 - // Get Spark follower count 53 - const sparkFollowersCount = await ctx.db.models.Follow.countDocuments({ 52 + // Get follower count 53 + const followersCount = await ctx.db.models.Follow.countDocuments({ 54 54 subject: actorDid, 55 55 }) 56 56 57 - // Get Spark follows count 58 - const sparkFollowsCount = await ctx.db.models.Follow.countDocuments({ 57 + // Get follows count 58 + const followsCount = await ctx.db.models.Follow.countDocuments({ 59 59 authorDid: actorDid, 60 60 }) 61 61 62 - // Get Spark posts count 63 - const sparkPostsCount = await ctx.db.models.Post.countDocuments({ 62 + // Get posts count 63 + const postsCount = await ctx.db.models.Post.countDocuments({ 64 64 authorDid: actorDid, 65 65 }) 66 - 67 - // Get Bluesky profile and stats 68 - let blueskyFollowersCount = 0 69 - let blueskyFollowsCount = 0 70 - let blueskyPostsCount = 0 71 - 72 - try { 73 - // Get the Bluesky profile using the DID 74 - const didDoc = await ctx.didResolver.resolveAtprotoData(actorDid) 75 - if (didDoc?.pds) { 76 - const response = await fetch(`${didDoc.pds}/xrpc/app.bsky.actor.getProfile?actor=${actorDid}`) 77 - if (response.ok) { 78 - const data = await response.json() 79 - blueskyFollowersCount = data.followersCount || 0 80 - blueskyFollowsCount = data.followsCount || 0 81 - blueskyPostsCount = data.postsCount || 0 82 - } 83 - } 84 - } catch (err) { 85 - // Ignore errors from Bluesky fetch, we'll just use Spark stats 86 - } 87 - 88 - // Combine stats, ensuring we don't count duplicates 89 - const followersCount = Math.max(sparkFollowersCount, blueskyFollowersCount) 90 - const followsCount = Math.max(sparkFollowsCount, blueskyFollowsCount) 91 - const postsCount = Math.max(sparkPostsCount, blueskyPostsCount) 92 66 93 67 // Build viewer state if a user is authenticated 94 68 const viewer: SoSprkActorDefs.ViewerState = {} ··· 256 230 ) 257 231 258 232 return router 259 - } 233 + }
+7
services/ingester/.env.example
··· 1 + NODE_ENV=development 2 + JETSTREAM_URL=wss://jetstream2.us-east.bsky.network/subscribe 3 + DB_NAME=dev 4 + DB_HOST=localhost 5 + DB_PORT=27017 6 + DB_USER=mongo 7 + DB_PASSWORD=mongo