Framework to create monolithic REST API


Keywords
mono, rest api, framework, monolithic, rest-api, acl, log, api, node, rest
License
MIT
Install
npm install @terrajs/mono@0.9.1

Documentation

Mono

Mono is a REST API Framework for node.js (with TypeScript support)

Installation

npm install --save @terrajs/mono

Features

  • Configuration based on environment
  • Easy API Versionning (v1, v2...)
  • Sessions with Json Web Token
  • ACL with imperium
  • Routes validation with joi
  • Init modules via modules/**/*.init.js
  • Routes declaration via modules/**/*.routes.js

Usage

conf/
  application.js
  development.js
modules/
  users/
    users.init.js
    users.routes.js
server.js
package.json

server.js

const start = require('@terrajs/mono').default

start()

With TypeScript:

import start from '@terrajs/mono'

Configuration

You project configuration should be inside the conf/ directory.

Mono will load and merge these files in this order:

  1. conf/application.js
  2. conf/${process.env.NODE_ENV}.js
  3. conf/local.js (should be inside .gitignore)

All these files should export an Object, to configure Mono, use the mono property.

mono available properties:

  • http: HTTP configuration of Mono server
  • jwt: Json Web Token configuration
  • log: Log configuration
  • modules: External modules to use with Mono

Getters

const { conf, log, acl, HttpError, db, es } = require('@terrajs/mono')

Utils

const { ok, cb, waitFor, waitForEvent, asyncObject } = require('@terrajs/mono/utils')