@mdf.js/http-server-provider
TypeScript icon, indicating that this package has built-in type declarations

1.6.0 • Public • Published

@mdf.js/http-server-provider

Node Version Typescript Version Known Vulnerabilities Documentation

netin

Mytra Development Framework - @mdf.js/http-server-provider

Typescript tools for development

Table of contents

Introduction

HTTP server provider for @mdf.js based on express.

Installation

Using npm:

npm install @mdf.js/http-server-provider

Using yarn:

yarn add @mdf.js/http-server-provider

Information

Check information about @mdf.js providers in the documentation of the core module @mdf.js/core.

Use

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 to true to use these environment variables.

    {
      port: process.env['CONFIG_SERVER_PORT'],
      host: process.env['CONFIG_SERVER_HOST'],
    }

Health checks

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, or error if the server could not be started.
    • observedValue: running if the server is running, stopped if the server is stopped, or error if the server could not be started.
    • status: pass if the server is running, fail could not be started or warn if the server is stopped.
    • output: In case of error state (status fail), the error message is shown.
    • componentType: service.
{
  "[mdf-http-server:status]": [
    {
      "status": "pass",
      "componentId": "00000000-0000-0000-0000-000000000000",
      "observedValue": "running",
      "componentType": "service",
      "output": undefined,
    },
  ],
}

Environment variables

  • CONFIG_SERVER_PORT (default: 8080): Port for the HTTP server.
  • CONFIG_SERVER_HOST (default: localhost): Host for the HTTP server.

License

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.

Package Sidebar

Install

npm i @mdf.js/http-server-provider

Weekly Downloads

199

Version

1.6.0

License

MIT

Unpacked Size

37.3 kB

Total Files

55

Last publish

Collaborators

  • cjimenezsaiz