DTP Framework: registerMiddleware

As part of the cleanup happening throughout DTP, application specific code is being hoisted out of the core platform. Here's one way that's happening.

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.

Post author

Founder of DTP, creator of Sites, Venue, Shing.tv, LibertyLinks.io and more to come.


    There are no comments at this time. Please check back later.
    DTP Sites
    A blogging engine with reach for the Next economy.
    dtp-sites v0.6.16
    © 2023 Digital Telepresence, LLC
    Made In USA πŸ‡ΊπŸ‡Έ