/*Canopy - The next generation of stoner streaming software Copyright (C) 2024 Rainbownapkin and the TTN Community This program is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see .*/ //npm imports const { Router } = require('express'); //local imports const permissionSchema = require("../../schemas/permissionSchema"); const {channelValidator} = require("../../validators/channelValidator"); const {channelPermissionValidator} = require("../../validators/permissionsValidator"); const registerController = require("../../controllers/api/channel/registerController"); const listController = require("../../controllers/api/channel/listController"); const settingsController = require("../../controllers/api/channel/settingsController"); const permissionsController = require("../../controllers/api/channel/permissionsController") const rankController = require("../../controllers/api/channel/rankController"); const deleteController = require("../../controllers/api/channel/deleteController"); //globals const router = Router(); //user authentication middleware router.use("/register",permissionSchema.reqPermCheck("registerChannel")); router.use("/delete",permissionSchema.reqPermCheck("deleteChannel")); router.use("/settings",permissionSchema.reqPermCheck("manageChannel")); //routing functions router.post('/register', channelValidator.name(), channelValidator.description(), channelValidator.thumbnail(), registerController.post); router.get('/list', listController.get); router.get('/settings', channelValidator.name('chanName'), settingsController.get); router.post('/settings', channelValidator.name('chanName'), channelValidator.settingsMap(), settingsController.post); router.get('/permissions', channelValidator.name('chanName'), permissionsController.get); router.post('/permissions', channelValidator.name('chanName'), channelPermissionValidator.channelPermissionsMap(), permissionsController.post); router.get('/rank', channelValidator.name('chanName'), rankController.get); router.post('/delete', channelValidator.name('chanName'), channelValidator.name('confirm'),deleteController.post); module.exports = router;