Software: Apache. PHP/8.1.30 uname -a: Linux server1.tuhinhossain.com 5.15.0-151-generic #161-Ubuntu SMP Tue Jul 22 14:25:40 UTC uid=1002(picotech) gid=1003(picotech) groups=1003(picotech),0(root) Safe-mode: OFF (not secure) /home/picotech/domains/rentals.picotech.app/public_html/server/routes/ drwxr-xr-x |
Viewing file: Select action/file-type: import express from 'express'; import Notice from '../models/Notice.js'; const router = express.Router(); // CREATE a new notice router.post('/', async (req, res) => { try { const notice = await Notice.create(req.body); res.status(201).json(notice); } catch (err) { console.error('Create notice error:', err); res.status(400).json({ error: 'Failed to create notice', details: err.message }); } }); // READ all notices router.get('/', async (req, res) => { try { const notices = await Notice.findAll(); res.json(notices); } catch (err) { console.error('Fetch notices error:', err); res.status(500).json({ error: 'Failed to fetch notices' }); } }); // READ a single notice by ID router.get('/:id', async (req, res) => { try { const notice = await Notice.findByPk(req.params.id); if (!notice) return res.status(404).json({ error: 'Notice not found' }); res.json(notice); } catch (err) { res.status(500).json({ error: 'Failed to fetch notice' }); } }); // UPDATE a notice router.put('/:id', async (req, res) => { try { const notice = await Notice.findByPk(req.params.id); if (!notice) return res.status(404).json({ error: 'Notice not found' }); await notice.update(req.body); res.json(notice); } catch (err) { console.error('Update notice error:', err); res.status(400).json({ error: 'Failed to update notice', details: err.message }); } }); // DELETE a notice router.delete('/:id', async (req, res) => { try { const notice = await Notice.findByPk(req.params.id); if (!notice) return res.status(404).json({ error: 'Notice not found' }); await notice.destroy(); res.json({ message: 'Notice deleted' }); } catch (err) { console.error('Delete notice error:', err); res.status(500).json({ error: 'Failed to delete notice' }); } }); export default router; |
:: Command execute :: | |
--[ c99shell v. 2.5 [PHP 8 Update] [24.05.2025] | Generation time: 0.0035 ]-- |