A community based topic aggregation platform built on atproto
1package routes
2
3import (
4 "Coves/internal/api/handlers/community"
5 "Coves/internal/api/middleware"
6 "Coves/internal/core/communities"
7
8 "github.com/go-chi/chi/v5"
9)
10
11// RegisterCommunityRoutes registers community-related XRPC endpoints on the router
12// Implements social.coves.community.* lexicon endpoints
13func RegisterCommunityRoutes(r chi.Router, service communities.Service, authMiddleware *middleware.AtProtoAuthMiddleware) {
14 // Initialize handlers
15 createHandler := community.NewCreateHandler(service)
16 getHandler := community.NewGetHandler(service)
17 updateHandler := community.NewUpdateHandler(service)
18 listHandler := community.NewListHandler(service)
19 searchHandler := community.NewSearchHandler(service)
20 subscribeHandler := community.NewSubscribeHandler(service)
21
22 // Query endpoints (GET) - public access
23 // social.coves.community.get - get a single community by identifier
24 r.Get("/xrpc/social.coves.community.get", getHandler.HandleGet)
25
26 // social.coves.community.list - list communities with filters
27 r.Get("/xrpc/social.coves.community.list", listHandler.HandleList)
28
29 // social.coves.community.search - search communities
30 r.Get("/xrpc/social.coves.community.search", searchHandler.HandleSearch)
31
32 // Procedure endpoints (POST) - require authentication
33 // social.coves.community.create - create a new community
34 r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.create", createHandler.HandleCreate)
35
36 // social.coves.community.update - update an existing community
37 r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.update", updateHandler.HandleUpdate)
38
39 // social.coves.community.subscribe - subscribe to a community
40 r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.subscribe", subscribeHandler.HandleSubscribe)
41
42 // social.coves.community.unsubscribe - unsubscribe from a community
43 r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.unsubscribe", subscribeHandler.HandleUnsubscribe)
44
45 // TODO: Add delete handler when implemented
46 // r.With(authMiddleware.RequireAuth).Post("/xrpc/social.coves.community.delete", deleteHandler.HandleDelete)
47}