How to query with tags to get specific places

Hi everyone, I’m new to OSM and I’m trying to figure out how to use it to create a web application that lets the user create a route with specified preferences.
Let’s say user X wants to go from point A to point B, but for some reasons he wants to travel on a path where there are points of interest where “building=bakehouse”, for example.
I couldn’t find anything on how to do that, like if there’s a way to query the DB to get all places (with their name, or latleng) within a range specified that have that tag, so I’m asking for help here.
Currently I’m using leaflet for the map, with AngularJS (I’m using Ionic framework).
Is there a way to achieve this and get a result containing the places with the specified characteristics?
Any tip, tutorial or guide will be really appreciated.

First you will need a provider to calculate the route between the 2 points. That’s not part of Leaflet. Some providers make extensions for Leaflet to talk to their API and show the results.

I am not aware of any routing service that allows to to specify POIs you have to meet when you travel from A to B.
So you will probably first need to retrieve those POI yourself and then calculate some alternative routes along each of those POIs.