The Server
Learn how to configure the server
Last updated
Learn how to configure the server
Last updated
The server is the part of the Blueprint application responsible for handling request. It is essentially a Wrapper Facade for an Express application. The server exists to provide functionality that is common across all Express application, such as listening on ports and . There are no extra steps need to use the server in your Blueprint application. You just need to configure it to meet you needs.
The server natively supports the http
and https
protocol. You configure the protocols under the protocols
section of the server configuration file.
Here is an example configuration for http
where we are setting the port number. The http
hash is the options support for .
All built-in middleware is configured under the middleware
property. If a specific middleware configuration is not defined and it does not have a default configuration, then it is not loaded. The server supports the following Blueprint middleware, in order.
Custom middleware is middleware functions that should be applied the entire application that are not suited for inclusion via a router, and not built-in middleware supported by the server.
Static files are assets on the server that are not dynamically generated. For example, an icon image file, a style sheet, or a javascript file could be considered a static file. The server is not considered with each individual static file, but where the static files reside.
You use the static property in the server configuration file to define the location of the static files. The static property takes an array of paths to the static files. If the path is a relative path, then it is is relation the app/
directory. If the path is an absolute path, then the specified path is used as-is.
Here is an example configuration for https
where we are setting the port number, public key, and private key. The https
hash is the options support for .
is http request logging middleware for .
Use middleware.morgan
property to configure . If you do not provide a configuration for , then a default one is provided. See the .
is Node.js parsing middleware for . It is responsible for parsing the body of a HTTP request and making the content available on req.body
. support different kinds of parsers, such as and .
Use middleware.bodyParser
to define the configuration for . Each parser you want to support has a named configuration under middleware.bodyParser
. and body parsers are always enabled. You, however, can change the configuration of and body parsers, and include others supported by the middleware.
is middleware for validating the input of an HTTP request. It is does this by adapting into an middleware. is used by to .
There is no configuration support for .
The middleware in responsible for parsing HTTP request cookies and making them available via req.cookies
.
Use the middleware.cookies
property to configure the middleware. See the documentation for the .
is very simple session middleware for Express. The session information is available on the req.session
data property.
Use the middleware.session
property to configure the middleware. See the documentation for the .
is authentication middleware for .
Use the middleware.passport
data property to configure . If middleware.passport.session
is defined in the server configuration file, then the server will .
Use the middleware.custom
property to configure custom middleware. The custom.middleware
property takes either a , or an array of .