[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.

use optionalauth middleware directly on the router

+6 -7
+2 -6
services/appview/src/index.ts
··· 4 4 import { HTTPException } from 'hono/http-exception' 5 5 import { logger } from 'hono/logger' 6 6 import { pino } from 'pino' 7 - import { optionalAuthMiddleware } from './auth/middleware.js' 8 7 import { Database } from './db.js' 9 8 import { env } from './env.js' 10 9 import { createFeedRouter } from './feed/feed.js' ··· 68 67 await next() 69 68 }) 70 69 71 - // Apply optional auth to getPosts - enables auth but doesn't require it 72 - app.use('/xrpc/so.sprk.feed.getPosts', optionalAuthMiddleware) 73 - 74 - // Auth routes 70 + // TODO: Remove this after getAuthorFeedRouter is properly implemented on frontend 75 71 const feedRouter = createFeedRouter(ctx) 76 72 app.route('/', feedRouter) 77 73 ··· 93 89 // Root route 94 90 app.get('/', (c) => { 95 91 return c.text( 96 - '✧・゚: ✧・゚:. ݁₊ ⊹ . ݁˖ . ݁ 𝚂𝙿𝙰𝚁𝙺 𝙰𝙿𝙸 . ݁₊ ⊹ . ݁˖ . ݁ :・゚✧:・゚✧', 92 + '✧・゚: ✧・゚:. ݁₊ ⊹ . ݁˖ . ݁ SPARK API . ݁₊ ⊹ . ݁˖ . ݁ :・゚✧:・゚✧', 97 93 ) 98 94 }) 99 95
+4 -1
services/appview/src/routes/feed/getPosts.ts
··· 5 5 import { transformPostToPostView } from '../../utils/post-transformer.js' 6 6 import { Database } from '../../db.js' 7 7 import type * as SoSprkFeedDefs from '../../lexicon/types/so/sprk/feed/defs.js' 8 + import { optionalAuthMiddleware } from '../../auth/middleware.js' 8 9 9 10 // Function to fetch posts by URIs 10 11 async function getPosts( ··· 35 36 export const createGetPostsRouter = (ctx: AppContext) => { 36 37 const router = new Hono() 37 38 38 - router.get('/xrpc/so.sprk.feed.getPosts', async (c) => { 39 + router.get('/xrpc/so.sprk.feed.getPosts', 40 + optionalAuthMiddleware, 41 + async (c) => { 39 42 const uris = c.req.queries('uris') 40 43 const userDid = c.get('did') as string | undefined 41 44