A community based topic aggregation platform built on atproto
at main 32 lines 1.4 kB view raw
1package routes 2 3import ( 4 "Coves/internal/api/handlers/post" 5 "Coves/internal/api/middleware" 6 "Coves/internal/core/posts" 7 8 "github.com/go-chi/chi/v5" 9) 10 11// RegisterPostRoutes registers post-related XRPC endpoints on the router 12// Implements social.coves.community.post.* lexicon endpoints 13// authMiddleware can be either OAuthAuthMiddleware or DualAuthMiddleware 14func RegisterPostRoutes(r chi.Router, service posts.Service, authMiddleware middleware.AuthMiddleware) { 15 // Initialize handlers 16 createHandler := post.NewCreateHandler(service) 17 deleteHandler := post.NewDeleteHandler(service) 18 19 // Procedure endpoints (POST) - require authentication 20 // social.coves.community.post.create - create a new post in a community 21 // Supports both OAuth (users) and service JWT (aggregators) authentication 22 r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.post.create", createHandler.HandleCreate) 23 24 // social.coves.community.post.delete - delete a post from a community 25 // Only post authors can delete their own posts 26 r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.post.delete", deleteHandler.HandleDelete) 27 28 // Future endpoints (Beta): 29 // r.Get("/xrpc/social.coves.community.post.get", getHandler.HandleGet) 30 // r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.post.update", updateHandler.HandleUpdate) 31 // r.Get("/xrpc/social.coves.community.post.list", listHandler.HandleList) 32}