(PDB-658) Move environments endpoint to the query engine

Needed to add support for an empty query to the engine. This was needed to query for ALL environments. Will need to rebase after https://github.com/puppetlabs/puppetdb/pull/982 is merged.
Yes, it was merge conflict, let me remove it