Adds an example for the JS SDK that copies the structure of the other SDKs of doing:
Log action about to be performed
Log outcome/return value
OR
Log error and exit
I made the following choices here:
Usage of ESM instead of CommonJS - Personal opinion that we should be moving to this in documentation
Usage of top level await/mjs - Avoids having to use an async iiife to allow using async/await
I think we could move to a .js file with a type field in the package.json of the example if desired
No package-lock committed - It's just another file to maintain and keep in sync between the SDK repo and the generator repo, and realistically adds 0 benefit
These two choices are what primarily drove the require for the >=16.13.0 (earliest 16 LTS) value in the examples engines.node field, although there is no check here so earlier versions will error with a potentially unhelpful error (is it worth adding a check?).
[ ] I have added documentation for new/changed functionality in this PR or in a PR to openfga.dev [Provide a link to any relevant PRs in the references section above]
[x] The correct base branch is being used, if not main
[ ] I have added tests to validate that the change in functionality is working as expected
Description
Adds an example for the JS SDK that copies the structure of the other SDKs of doing:
I made the following choices here:
.js
file with atype
field in thepackage.json
of the example if desiredpackage-lock
committed - It's just another file to maintain and keep in sync between the SDK repo and the generator repo, and realistically adds 0 benefitThese two choices are what primarily drove the require for the
>=16.13.0
(earliest 16 LTS) value in the examplesengines.node
field, although there is no check here so earlier versions will error with a potentially unhelpful error (is it worth adding a check?).References
Closes out #198 JS SDK PR: https://github.com/openfga/js-sdk/issues/63
Review Checklist
main