Skip to content

chrisfitkin/aor-feathers-client

 
 

Repository files navigation

feathers rest Client for admin-on-rest

For using feathers with admin-on-rest.

Installation

npm install aor-feathers-client --save

Usage with stable

// in src/feathersClient.js
import feathers from 'feathers-client';

const host = 'http://localhost:3030';

export default feathers()
  .configure(feathers.hooks())
  .configure(feathers.rest(host).fetch(window.fetch.bind(window)))
  .configure(feathers.authentication({ storage: window.localStorage }));
// in src/App.js
import React from 'react';
import { Admin, Resource } from 'admin-on-rest';
import { authClient, restClient } from 'aor-feathers-client';
import feathersClient from './feathersClient';
import { PostList } from './posts';

const App = () => (
  <Admin
    authClient={authClient(feathersClient)}
    restClient={restClient(feathersClient)}
  >
    <Resource name="posts" list={PostList} />
  </Admin>
);

export default App;

Usage with Auk

// in src/feathersClient.js
import feathers from 'feathers-client';
import hooks from 'feathers-hooks';
import rest from 'feathers-rest/client';
import authentication from 'feathers-authentication-client';

const host = 'http://localhost:3030';

export default feathers()
  .configure(hooks())
  .configure(rest(host).fetch(window.fetch.bind(window)))
  .configure(authentication({
    jwtStrategy: 'jwt',
    storage: window.localStorage,
  }));
// in src/App.js
import React from 'react';
import { Admin, Resource } from 'admin-on-rest';
import { authClient, restClient } from 'aor-feathers-client';
import feathersClient from './feathersClient';
import { PostList } from './posts';

const authClientOptions = {
  storageKey: 'feathers-jwt',
  authenticate: { strategy: 'local' },
};

const App = () => (
  <Admin
    authClient={authClient(feathersClient, authClientOptions)}
    restClient={restClient(feathersClient)}
  >
    <Resource name="posts" list={PostList} />
  </Admin>
);

export default App;

License

This library is licensed under the MIT Licence, and sponsored by camba.

About

A feather rest client for admin-on-rest

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 95.9%
  • Makefile 4.1%