Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/no0dles/abox
https://github.com/no0dles/abox
Last synced: 25 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/no0dles/abox
- Owner: no0dles
- License: mit
- Created: 2016-10-01T13:11:33.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2017-07-24T16:57:02.000Z (over 7 years ago)
- Last Synced: 2024-04-28T04:42:05.311Z (9 months ago)
- Language: TypeScript
- Size: 47.9 KB
- Stars: 0
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# abox - Api Toolbox
[![Build Status](https://travis-ci.org/no0dles/abox.svg?branch=master)](https://travis-ci.org/no0dles/abox)
[![npm version](https://badge.fury.io/js/abox.svg)](https://badge.fury.io/js/abox)
[![codecov](https://codecov.io/gh/no0dles/abox/branch/master/graph/badge.svg)](https://codecov.io/gh/no0dles/abox)## Quickstart
### Installation
```
npm install abox --save
```### Code Example
messages.ts
```typescript
import {Key} from "abox";@Key("ping")
export class Ping {
constructor(public message: string) {}
}@Key("pong")
export class Pong {
constructor(public message: string) {}
}
```app.ts
```typescript
import {Api} from "abox";
import {Ping, Pong} from "./messages";const api = new Api();
api
.on(Ping)
.do((ping, context) => {
context
.emit(new Pong(ping.message))
.done();
});api
.on(Pong)
.do((pong, context) => {
console.log("Pong:", pong.message);
context.done();
});export = api;
```