1.0.2 • Published 8 years ago

abox v1.0.2

Weekly downloads
7
License
MIT
Repository
github
Last release
8 years ago

abox - Api Toolbox

Build Status npm version codecov.io

Quickstart

Installation

npm install abox --save

Code Example

action.ts

import {Action} from "abox";

@Action({ name: "ping" })
export class Ping {
  constructor(public message: string) {

  }
}

@Action({ name: "pong" })
export class Pong {
  constructor(public message: string) {

  }
}

app.ts

import {Api} from "abox";
import {Ping, Pong} from "./actions";

const api = new Api();

api
  .on(Ping)
  .handle((context, data) => {
    context.done(new Pong(data.message));
  });

api
  .on(Pong)
  .handle((context, data) => {
    console.log("Pong:", data.message);
    context.done();
  });

export = api;