Preferences to customize the application.
The default settings for the configuration service. It's a
short-circuit for options.config.default
Protected_Since the configuration service has an async initialization, the class uses this flag internally to validate if the configuration has been initialized or not.
Protected_A list with all the top routes controlled by the application. Every time a controller is mounted, its route will be added here.
Protected_The Express application Jimpex uses under the hood.
Protected Optional_The instance of the server that is listening for requests.
Protected_A list of functions that implement controllers and middlewares. When the application starts, the queue will be processed and those controllers and middlewares will be added to the server instance. The reason they are not added directly like with a regular Express implementation is that services on Jimple use lazy loading, and adding middlewares and controllers as they come could cause errors if they depend on services that are not yet registered.
Protected_The customization settings for the application.
Protected Optional_A reference to the actual HTTP the application will use. This can vary depending on
whether HTTPS, or HTTP2 are enabled. If HTTPS is not enabled, it will be the same as
the express property; if HTTPS is enabled, it will be an https server; and if
HTTP2 is enabled, it will be an spdy server.
Gets the events service.
The Express application Jimpex uses under the hood.
The server instance that gets created when the app is started.
The logger service.
The application customization options.
A list of the routes that have controllers mounted on them.
Protected_Adds a static folder to the application.
The route to add the folder to.
The path to the folder in the file system. If not defined, it will
be use the same value as route. The path could be relative to the
project root, or where the application executable is located,
depending on the value of the onHome parameter.
If true, the path to the folder will be relative to the project
root. If false, it will be relative to where the application
executable is located.
Protected_This helper method validates the path options in order to register the app
location in the pathUtils service. The app location should be the path to where
the application executable is located, but due to how ESM works, we can't infer it
from the module object, so we need either received as the appPath setting, or try
to get it from the parent module.
Protected_Emits an event using the events service.
The literal name of the event, to type the event payload.
The name of the event to emit.
The event payload.
Protected_This method is like a "lifecycle method", it gets executed on the constructor right
before the "boot step". The idea is for the method to be a helper when the
application is defined by sub-classing Jimpex: the application could register
all important services here and the routes on boot, then, if the implementation needs
to access or overwrite a something, it can send boot: false, access/register what
it needs, and then call boot(). That would be impossible for an application without
overwriting the constructor and the boot functionality.
Protected_It generates overwrites for the application options when it gets created. This method
is a helper for when the application is defined by sub-classing Jimpex: It's
highly probable that if the application needs to change the default options, it would
want to do it right from the class, instead of having to do it on every
implementation. A way to do it would be overwriting the constructor and calling
super with the custom overwrites, but this method exists so that won't be
necessary: when creating the options, the constructor will merge the result of this
method on top of the default ones.
Protected_Loads the contents of a dictionary of credentials files that need to be used to configure HTTPS.
The dictionary where the keys are the type of credentials
(ca, cert, key) and the values are the paths to the
files.
If this is true, the path of the files will be relative
to the project root. If it is false, it will be relative
to where the application executable is located.
Protected_Loads the ESM modules that are needed by Jimpex. This is called just before the starting the application so they'll be available for all the services.
Protected_Processes the resources from the mount queue (added with Jimpex.mount and Jimpex.use), and adds them to the Express application.
Protected_Sends a target object to a list of reducer events so they can modify or replace it.
The name of the event to use.
The object to reduce with the event.
Extra context for the listeners.
Protected_Setups the configuration service. The new configuration service requires async calls
in order to load the configuration files (as it uses import instead of require),
so it can't be instantiated as the other services.
This method is called just before starting the application.
Protected_Registers the "core services" on the container: logger, events, utils, etc.
Protected_Configures the Express application based on the class options.
This is where the app would register all its specific services, middlewares and controllers.
Disables the server TLS validation. Meant to be used for development purposes.
Creates a new router instance.
Based on the application options, it returns whether the application is healthy or not.
This is an alias of start. The idea is for it to be used on serverless platforms,
where you don't get to start your app, you just have export it.
Optionalport: numberIn case the configuration doesn't already have it,
this is the port where the application will use to run. If this
parameter is used, the method will overwrite the port
setting on the configuration service.
OptionalonStart: JimpexStartCallbackA callback function to be called when the server starts.
The server instance.
Mounts a route controller or a middleware into a server routes.
The route for the controller/middleware.
The controller/middleware resource to be mounted.
Adds a listener for an application event.
The name of the event, to match the type of the listener function.
The name of the event to listen for.
The listener function.
A function to unsubscribe the listener.
Adds a listener for an application event that will only be executed once: the first time the event is triggered.
The name of the event, to match the type of the listener function.
The name of the event to listen for.
The listener function.
A function to unsubscribe the listener.
Starts the app server.
OptionalonStart: JimpexStartCallbackA callback function to be called when the server actually starts.
The server instance.
Stops the server instance.
Adds a global middleware to the application.
The middleware resource to be added.
Jimpex is a mix of Jimple, a Javascript port of Pimple dependency injection container, and Express, one of the most popular web frameworks for Node.
Todo
Implement
helmet.