1.0.3 • Published 4 years ago

@hyper.io/connect v1.0.3

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Table of Contents

Getting Started

Install the @hyper.io/connect module

npm install @hyper.io/connect

Create an environment variable called HYPER

export HYPER=hyperio://u:p@test.hyper.io/svc

Use the @hyper.io/connect module in your Data Access Layer (DAL)

import hyper from '@hyper.io/connect'

async function query(selector) {
  await fetch(hyper.url('data') + '/_query', {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json',
      Authorization: `Bearer ${hyper.token()}`
    },
    body: JSON.stringify({
      selector
    })
  })
  .then(r => r.json())
}

query({ type: 'widget'}).then(console.log.bind(console))

Installation

npm install @hyper.io/connect

or

yarn add @hyper.io/connect

Features

  • url (service : string, ...paths : string) : string

This method takes a hyper service port as an argument and optional path argurments and returns a full url to access the service for an app.

Currently, hyper supports the following service ports:

  • data
  • cache
  • search
  • storage
  • queue
import hyper from '@hyper.io/connect'

console.log(hyper.url('search', '_search'))
  • token ( payload: object ) : string

This method takes no arguments and returns a token based on the hyper connection string that should give the client secure access to the hyper service.

Contributing

All contributions welcome.

License

Apache 2.0

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago