import { Category, sequelize } from './model';

async function view(req) {
  try {
    let { cid } = req.query;
    console.log(cid);

    await sequelize.authenticate();

    const category = await Category.findOne({ where: { cid } });

    return { status: 'OK', category };
  } catch (error) {
    console.error(error);
  }
}

export default async function handler(req, res) {
  try {
    let result = await view(req);

    return res.status(200).send(result);
  } catch (err) {
    console.log(err);
    res.status(200).send({ status: 'error', message: 'list error' });
  }
}
