diff --git a/server.js b/server.js deleted file mode 100644 index 46bd59b..0000000 --- a/server.js +++ /dev/null @@ -1,53 +0,0 @@ -import express from "express"; -import cors from "cors"; - -const app = express(); -app.use(cors()); -app.use(express.json()); - -// --- “BD” en memoria (se borra cuando redeploy/restart) --- -const services = []; -let nextId = 1; - -// Raíz -app.get("/", (req, res) => res.send("IntegraRepara API OK")); - -// Health (sin DB por ahora) -app.get("/health", (req, res) => { - res.json({ ok: true, db: false, now: new Date().toISOString() }); -}); - -// Listar servicios -app.get("/services", (req, res) => { - // opcional: ordenar por id desc para ver lo último arriba - const list = [...services].sort((a, b) => b.id - a.id); - res.json({ ok: true, count: list.length, services: list }); -}); - -// Crear servicio -app.post("/services", (req, res) => { - const { title, client, phone, address, notes } = req.body || {}; - - if (!title || !client) { - return res.status(400).json({ - ok: false, - error: "Faltan campos obligatorios: title y client", - }); - } - - const item = { - id: nextId++, - title: String(title).trim(), - client: String(client).trim(), - phone: phone ? String(phone).trim() : "", - address: address ? String(address).trim() : "", - notes: notes ? String(notes).trim() : "", - createdAt: new Date().toISOString(), - }; - - services.push(item); - res.status(201).json({ ok: true, service: item }); -}); - -const port = process.env.PORT || 3000; -app.listen(port, () => console.log(`🚀 API listening on :${port}`)); \ No newline at end of file