fix: corretta chiamata che provocava un errore su postgres.
This commit is contained in:
1 parent
60259427d3
commit
107ba10689
1 file changed
+9
@@ -1915,6 +1915,9 @@ router.delete('/articles/:articleId', async (req, res) => {
|
|||||||
router.get('/attachments/:id', async (req, res) => {
|
router.get('/attachments/:id', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
|
if (!/^\d+$/.test(id)) {
|
||||||
|
return res.status(404).send('Allegato non trovato.');
|
||||||
|
}
|
||||||
const result = await pool.query(
|
const result = await pool.query(
|
||||||
`SELECT filename, content_type, content
|
`SELECT filename, content_type, content
|
||||||
FROM article_data_mime_attachment
|
FROM article_data_mime_attachment
|
||||||
@@ -1987,6 +1990,9 @@ router.get('/attachments/:id', async (req, res) => {
|
|||||||
router.put('/attachments/:id', async (req, res) => {
|
router.put('/attachments/:id', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
|
if (!/^\d+$/.test(id)) {
|
||||||
|
return res.status(404).json({ error: 'Allegato non trovato' });
|
||||||
|
}
|
||||||
const { content } = req.body;
|
const { content } = req.body;
|
||||||
if (typeof content !== 'string') {
|
if (typeof content !== 'string') {
|
||||||
return res.status(400).json({ error: 'Contenuto non valido' });
|
return res.status(400).json({ error: 'Contenuto non valido' });
|
||||||
@@ -2016,6 +2022,9 @@ router.put('/attachments/:id', async (req, res) => {
|
|||||||
router.post('/attachments/:id/open', async (req, res) => {
|
router.post('/attachments/:id/open', async (req, res) => {
|
||||||
try {
|
try {
|
||||||
const { id } = req.params;
|
const { id } = req.params;
|
||||||
|
if (!/^\d+$/.test(id)) {
|
||||||
|
return res.status(404).json({ error: 'Allegato non trovato' });
|
||||||
|
}
|
||||||
const result = await pool.query(
|
const result = await pool.query(
|
||||||
`SELECT filename, content_type, content FROM article_data_mime_attachment WHERE id = $1`,
|
`SELECT filename, content_type, content FROM article_data_mime_attachment WHERE id = $1`,
|
||||||
[id]
|
[id]
|
||||||
|
|||||||
Reference in new issue
Block a user