@hookcompany/feathers-client-custom-methods

️🏹 Create feathers service on client with custom methods names.

Stats

StarsIssuesVersionUpdatedCreatedSize
@hookcompany/feathers-client-custom-methods
1.0.23 years ago3 years agoMinified + gzip package size for @hookcompany/feathers-client-custom-methods in KB

Readme

Feathers Client Custom Methods

🏹 Create feathers service on client with custom methods names.

NPM version

Npm Downloads

Getting Started

Use npm:

npm install --save @hookcompany/feathers-client-custom-methods

Or use yarn:

yarn add @hookcompany/feathers-client-custom-methods

Prerequisite

Install @hookcompany/feathers-custom-methods on server (Fathers Custom Methods)

Config

Bootstrap

import feathers from '@feathersjs/feathers';
import feathersRestClient from '@feathersjs/rest-client';
import axios from 'axios';

import feathersCustomMethods from '@hookcompany/feathers-client-custom-methods';

const HTTP_URI = '<endPoint>';
const rest = feathers()
  .configure(feathersRestClient(HTTP_URI).axios(axios));

feathersCustomMethods.bootstrap(rest)
  .then(Feathers => {
    const Feeds = Feathers.service('feeds');

    Feeds.foo()
      .then(console.log)
      .catch(console.log);
  });

or

Options

import feathers from '@feathersjs/feathers';
import feathersRestClient from '@feathersjs/rest-client';
import axios from 'axios';

import feathersCustomMethods from '@hookcompany/feathers-client-custom-methods';

const HTTP_URI = '<endPoint>';
const rest = feathers()
  .configure(feathersRestClient(HTTP_URI).axios(axios))
  .configure(feathersCustomMethods());

const Feeds = rest.service('feeds', [
  'foo:find',
  'bar:find',
  'buzz:get',
  'foobar:create',
  'foobuzz:update',
  'barbuzz:patch',
  'foobarbuzz:remove'
]);

Feeds.foo()
  .then(console.log)
  .catch(console.log);

Consuming The Service Methods

You can consume the service methods, like that:

Method foo(find)

[GET] localhost:3030/users/foo

Method bar(find)

[GET] localhost:3030/users/bar

Method buzz(get)

[GET] localhost:3030/users/buzz/:id

Method foobar(create)

[POST] localhost:3030/users/foobar

Method foobuzz(update)

[PUT] localhost:3030/users/foobuzz/:id

Method barbuzz(patch)

[PATCH] localhost:3030/users/barbuzz/:id

Method foobarbuzz(remove)

[DELETE] localhost:3030/users/foobarbuzz/:id

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.