@hyper.io/connect
v1.0.3
Published
<h1 align="center">@hyper.io/connect</h1> <p align="center">@hyper.io/connect is a configuration module for hyper clients, this module gives the developer two functions: `url` and `token`, which can take a `hyperio` connection string and create the proper
Downloads
2
Readme
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:[email protected]/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