Skip to content
This repository has been archived by the owner on Aug 16, 2023. It is now read-only.

Commit

Permalink
📝 Add usage
Browse files Browse the repository at this point in the history
  • Loading branch information
ci7lus committed Aug 4, 2020
1 parent 5391498 commit 5cbb78f
Showing 1 changed file with 52 additions and 0 deletions.
52 changes: 52 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,55 @@
[![npm version](https://img.shields.io/npm/v/ironpipe)](https://www.npmjs.com/package/ironpipe)

[WIP] TypeScript typed helpers for pipedream.

## Install

```shell
yarn add -D ironpipe
```

## Usage

### defineComponent

`defineComponent` is a function for defining type-safe components.

```ts
import { defineComponent } from "ironpipe"

module.exports = defineComponent({
name: "componentname",
version: "0.0.1",
props: {
url: {
type: "string",
label: "something url",
},
timer: {
type: "$.interface.timer",
default: {
intervalSeconds: 60 * 15,
},
},
db: "$.service.db",
http: "$.interface.http",
},
methods: {
random(n: number) {
return Math.random() * n
},
},
dedupe: "unique",
async run() {
// `this` will be typed whenever possible.
this.db.set("random-value", this.random(100))
this.db.set("something-url", this.url)

this.http.respond({
status: 200,
headers: {},
body: this.db.get<number>("random-value")?.toString() || this.url,
})
},
})
```

0 comments on commit 5cbb78f

Please sign in to comment.