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

0.11.0 • Public • Published

Node.js CI

vrf-rest

REST API for vrf.

It implements REST contract for resource, for example

<rf-form
  name="Todo"
  auto 
/>

For this form vrf-rest uses following http requests:

GET /todos/:id - on load

POST /todos - on create

PATCH /todos/:id - on update

Id may be calculated through the url using idFromRoute vrf helper, or passed directly using rf-id prop.

For the form in single mode

<rf-form
  name="Todo"
  single
  auto 
/>

It serves like that:

GET /todos - on load

PATCH /todos - on update

Sometimes you need to execute action on resource without getting data, for this purpose you may use action mode:

<rf-form
  name="Todo#addComment"
  :rf-id="1"
  auto 
>
  <rf-input name="message" />
  <rf-submit />
</rf-form>

This form sends POST request to /todos/1/add_comment.

If a form contains files vrf-rest uses multiplaylod format which allows to send files and keep data types of other form elements at the same time. Example of a mixin for rails controller to support the format

module MultipayloadController
  def params
    ActionController::Parameters.new(JSON.parse(super[:_json] || '{}').deep_merge(super.except(:_json)))
  end
end

Readme

Keywords

none

Package Sidebar

Install

npm i vrf-rest

Weekly Downloads

59

Version

0.11.0

License

ISC

Unpacked Size

28.6 kB

Total Files

15

Last publish

Collaborators

  • dimailn