You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
ojizero 9c170c6452
futher setup and module skeleton
1 year ago
src futher setup and module skeleton 1 year ago
test futher setup and module skeleton 1 year ago
.gitignore futher setup and module skeleton 1 year ago
.npmignore futher setup and module skeleton 1 year ago
LICENSE Initial commit 1 year ago
README.md futher setup and module skeleton 1 year ago
package-lock.json futher setup and module skeleton 1 year ago
package.json futher setup and module skeleton 1 year ago
tsconfig.json futher setup and module skeleton 1 year ago
tsconfig.spec.json futher setup and module skeleton 1 year ago

README.md

# portal > HTTP API clients ... simplified.

Installation

npm install --save @ojizero/portal

Usage

Aimed to be used as a building block for API client libraries

/// In your library or definition file
import portal from '@ojizero/portal'

const client = portal({ baseUrl: 'some.base.url' }) // Initial configuration can be passed here

// Get method without path variables
client.route('someGetMethod', { path: '/some/path' })

// Get method with path variables
client.route('someGetMethodWithParam', { path: '/some/path/:withInnerVariable' })

export default client

/* ******************* */

/// In your application
import YourClient from 'your-client-module'

const client = YourClient() // You can also pass additional options to futher configure the client

const someGetMethodPromise = client.someGetMethod() // GET http://some.base.url/some/path
const someGetMethodWithParamPromise = client.someGetMethodWithParam(5) // GET http://some.base.url/some/path/5