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

1.0.1 • Public • Published

layout-service

Simply create service api calling actions from JSON config

Installation

NPM

npm install layout-service
# or
yarn add layout-service
import Service from 'layout-service'

const service = Service.create(
  {
    modules: [{
      name: "test",
      baseUrl: "/api/test",
      actions: [
        {
          route: "/list",
          name: "getList",
          method: "get",
          params: ["a", "b"]
        },
        {
          route: "/{id}",
          name: "getInfo",
          method: "get",
          params: ["id"]
        },
        {
          route: "/{id}",
          name: "updateInfo",
          method: "put",
          params: ["id"]
        },
        {
          route: "",
          name: "createInfo",
          method: "post",
          params: ["a", "b"]
        }]
    }]
  }
]);

await service.test.getList({ a: 1, b: 1 });
await service.test.getInfo({ id: 1 });
await service.test.createInfo({ a: 1, b: 1 });
await service.test.putInfo({ id: 1, a: 1, b: 1 });

Readme

Keywords

Package Sidebar

Install

npm i layout-service

Weekly Downloads

3

Version

1.0.1

License

MIT

Unpacked Size

86.2 kB

Total Files

15

Last publish

Collaborators

  • yaojianpin