https://github.com/liam-fitzgerald/urbit-airlock-ts
A library for interacting with your urbit over HTTP
https://github.com/liam-fitzgerald/urbit-airlock-ts
urbit
Last synced: about 1 year ago
JSON representation
A library for interacting with your urbit over HTTP
- Host: GitHub
- URL: https://github.com/liam-fitzgerald/urbit-airlock-ts
- Owner: liam-fitzgerald
- Created: 2020-03-31T01:44:38.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2022-05-26T06:55:29.000Z (about 4 years ago)
- Last Synced: 2025-03-27T18:04:09.972Z (about 1 year ago)
- Topics: urbit
- Language: TypeScript
- Size: 108 KB
- Stars: 13
- Watchers: 2
- Forks: 0
- Open Issues: 7
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Urbit Airlock bindings
## Installation
`npm install urbit-airlock --save`
## Usage
### Connection
Opening a connection to your urbit is as follows
``` typescript
const connection = await connect(
'zod',
'http://localhost',
80,
'lidlut-tabwed-pillex-ridrup'
);
const channel = new Channel(connection);
```
You may then subscribe and poke over the connection.
```typescript
channel.subscribe('chat-view', '/primary', {
mark: 'json',
onError: (err: any) => { console.log(err); },
onEvent: (event: any) => { console.log(event); },
onQuit: (err: any) => { console.log(err); }
});
channel.poke('gall-app', {
mark: 'json',
data: { update: 2 }
});
```
### Typescript
Pokes and subscription updates are strongly typed, but you need to make the
interface-mark correspondence known to typescript.
You associate a mark to an interface like so
``` typescript
declare module 'urbit-airlock/lib/marks' {
interface Marks {
readonly 'number': number;
}
}
```
This associates the 'number' mark to the typescript type `number`