Blueprint Modules
Codify design solutions into reusable modules
What is a Blueprint Module?
A Blueprint module is a node module that contains a reusable Blueprint entities that can be applied to a Blueprint application. The goal of a Blueprint module is to provide functionality that address a certain application concern. For example, a Blueprint module many provide support for MongoDB, or it may implement a solution for integrating a paywall into your application. This way, the Blueprint application developer does not have to implement the solution themselves.
Creating a Blueprint Module
It is not hard to create a Blueprint module. First, you need to create a standard Blueprint application.
After the Blueprint application is created, add blueprint-module
to the keywords
property in the generated packaged.json
file. Now, save the application and publish it using npm
.
You have now created your first Blueprint module.
Loading Blueprint Modules
The Blueprint application automatically loads all Blueprint modules. It does so by using a postorder depth-first search of the dependencies defined in package.json
, and loading all modules that have the keyword blueprint-module
. This ensures that all dependencies are available to the parent module, or application, when it is loaded into memory.
A Blueprint module can depend on other Blueprint modules.
When a Blueprint module is loaded into memory, the module is added to the Blueprint application and the entities in the Blueprint module are merged with the entities in the application. If an entity with the same type and name already appears in the application, it is overwritten. The overwritten entity, however, will still be accessible via the application. You just have to include the Blueprint module name when you are perform a lookup operation. For example
Supported Entities
The following entities can be loaded from a Blueprint module into a Blueprint application:
Controllers
Listeners
Models
Policies
Resources
Routers
Sanitizers
Services
Validators
When a router is loaded from a Blueprint module, its routes are not automatically added to the Blueprint application. Instead, you must mount a router for it to be useable from the Blueprint application.
Module Directory
The following is a list of know Blueprint modules.
Authentication
Gatekeeper - Token-based authentication
Communication/Messaging
Greenlock - Let's Encrypt support for free, automated SSLs
Firebase Messaging - Google Firebase Messaging support
Socket.IO - Socket.IO support
Data Models
MongoDB - MongoDB support via Mongoose
Documentation
Swagger UI - generate and view Swagger specification from application
Last updated