HTTP server provider for @mdf.js based on express.
Using npm:
npm install @mdf.js/http-server-provider
Using yarn:
yarn add @mdf.js/http-server-provider
Check information about @mdf.js providers in the documentation of the core module @mdf.js/core.
The provider implemented in this module wraps an HTTP server based on express to provide a simple HTTP server.
import { HTTP } from '@mdf.js/http-server-provider';
const client = HTTP.Factory.create({
name: `myHTTPServerProvider`,
config: {
/** Port for the HTTP server */
port: 8080,
/** Host for the HTTP server */
host: 'localhost',
/** Express app configuration */
app: Express,
},
logger: myLoggerInstance,
useEnvironment: true,
});
-
Defaults:
{ port: 8080, host: 'localhost', app: /* Default static web */, }
-
Environment: remember to set the
useEnvironment
flag totrue
to use these environment variables.{ port: process.env['CONFIG_SERVER_PORT'], host: process.env['CONFIG_SERVER_HOST'], }
Checks included in the provider:
-
status: Due to the nature of the HTTP server, the status could be
running
if the server has been started properly,stopped
if the server has been stopped or is not initialized, orerror
if the server could not be started.-
observedValue:
running
if the server is running,stopped
if the server is stopped, orerror
if the server could not be started. -
status:
pass
if the server is running,fail
could not be started orwarn
if the server is stopped. -
output: In case of
error
state (statusfail
), the error message is shown. -
componentType:
service
.
-
observedValue:
{
"[mdf-http-server:status]": [
{
"status": "pass",
"componentId": "00000000-0000-0000-0000-000000000000",
"observedValue": "running",
"componentType": "service",
"output": undefined,
},
],
}
-
CONFIG_SERVER_PORT (default:
8080
): Port for the HTTP server. -
CONFIG_SERVER_HOST (default:
localhost
): Host for the HTTP server.
Copyright 2024 Mytra Control S.L. All rights reserved.
Use of this source code is governed by an MIT-style license that can be found in the LICENSE file or at https://opensource.org/licenses/MIT.