https://github.com/unadlib/acting
🎏Acting is a tiny agent model tool.
https://github.com/unadlib/acting
model restful
Last synced: over 1 year ago
JSON representation
🎏Acting is a tiny agent model tool.
- Host: GitHub
- URL: https://github.com/unadlib/acting
- Owner: unadlib
- License: mit
- Created: 2019-03-28T03:05:07.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2019-05-17T16:58:35.000Z (about 7 years ago)
- Last Synced: 2025-03-06T21:17:09.279Z (over 1 year ago)
- Topics: model, restful
- Language: TypeScript
- Homepage:
- Size: 67.4 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Acting
[](https://travis-ci.org/unadlib/acting)
[](https://www.npmjs.com/package/acting)
Acting is a tiny agent model tool.
### Usage
To install `acting` with yarn:
```bash
yarn install acting # or npm install --save acting
```
### Example
```js
import Acting from 'acting';
const acting = new Acting({
fetch: (...args) => console.log(...args),
domains: {
admin: ['GET', 'POST'],
groups: {
method: ['DELETE'],
role: ['PUT'],
},
users: {
param: {
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: `method`)
- `withKey`: string(default: `param`)