This repository has no description
0

Configure Feed

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

semble / src / modules / cards / infrastructure / http / routes / collectionRoutes.ts
5.2 kB 117 lines
1import { Router } from 'express'; 2import { CreateCollectionController } from '../controllers/CreateCollectionController'; 3import { UpdateCollectionController } from '../controllers/UpdateCollectionController'; 4import { DeleteCollectionController } from '../controllers/DeleteCollectionController'; 5import { GetCollectionPageController } from '../controllers/GetCollectionPageController'; 6import { GetMyCollectionsController } from '../controllers/GetMyCollectionsController'; 7import { GetUserCollectionsController } from '../controllers/GetUserCollectionsController'; 8import { GetCollectionPageByAtUriController } from '../controllers/GetCollectionPageByAtUriController'; 9import { GetCollectionsForUrlController } from '../controllers/GetCollectionsForUrlController'; 10import { SearchCollectionsController } from '../controllers/SearchCollectionsController'; 11import { GetOpenCollectionsWithContributorController } from '../controllers/GetOpenCollectionsWithContributorController'; 12import { GetCollectionFollowersController } from '../controllers/GetCollectionFollowersController'; 13import { GetCollectionFollowersCountController } from '../controllers/GetCollectionFollowersCountController'; 14import { GetCollectionContributorsController } from '../controllers/GetCollectionContributorsController'; 15import { AuthMiddleware } from 'src/shared/infrastructure/http/middleware'; 16 17export function createCollectionRoutes( 18 authMiddleware: AuthMiddleware, 19 createCollectionController: CreateCollectionController, 20 updateCollectionController: UpdateCollectionController, 21 deleteCollectionController: DeleteCollectionController, 22 getCollectionPageController: GetCollectionPageController, 23 getMyCollectionsController: GetMyCollectionsController, 24 getUserCollectionsController: GetUserCollectionsController, 25 getCollectionPageByAtUriController: GetCollectionPageByAtUriController, 26 getCollectionsForUrlController: GetCollectionsForUrlController, 27 searchCollectionsController: SearchCollectionsController, 28 getOpenCollectionsWithContributorController: GetOpenCollectionsWithContributorController, 29 getCollectionFollowersController: GetCollectionFollowersController, 30 getCollectionFollowersCountController: GetCollectionFollowersCountController, 31 getCollectionContributorsController: GetCollectionContributorsController, 32): Router { 33 const router = Router(); 34 35 // Query routes 36 // GET /api/collections - Get my collections 37 router.get('/', authMiddleware.ensureAuthenticated(), (req, res) => 38 getMyCollectionsController.execute(req, res), 39 ); 40 41 // GET /api/collections/search - Search collections globally 42 router.get('/search', authMiddleware.optionalAuth(), (req, res) => 43 searchCollectionsController.execute(req, res), 44 ); 45 46 // GET /api/collections/url - Get collections for URL 47 router.get('/url', authMiddleware.optionalAuth(), (req, res) => 48 getCollectionsForUrlController.execute(req, res), 49 ); 50 51 // GET /api/collections/user/:identifier - Get user's collections by identifier 52 router.get('/user/:identifier', authMiddleware.optionalAuth(), (req, res) => 53 getUserCollectionsController.execute(req, res), 54 ); 55 56 // GET /api/collections/contributed/:identifier - Get open collections where user contributed 57 router.get( 58 '/contributed/:identifier', 59 authMiddleware.optionalAuth(), 60 (req, res) => getOpenCollectionsWithContributorController.execute(req, res), 61 ); 62 63 // GET /api/collections/at/:handle/:recordKey - Get collection by AT URI 64 router.get( 65 '/at/:handle/:recordKey', 66 authMiddleware.optionalAuth(), 67 (req, res) => getCollectionPageByAtUriController.execute(req, res), 68 ); 69 70 // GET /api/collections/:collectionId/followers - Get collection followers 71 router.get( 72 '/:collectionId/followers', 73 authMiddleware.optionalAuth(), 74 (req, res) => getCollectionFollowersController.execute(req, res), 75 ); 76 77 // GET /api/collections/:collectionId/followers/count - Get collection followers count 78 router.get( 79 '/:collectionId/followers/count', 80 authMiddleware.optionalAuth(), 81 (req, res) => getCollectionFollowersCountController.execute(req, res), 82 ); 83 84 // GET /api/collections/:collectionId/contributors - Get collection contributors 85 router.get( 86 '/:collectionId/contributors', 87 authMiddleware.optionalAuth(), 88 (req, res) => getCollectionContributorsController.execute(req, res), 89 ); 90 91 // GET /api/collections/:collectionId - Get collection page 92 router.get('/:collectionId', authMiddleware.optionalAuth(), (req, res) => 93 getCollectionPageController.execute(req, res), 94 ); 95 96 // Command routes 97 // POST /api/collections - Create a new collection 98 router.post('/', authMiddleware.ensureAuthenticated(), (req, res) => 99 createCollectionController.execute(req, res), 100 ); 101 102 // PUT /api/collections/:collectionId - Update collection details 103 router.put( 104 '/:collectionId', 105 authMiddleware.ensureAuthenticated(), 106 (req, res) => updateCollectionController.execute(req, res), 107 ); 108 109 // DELETE /api/collections/:collectionId - Delete a collection 110 router.delete( 111 '/:collectionId', 112 authMiddleware.ensureAuthenticated(), 113 (req, res) => deleteCollectionController.execute(req, res), 114 ); 115 116 return router; 117}