docs: add example repository and update documentation #36
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request introduces a comprehensive example project for the HackMD API client and modernizes the codebase by transitioning to ES Modules (ESM) and adding support for both ESM and CommonJS builds. It also enhances the API client's features with retry logic, ETag-based caching, and improved error handling. Below are the most significant changes grouped by theme:
Example Project for HackMD API Client
examples/nodejs/) demonstrating key API features such as user information retrieval, note creation, content updates, and error handling. This includes a detailedREADME.mdwith setup instructions and usage examples. [1] [2].env.examplefile to guide users in setting up environment variables for the example project.Transition to ES Modules and Build System Modernization
nodejs/package.jsonto use ESM by default, addedexportsfield for dual ESM and CommonJS compatibility, and replacedtscwith Rollup for building the library. [1] [2]rollup.config.jsfile to configure ESM and CommonJS builds with source maps and external dependencies.tsconfig.base.jsonto useESNextfor bothmoduleandtarget, aligning with modern JavaScript standards.API Client Enhancements
HackMDError,HttpResponseError, etc.) individually to improve modularity and usability. [1] [2] [3]Documentation Improvements
README.mdwith examples for ESM, CommonJS, and legacy import paths, as well as advanced features like retry configuration and response data handling.README.mdto highlight the example project and its features.Miscellaneous Updates
nodejs/.eslintrc.jstonodejs/.eslintrc.cjsto align with ESM conventions.package-lock.jsonand dependencies to reflect the new build system and added required plugins for Rollup. [1] [2]