DTP Framework: registerMiddleware
Off and on over the past couple days, I've been refactoring the DTP core library into it's own module that can then be added to projects as a dependency. I do mean the directory in the project that implements classes like SiteAsync and SitePlatform. As part of this work, the config object received a registerMiddleware
function.
This function, which is optional, lets you build and register your own ExpressJS middleware to be installed in the request processing chain after session startup and before controller logic (endpoints/routes). Here I am showing DTP Sites using the new config function to register it's Page middleware - which should execute for every request.
NOTICE: Middleware registered on the app here as shown will be called with every request. This may not be what you want, I am being simple to show what's possible in the function.
This helps keep change and application-specific code out of the core. I go fast when getting things off the ground, then come back and tidy things up once they're proven. The DTP framework will be sticking around. So it's time to make it more formal. This is part of that.