Generalize library.

This generalizes the implementation of the library, freeing it from
being too tightly coupled to Express applications. It now works with
Express routers and libraries with similar APIs.