export default async function getCartocss(req, reply) {
  const { pg, params } = req;

  const { id } = params;
  if (!id) return reply.status(400).send({ message: 'id is empty', status: 400 });

  const selectCartocss = `select cartocss_key,name,description,config,style,group_id,is_public,enabled from gis.cartocss where cartocss_id='${id}'`;
  const cartocss = await pg.one(selectCartocss).catch(() => null);
  if (!cartocss) return reply.status(404).send({ message: 'cartocss not found', status: 404 });

  return reply.status(200).send({ message: cartocss, status: 200 });
}
