Skip to content

Commit 96f1e3e

Browse files
Major updates before switching to axios (backend)
1 parent ba2ad20 commit 96f1e3e

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

.editorconfig

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
root = true
2+
3+
[*]
4+
indent_style = space
5+
indent_size = 2
6+
7+
[*.{js,ts,tsx,scss,css,html}]
8+
indent_style = space
9+
indent_size = 2

backend/routes/products.js

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
const express = require('express');
2+
const pool = require('../db');
3+
4+
const router = express.Router();
5+
6+
router.get('/', async (req, res) => {
7+
try {
8+
const result = await pool.query('SELECT * FROM products');
9+
res.json(result.rows);
10+
} catch (err) {
11+
console.error('🔴 DB ERROR:', { message: err.message, stack: err.stack });
12+
res.status(500).json({ error: 'Database query failed' });
13+
}
14+
});
15+
16+
module.exports = router;

0 commit comments

Comments
 (0)