0.10.1 • Published 6 years ago

metallic-app v0.10.1

Weekly downloads
2
License
BSD-3-Clause
Repository
github
Last release
6 years ago

metallic-app

Build Status js-standard-style

A Koa's application bundled with common middlewares to build CARTO's services in a fancy way.

Quickstart

  • Create app.js:
import { default as AppFactory } from 'metallic-app'

const app = AppFactory.create(/* { config } */)

await app.run()
  • Run:
$ node app.js

Configuration

A working example with default values:

const app = AppFactory.create({
    metrics, // a metallic-metrics' instance (optional, default: undefined)
    logger, // a metallic-logger's instance (required)
    options: {
        port: 0 // port to listen (optional, default: 0)
    }
})

metrics: Object (default: undefined)

A metallic-metrics' instance. Further documentation: metallic-metrics

logger: Object (required)

A metallic-logger's instance. Further documentation: metallic-logger

options: Object (default: undefined)

  • port: port to listen incoming requests (optional, default: 0). If port is not provided then operating system will assign a random port, which can be retrieved by using app.address().port after awaiting .run().

Features

  • Proper error handling
  • Identifies every request with a unique identifier setting a custom header X-Request-ID and accesible by ctx.state.requestId
  • Adds response time header X-Response-Time
  • Request/Response logging
  • Provides an accessor to metrics in request/reponse context

API

await app.run()

Accepts connections on the specified port, if provided.

await app.close()

Stop to accept connections.

0.10.1

6 years ago

0.10.0

6 years ago

0.9.0

6 years ago

0.8.0

7 years ago

0.7.0

7 years ago

0.6.0

7 years ago

0.5.0

7 years ago

0.4.0

7 years ago

0.3.0

7 years ago

0.2.1

7 years ago

0.2.0

7 years ago

0.1.0

7 years ago

0.0.0

7 years ago