This commit is contained in:
2026-03-23 19:14:25 -05:00
parent 92676e652a
commit 58ac75e51b
11 changed files with 202 additions and 20 deletions

View File

@@ -0,0 +1,11 @@
FROM node:22-alpine
WORKDIR /app
COPY package*.json ./
RUN npm ci --omit=dev
COPY . .
EXPOSE 5000
CMD ["node", "index.js"]

View File

@@ -3,8 +3,8 @@ const { Pool } = require('pg');
const cors = require('cors');
require('dotenv').config();
const app = express();
const port = process.env.PORT || 5000;
const app = express();
const port = process.env.PORT || 5000;
// Middleware
app.use(cors());
@@ -20,12 +20,22 @@ const pool = new Pool({
port: process.env.DB_PORT,
});
pool.on('error', (err) => {
console.error('Unexpected error on idle client', err);
process.exit(-1);
});
// Routes
pool.on('error', (err) => {
console.error('Unexpected error on idle client', err);
process.exit(-1);
});
app.get('/health', async (_req, res) => {
try {
await pool.query('SELECT 1');
res.json({ ok: true });
} catch (err) {
console.error('Healthcheck failed', err);
res.status(500).json({ ok: false });
}
});
// Routes
// --- PRODUCTS ---
app.get('/api/products', async (req, res) => {

View File

@@ -0,0 +1,36 @@
CREATE TABLE IF NOT EXISTS products (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
price DECIMAL(10, 2) NOT NULL,
image TEXT NOT NULL,
description TEXT,
gallery JSONB DEFAULT '[]'::jsonb,
slug TEXT,
number TEXT,
aspect_ratio TEXT,
details JSONB DEFAULT '[]'::jsonb
);
CREATE TABLE IF NOT EXISTS articles (
id SERIAL PRIMARY KEY,
title VARCHAR(255) NOT NULL,
date VARCHAR(50) NOT NULL,
image TEXT NOT NULL,
sections JSONB DEFAULT '[]'::jsonb,
slug TEXT,
category TEXT,
description TEXT,
is_featured BOOLEAN DEFAULT FALSE
);
CREATE TABLE IF NOT EXISTS orders (
id SERIAL PRIMARY KEY,
customer_email TEXT NOT NULL,
customer_name TEXT NOT NULL,
shipping_address JSONB NOT NULL,
items JSONB NOT NULL,
total_amount DECIMAL(10, 2) NOT NULL,
payment_status TEXT DEFAULT 'pending',
shipping_status TEXT DEFAULT 'pending',
created_at TIMESTAMP WITH TIME ZONE DEFAULT CURRENT_TIMESTAMP
);