acting
TypeScript icon, indicating that this package has built-in type declarations

2.0.3 • Public • Published

Acting

Travis npm

Acting is a tiny agent model tool.

Usage

To install acting with yarn:

yarn install acting # or npm install --save acting 

Example

import Acting from 'acting';
 
const acting = new Acting({
  fetch: (...args) => console.log(...args),
  domains: {
    admin: ['GET', 'POST'],
    groups: {
      _self: ['DELETE'],
      role: ['PUT'],
    },
    users: {
      _with: {
        books: ['GET'],
      }
    }
  }
});
 
await acting.admin.get({ params: { a: 1 } });
await acting.admin.post({ body: { foo: 'bar'} });
await acting.groups.delete({ params: { b: 1 }, body: 'testbody' });
await acting.groups.role.put();
await acting.users(10).books.get();

console.log results:

{ path: '/admin?a=1', method: 'GET' }
{ path: '/admin', method: 'POST' } { foo: 'bar' }
{ path: '/groups?b=1', method: 'DELETE' } 'testbody'
{ path: '/groups/role', method: 'PUT' }
{ path: '/users/10/books', method: 'GET' }

Options

  • root: string
  • domains: object
  • fetch: function
  • selfKey: string(defalt: _self)
  • withKey: string(default: _with)

Readme

Keywords

Package Sidebar

Install

npm i acting

Weekly Downloads

2

Version

2.0.3

License

MIT

Unpacked Size

160 kB

Total Files

10

Last publish

Collaborators

  • unadlib