When a client requests movie data, an endpoint provides the address and operation that route the request to the appropriate server behavior. A GET request to /movies returns all movies, while /movie/:id uses a route parameter to find one movie. section 4.3.1
An API endpoint is a network-accessible operation identified by a URL and method. Its route connects a client request to application logic and determines the response, including errors such as “Movie not found.” section 4.3.1
A practical endpoint implementation separates these responsibilities:
- Define application operations such as retrieving all movies, finding a movie by ID or name, inserting a movie, or retrieving the first movie. section 4.3.1
- Register routes that map HTTP requests to those operations; route parameters capture values embedded in a URL. section 4.3.1
- Start the provider service, import its data, listen on an available port, and expose the endpoint to clients. section 4.3.1
Movies API
A provider registers GET /movies to send the complete movie collection and GET /movie/:id to return the matching movie. Requesting /movie/1 returns The Shawshank Redemption; an unknown ID returns a 404 response. In contract testing, a search-suggestions endpoint can instead be exercised through a real provider while the E2E test uses a mock. section 4.3.1 section 12.4
...
const movies = new Movies();
server.get('/movies', (req, res) => {
res.send(movies.getMovies());
});
server.get('/movie/:id', (req, res) => {
const movie = movies.getMovieById(req.params.id);
if (!movie) {
res.status(404).send('Movie not found');
} else {
res.send(movie);
}
});
...
Inspect the concrete Express route definitions for collection retrieval, parameterized lookup, and not-found handling. section 4.3.1

























