Standard Responses
ResourcesJS exports one optional response helper: response.ok().
import { response } from "@amrachraf6690/resourcesjs";
return response.ok(UserResource.make(user));Output:
{ "success": true, "data": { "id": 1 }}Metadata
Section titled “Metadata”Resource metadata is preserved:
{ "success": true, "data": { "id": 1 }, "meta": { "version": "1.0" }}Ordinary Values
Section titled “Ordinary Values”Only branded Resource envelopes are flattened. Ordinary values are wrapped under
data, even if they already contain a data property.
response.ok({ data: "ordinary" });{ "success": true, "data": { "data": "ordinary" }}