const express = require('express');
const router = express.Router();
const facService = require('../services/facService');

router.post('/create', async (req, res) => {
  const data = req.body;
  const fac = await facService.createFAC(data);

  res.json({ valid: Boolean(fac), fac });
});

router.get("/read/id/:id", async (req, res) => {
  const id = req.params.id;

  try {
    const fac = await facService.getFACbyId(id);
    res.json({ valid: Boolean(fac), fac });    
  } catch (error) {
    res.status(500).json({ valid: false, error: "Internal Server Error" });
  }
});

module.exports = router;