@hookcompany/feathers-client-custom-methods

1.0.2 • Public • Published

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

Package Sidebar

Install

npm i @hookcompany/feathers-client-custom-methods

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

9.34 kB

Total Files

11

Last publish

Collaborators

  • hileomsi
  • iagosilva96
  • rastelli
  • roganmelo