Skip to content

docs: add example repository and update documentation #36

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

Merged
merged 6 commits into from
May 27, 2025

Conversation

Yukaii
Copy link
Member

@Yukaii Yukaii commented May 27, 2025

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

  • Added a complete example project (examples/nodejs/) demonstrating key API features such as user information retrieval, note creation, content updates, and error handling. This includes a detailed README.md with setup instructions and usage examples. [1] [2]
  • Introduced an .env.example file to guide users in setting up environment variables for the example project.

Transition to ES Modules and Build System Modernization

  • Updated nodejs/package.json to use ESM by default, added exports field for dual ESM and CommonJS compatibility, and replaced tsc with Rollup for building the library. [1] [2]
  • Added a rollup.config.js file to configure ESM and CommonJS builds with source maps and external dependencies.
  • Updated tsconfig.base.json to use ESNext for both module and target, aligning with modern JavaScript standards.

API Client Enhancements

  • Introduced retry logic with exponential backoff for failed requests, ETag-based caching for note retrieval, and options for raw response handling in the API client.
  • Exported all error classes (HackMDError, HttpResponseError, etc.) individually to improve modularity and usability. [1] [2] [3]

Documentation Improvements

  • Expanded the main README.md with examples for ESM, CommonJS, and legacy import paths, as well as advanced features like retry configuration and response data handling.
  • Added a new "Examples" section to the repository's README.md to highlight the example project and its features.

Miscellaneous Updates

  • Renamed nodejs/.eslintrc.js to nodejs/.eslintrc.cjs to align with ESM conventions.
  • Updated package-lock.json and dependencies to reflect the new build system and added required plugins for Rollup. [1] [2]

…tion, response data handling, and ETag support
@Yukaii Yukaii changed the title docs: enhance README with advanced features including retry configuration, response data handling, and ETag support docs: add example repository and update documentation May 27, 2025
@Yukaii Yukaii mentioned this pull request May 27, 2025
@Yukaii Yukaii linked an issue May 27, 2025 that may be closed by this pull request
@Yukaii Yukaii merged commit ed9db81 into develop May 27, 2025
2 checks passed
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.

Usage Docmentation missing
1 participant