46 lines
1.7 KiB
JavaScript
46 lines
1.7 KiB
JavaScript
const express = require('express');
|
|
const collectionRouter = express.Router();
|
|
|
|
const collectionController = require('../controllers/collectionController');
|
|
const { collectionPicturesUpload } = require('../services/mutlerStorageLocations');
|
|
|
|
// ! /collections
|
|
// * GET - ALL COLLECTIONS
|
|
collectionRouter.get('/', collectionController.getCollections);
|
|
|
|
// * GET - COLLECTION BY ID
|
|
collectionRouter.get('/:id', collectionController.getCollectionById);
|
|
|
|
// * POST - CREATE COLLECTION
|
|
collectionRouter.post('/', collectionController.createCollection);
|
|
|
|
// * PUT - UPDATE COLLECTION
|
|
const upload = collectionPicturesUpload.fields([
|
|
{ name: 'poster', maxCount: 1 },
|
|
{ name: 'backdrop', maxCount: 1 }
|
|
]);
|
|
collectionRouter.put('/:id', upload, collectionController.updateCollection);
|
|
|
|
// * PUT - REFRESH COLLECTION
|
|
collectionRouter.put('/:id/refresh', collectionController.refrechCollection);
|
|
|
|
// * PUT - GET COLLECTION PARTS
|
|
collectionRouter.put('/:id/parts', collectionController.getCollectionParts);
|
|
|
|
// * DELETE - DELETE COLLECTION
|
|
collectionRouter.delete('/:id', collectionController.deleteCollection);
|
|
|
|
// * POST - ADD ENTRY TO A COLLECTION
|
|
collectionRouter.post('/:collectionId/entries/:entryId', collectionController.addEntryToCollection);
|
|
|
|
// * PATCH - UPDATE ENTRY ORDER IN COLLECTION
|
|
collectionRouter.patch('/:collectionId/entries/:entryId', collectionController.updateCollectionEntryOrder);
|
|
|
|
// * DELETE - REMOVE AN ENTRY FROM A COLLECTION
|
|
collectionRouter.delete('/:collectionId/entries/:entryId', collectionController.removeEntryFromCollection);
|
|
|
|
// * POST - CREATE COLLECTION WITH ENTRY
|
|
collectionRouter.post('/collection-with-entry', collectionController.createCollectionWithEntry);
|
|
|
|
module.exports = collectionRouter;
|