This package has been deprecated

Author message:

Package no longer supported. Contact Support at https://www.npmjs.com/support for more info.

dino-serverless
TypeScript icon, indicating that this package has built-in type declarations

0.6.4 • Public • Published

DinO Serverless

DinO Serverless's aim is to create a configuration first framework for exposing web APIs in a serverless architectural configuration. The basic idea is that the first step of development starts with defining your Swagger/OpenAPI definition and provide it to DinO Serverless which will map your API and connect directly your code using the standard operationId defined for each API, this allow you to focus on your business requirements and the aspects that matters for your application leaving the boilerplate to DinO Serverless.

In order to be able to connect your Swagger/OpenAPI definition with your code seemlesly DinO Serverless define the concept of Interface, an interface is a Component on DinO world which responsibility is to accept the input from the users and propagate, after the required checks are performed, it to your services.

An example of how DinO Serverless works is provided on the examples/json folder, you can run it using the following command:

DINO_CONTEXT_ROOT=examples/json DINO_CONFIG_PATH=examples/json/config.json node examples/json/main.js

DinO Serverless integrate with Swagger UI, this allow you to easilly test your APIs and provide a clear interface for documentation, the Swagger UI will ba accessible at http://localhost:3030/api-docs or in general http[s]://hostname[:port]/api-docs.

Configuration

API configuration is primarily done via OpenAPI 3.0 definition. Some aspects are configured via a configuration file.

Monitoring

If enabled an additional endpoint /monitor is exposed that provides usefull information about the application status.

Exposed information are:

  1. UP/DOWN status
  2. Per-API cache - when enabled - information
  3. CO2eq runtime emissions if enabled via the dino.server.monitoring.co2 configuration. CO2eq monitoring is executed using the CO2.js library provided by The Greeen Web Foundation

Monitoring is enabled by default and can be controlled enabled/disabled using the dino.server.monitoring.enabled configuration.

Example

{
  "dino": {
    "monitoring": {
      "enabled": true|false,
      "c02": true|false
    }
  }
}

Caching

Dino-express uses apicache-plus module to provide caching functionalities. Caching is enabled adding the cache directive as part of the API definition, available configuration aspects are:

Parameter Description Default
ttl The TTL of the cache for this API 30 minutes
debug Enable debug statements for on console false
trackPerformance Enable performance tracking for the API cache, performance monitoring can be observed via /monitor endpoint true
isBypassable Allows to bypass cache by requesting with Cache-Control: no-store header true

Example

---
paths:
  /uuid:
    get:
      summary: Get a UUID
      operationId: getUUID
      tags:
        - uuid
      parameters: {}
      cache:
        ttl: 30 Seconds
        debug: false
        trackPerformance: true
        isBypassable: true
      responses:
        '200':
          description: An object containing a UUID
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/UUID'
        default:
          description: unexpected error
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/Error'

Contributing

Given the scarce amount of time in my hands the pace of the project is really slow, so contribution are welcome.

If you are interested in contributing to the project please do not hesitate have a look at the contributing guidelines or get in touch.

Package Sidebar

Install

npm i dino-serverless

Weekly Downloads

2

Version

0.6.4

License

Apache-2.0

Unpacked Size

158 kB

Total Files

83

Last publish

Collaborators

  • qbr