telegra.ph
telegra.ph copied to clipboard
All the TypeScript, Better Docs, More Flexibility, and Fewer Vulnerabilities
Hey there! This PR tackles the improvements I suggested in issue #6. Here's a breakdown of what's been done:
-
Switched to TypeScript: The entire codebase is now in TypeScript, offering better type checks and a smoother experience for developers. I noticed the library uses TravisCI, which I'm not too familiar with, so I haven't included anything for compiling TypeScript. However, I'm more than willing to help set this up if needed.
-
Added JSDoc Comments: No more switching between code and documentation. Now, all the documentation is right in the editor.
-
No More CommonJS: The codebase has been updated to use modern ECMAScript syntax, making it more streamlined and up-to-date.
-
New
src
Directory: I've reorganized the source files into asrc
folder for better structure and clarity. -
New HTTP Client Interface: I've introduced a
Client
interface for HTTP operations. Any class implementing this interface can be used as the HTTP client. Two implementations are provided: one based on Node'sHTTPS
module and another on thefetch
API. These can be imported fromtelegra.ph/clients
. TheHTTPS
client is the default if no other client is specified inoptions.client
. This change also means droppingisomorphic-fetch
, addressing its security vulnerabilities. -
Included
LICENSE
andreadme.md
in Package: It's standard practice to include these files in the package distribution, ensuring that users have access to full documentation and licensing information right off the bat. -
Updated README: The README now showcases ECMAScript syntax and includes an example for injecting an HTTP client.
I've thoroughly tested these changes, and everything seems to be in top shape. This update should significantly enhance the library's robustness, security, and usability. Eager to hear your thoughts! Resolves #6.