@yagisumi/groonga-http-client
TypeScript icon, indicating that this package has built-in type declarations

0.1.0 • Public • Published

@yagisumi/groonga-http-client

HTTP Client for Groonga with axios.

NPM version install size DefinitelyTyped
Build Status Coverage percentage

Installation

$ npm i @yagisumi/groonga-http-client

Usage

  • typescript
import { createGroongaClient } from '@yagisumi/groonga-http-client'
import axios from 'axios'

async function main() {
  const client = createGroongaClient(axios, 'http://localhost:10041')
  const r1 = await client.commandAsync('status').catch(() => undefined)

  client.command('table_list', (err, data) => {
    if (err) {
      console.error(err)
    } else {
      console.log(data)
    }
  })
}
main()

API

createGroongaClient

alias: createClient

function createGroongaClient(
  axios: AxiosInstance, 
  host: string // e.g. 'http://localhost:10041'
): GroongaHttpClient

Creats a client. Same as new GroongaHttpClient(axios, host)

class GroongaHttpClient

command

command(
  command: string,
  options: object,
  callback: (err: Error, data: any) => void
): void
command(
  command: string,
  callback: (err: Error, data: any) => void
): void

Executes a command with a callback.

commandAsync

commandAsync(
  command: string,
  options: object
): Promise<any>
commandAsync(
  command: string
): Promise<any>

Executes a command and returns a promise.

License

MIT License

Readme

Keywords

Package Sidebar

Install

npm i @yagisumi/groonga-http-client

Weekly Downloads

0

Version

0.1.0

License

MIT

Unpacked Size

92.2 kB

Total Files

13

Last publish

Collaborators

  • yagisumi