1.0.8 • Published 26 days ago

express-http-server v1.0.8

Weekly downloads
-
License
ISC
Repository
github
Last release
26 days ago

express-http-server

Express http server for initializing middleware, error handlers, routes, openapi validator and logger.

Config

NameDescription
routerBase routes to initialize in the server
openapiBaseSchemaPath to OpenAPI specification yaml file
envControl logging and stack inclusion in error responses
ignoredAccessLogPathsURL path fragments to be excluded from the access logs

For logger configuration properties see the logger documentation

Usage

import { App } from 'express-http-server';

/**required env values */
const appConfig = {
  /** base routes to initialize in the server */
  router: routers,  

  /** logger configuration */
  logger: { logLevel: 'debug', logStyle: 'cli', appName: 'nodejs-commons', moduleName: 'App' },
  ignoredAccessLogPaths: '',

  /** path to openapi swagger file */
  openapiBaseSchema: 'src/openapi/api.schema.yml',

  /** environment(development/test/prod) */  
  env: 'development',

  /** function which allows you to register custom body parsers */
  customBodyParser: (app: Express) => app.use(express.json()),
};

/** initializing the server */
export const app = new App(appConfig).init();