src/controllers/theatre.ts
import * as Hapi from '@hapi/hapi';import * as Boom from '@hapi/boom';import Theatre from '../models/theatre'; Similar blocks of code found in 3 locations. Consider refactoring.export default async (request: Hapi.Request) => { const theatreSlug = request.params.theatreSlug; if (!theatreSlug) { const theatres = await Theatre.find({}).lean().exec(); return Theatre.serialize(theatres); } const theatre = await Theatre.findOne({ slug: theatreSlug, }) .lean() .exec(); if (!theatre) { return Boom.notFound(); } return Theatre.serialize(theatre);};