import express from 'express'; import { isAuthenticated } from '../../keycloak.js'; const router = express.Router(); import { listGCodeFilesRouteHandler, listGCodeFilesByPropertiesRouteHandler, getGCodeFileRouteHandler, editGCodeFileRouteHandler, newGCodeFileRouteHandler, parseGCodeFileHandler, uploadGCodeFileContentRouteHandler, getGCodeFileContentRouteHandler, deleteGCodeFileRouteHandler, } from '../../services/production/gcodefiles.js'; import { convertPropertiesString, getFilter } from '../../utils.js'; // list of vendors router.get('/', isAuthenticated, (req, res) => { const { page, limit, property, search, sort, order } = req.query; const allowedFilters = ['_id', 'filament']; const filter = getFilter(req.query, allowedFilters); listGCodeFilesRouteHandler(req, res, page, limit, property, filter, search, sort, order); }); router.get('/properties', isAuthenticated, (req, res) => { let properties = convertPropertiesString(req.query.properties); const allowedFilters = ['filament']; const filter = getFilter(req.query, allowedFilters, false); listGCodeFilesByPropertiesRouteHandler(req, res, properties, filter); }); router.post('/', isAuthenticated, (req, res) => { newGCodeFileRouteHandler(req, res); }); router.get('/:id', isAuthenticated, (req, res) => { getGCodeFileRouteHandler(req, res); }); router.put('/:id', isAuthenticated, async (req, res) => { editGCodeFileRouteHandler(req, res); }); router.delete('/:id', isAuthenticated, async (req, res) => { deleteGCodeFileRouteHandler(req, res); }); router.post('/:id/content', isAuthenticated, (req, res) => { uploadGCodeFileContentRouteHandler(req, res); }); router.post('/content', isAuthenticated, (req, res) => { parseGCodeFileHandler(req, res); }); router.get('/:id/content', isAuthenticated, (req, res) => { getGCodeFileContentRouteHandler(req, res); }); export default router;