From 9b932589896b91ab6fd7ede1fe6c41e11812abe6 Mon Sep 17 00:00:00 2001 From: Flatlogic Bot Date: Wed, 14 Jan 2026 16:48:52 +0000 Subject: [PATCH] event fix --- backend/src/index.js | 4 ++++ backend/src/routes/events.js | 15 +-------------- backend/src/routes/public.js | 13 +++++++++++++ frontend/src/pages/index.tsx | 2 +- 4 files changed, 19 insertions(+), 15 deletions(-) create mode 100644 backend/src/routes/public.js diff --git a/backend/src/index.js b/backend/src/index.js index a34f1bb..dafb012 100644 --- a/backend/src/index.js +++ b/backend/src/index.js @@ -88,8 +88,12 @@ app.use('/api-docs', function (req, res, next) { app.use(cors({origin: true})); require('./auth/auth'); + +const publicRoutes = require('./routes/public'); + app.use(bodyParser.json()); +app.use('/api', publicRoutes); app.use('/api/auth', authRoutes); app.use('/api/file', fileRoutes); app.use('/api/pexels', pexelsRoutes); diff --git a/backend/src/routes/events.js b/backend/src/routes/events.js index 5cdf433..c61352c 100644 --- a/backend/src/routes/events.js +++ b/backend/src/routes/events.js @@ -1,24 +1,11 @@ const express = require('express'); -const EventsService = require('../services/events'); -const EventsDBApi = require('../db/api/events'); -const wrapAsync = require('../helpers').wrapAsync; - - -const router = express.Router(); - -const { parse } = require('json2csv'); - - const { checkCrudPermissions, } = require('../middlewares/check-permissions'); -router.get('/public', wrapAsync(async (req, res) => { - const payload = await EventsDBApi.findAll(req.query); - res.status(200).send(payload); -})); +const router = express.Router(); router.use(checkCrudPermissions('events')); diff --git a/backend/src/routes/public.js b/backend/src/routes/public.js new file mode 100644 index 0000000..30d57a1 --- /dev/null +++ b/backend/src/routes/public.js @@ -0,0 +1,13 @@ + +const express = require('express'); +const EventsDBApi = require('../db/api/events'); +const wrapAsync = require('../helpers').wrapAsync; + +const router = express.Router(); + +router.get('/events/public', wrapAsync(async (req, res) => { + const payload = await EventsDBApi.findAll(req.query); + res.status(200).send(payload); +})); + +module.exports = router; diff --git a/frontend/src/pages/index.tsx b/frontend/src/pages/index.tsx index 2cdbbb0..ae27bd6 100644 --- a/frontend/src/pages/index.tsx +++ b/frontend/src/pages/index.tsx @@ -28,7 +28,7 @@ export default function LandingPage() { useEffect(() => { const fetchEvents = async () => { try { - const response = await axios.get(`/api/events/public`); + const response = await axios.get(`/events/public`); setEvents(response.data.rows); setLoading(false); } catch (err) {