Use middlewares only for json server specific routes

How can I use a middleware for my json-server ONLY FOR specific routes? In the json-server docs, I can see the following instructions:

server.use(customMiddleware)
server.use(jsonServerRouter) // customMiddleware should be executed ONLY FOR jsonServerRouter

/*
Problem is here, customMiddleware has already been executed,
so following routes will use the middleware too
*/
server.use(otherRoutes)