my monorepo for atproto based applications
at main 38 lines 1.1 kB view raw
1import { InvalidRequestError } from "@atproto/xrpc-server"; 2import { Server } from "@my/lexicon/server"; 3import { AppContext } from "@/config"; 4import algos from "@/algos"; 5import { validateAuth } from "@/auth"; 6import { AtUri } from "@atproto/syntax"; 7 8export default function (server: Server, ctx: AppContext) { 9 server.app.bsky.feed.getFeedSkeleton(async ({ params, req }) => { 10 const feedUri = new AtUri(params.feed); 11 const algo = algos[feedUri.rkey]; 12 if ( 13 feedUri.hostname !== ctx.cfg.publisherDid || 14 feedUri.collection !== "app.bsky.feed.generator" || 15 !algo 16 ) { 17 throw new InvalidRequestError( 18 "Unsupported algorithm", 19 "UnsupportedAlgorithm", 20 ); 21 } 22 /** 23 * Example of how to check auth if giving user-specific results: 24 * 25 * const requesterDid = await validateAuth( 26 * req, 27 * ctx.cfg.serviceDid, 28 * ctx.didResolver, 29 * ) 30 */ 31 32 const body = await algo(ctx, params); 33 return { 34 encoding: "application/json", 35 body: body, 36 }; 37 }); 38}