Files
SkyArtShop/backend/routes/public.js
Local Server 8bb6430a70 Website restoration: Node.js backend, restored design, GitHub sync disabled
- Replaced broken .NET backend with Node.js/Express
- Restored original website design with purple gradient hero
- Updated homepage and shop pages with Bootstrap 5 responsive design
- Disabled GitHub remote sync - all code now stored locally only
- Created backup scripts and documentation
- All changes saved on Ubuntu server at /var/www/SkyArtShop
2025-12-13 17:53:34 -06:00

40 lines
1.1 KiB
JavaScript

const express = require('express');
const { query } = require('../config/database');
const router = express.Router();
router.get('/', async (req, res) => {
try {
const products = await query(
'SELECT id, name, description, price, imageurl FROM products WHERE isactive = true ORDER BY createdat DESC LIMIT 8'
);
const sections = await query(
'SELECT * FROM homepagesections ORDER BY displayorder ASC'
);
res.render('public/home', {
title: 'Welcome - SkyArtShop',
products: products.rows,
sections: sections.rows
});
} catch (error) {
console.error('Home page error:', error);
res.status(500).send('Server error');
}
});
router.get('/shop', async (req, res) => {
try {
const products = await query(
'SELECT id, name, description, price, imageurl, category FROM products WHERE isactive = true ORDER BY name ASC'
);
res.render('public/shop', {
title: 'Shop - SkyArtShop',
products: products.rows
});
} catch (error) {
console.error('Shop page error:', error);
res.status(500).send('Server error');
}
});
module.exports = router;