# gsox

> framework for streaming data to browser and mobile clients using grapqhl subscriptions, websockets, and webhook

Latest version **0.1.21** (published 2018-08-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install gsox
pnpm add gsox
yarn add gsox
bun add gsox
```

Provides the command `gsox`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.21 |
| Published | 2018-08-07 |
| First published | 2018-07-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 311.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Alek Merani |
| Maintainers | amerani |

## Links

- npm: https://www.npmjs.com/package/gsox
- npm.io page: https://npm.io/package/gsox

## Dependencies (2)

- [async](https://npm.io/package/async.md) ^2.6.1
- [chalk](https://npm.io/package/chalk.md) ^2.4.1

## Recent versions

- 0.1.21 (latest) — 2018-08-07
- 0.1.20 — 2018-08-07
- 0.1.19 — 2018-08-06
- 0.1.3 — 2018-08-06
- 0.1.1 — 2018-07-21
- 0.1.0 — 2018-07-21

## README

# gsox
framework for streaming data to browser and mobile clients using grapqhl subscriptions, websockets, and webhook

## installation
`npx gsox`

## schema
describe your data types
```js
import { Type, Field } from "@gsox/schema"

@Type()
class Notification {

      @Field('Int')
      id:number

      @Field()
      type:string
}

@Type()
class MessageType { ... }

const inject = [Notification, MessageType]
```

## client
consume/subscribe to one or more types

### react
```js
import { createClient, StreamProvider, StreamConsumer } from "@gsox/client"

const client = createClient({ host, port })

<StreamProvider client={client}>
      <StreamConsumer types={[Notification]}>

      {({ data, error, loading }) => {
            if(loading) return <Loading />
            if(data) return <DataView />
      }}

      </StreamConsumer>
</StreamProvider>
```

### observable
```js
import { createClient } from "@gsox/client"

const client = createClient({ host, port })

client.subscribe([Notification, MessageType], {
      next: data => console.log(data),
      error: error => console.log(error)
})
```

## server
inject data types and apply express middleware
```js
import { applyMiddleware } from "@gsox/server"

const app = express()

const server = applyMiddleware(app, { host, port, inject })

server.listen(() => console.log(`gsox listening 🧦🧦🧦`))
```

## endpoints
`http://host:port/webhook` - accepts shape of your schema

`ws://host:port/graphql` - publishes webhook body to client subscribers

## options
```js
{
  host: "localhost",
  port: 3000,
  routes: {
    graphql: "/graphql",
    webhook: "/webhook"
  }
}
```

---
_Source: https://npm.io/package/gsox · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
