The controller uses the model (entity + repository) and it is implemented using the Express routing techniques that we explored earlier in this chapter.
We are going to declare routes to get all movies, filter movies by year, and create a new movie. The example also uses req.params to access the request parameter year.
It is important to note that we can use the get method to declare a route handler for an HTTP GET request, while we can use the post method to declare a route handler for an HTTP POST request:
import { Router } from "express"; import { getRepository } from "../repositories/movie_repository"; const movieRouter = Router(); movieRouter.get("/", function (req, res) { const movieRepository = getRepository(); movieRepository.find().then((movies) ...