// planilla/api/server.js
import express from 'express';
import { Pool } from 'pg';
const app = express();
const pool = new Pool({
  host: process.env.DB_HOST,
  user: process.env.DB_USER,
  password: process.env.DB_PASSWORD,
  database: process.env.DB_NAME,
});
app.use(express.json());
app.get('/api/items', async (req, res) => {
  const { rows } = await pool.query('SELECT * FROM items');
  res.json(rows);
});

app.get('/api/test', async (req, res) => {
  // hello world
  console.log('Hello World');
  res.json({ message: 'Hello World' });
});

app.listen(4000, ()=> console.log('API corriendo en :4000'));
