Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(js-sdk): add example js project #305

Merged
merged 2 commits into from
Feb 7, 2024
Merged

feat(js-sdk): add example js project #305

merged 2 commits into from
Feb 7, 2024

Conversation

ewanharris
Copy link
Member

@ewanharris ewanharris commented Feb 6, 2024

Description

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?).

References

Closes out #198
JS SDK PR: openfga/js-sdk#63

Review Checklist

  • I have clicked on "allow edits by maintainers".
  • 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]
  • 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

@ewanharris ewanharris requested a review from a team as a code owner February 6, 2024 16:52
@ewanharris ewanharris requested a review from rhamzeh February 7, 2024 10:49
@ewanharris ewanharris added this pull request to the merge queue Feb 7, 2024
Merged via the queue into main with commit 77f822b Feb 7, 2024
13 checks passed
@ewanharris ewanharris deleted the feat/js-example branch February 7, 2024 11:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants