comedians.ts

import { getComedians, getComedian } from '../fetch/comedians';
import { apiPrefix } from '../../utility/constants/app';
import comedianMapper from '../mapper/comedians';
import middlewares from '../helper/middlewares';

export default async function comedianEndpoints(app) {
  app.get(`${apiPrefix}/comedians`, middlewares, async (req, res) => {
    const list = await getComedians(req);
    res.json(list);
  });

  app.get(`${apiPrefix}/comedians/:comedianId`, middlewares, async (req, res) => {
    const result = await getComedian(req);
    const comedian = comedianMapper(result);
    res.json(comedian);
  });
}