DEV Community

Jack Ecuyer
Jack Ecuyer

Posted on

๐Ÿš€ Building a TypeScript SDK for the Hevy API โ€“ Dev Log #1

Hey everyone ๐Ÿ‘‹

I've decided to start sharing weekly updates about what Iโ€™m building,
learning, and overcoming as a software developer.

๐—ช๐—ต๐˜†?
To track and share what Iโ€™m learning, stay consistent with my personal projects, and connect with others in the tech community.

๐Ÿ›  This first post covers the past couple of weeks as Iโ€™ve kicked off a new project:

๐Ÿ’ก ๐—ง๐—ต๐—ฒ ๐—ฃ๐—ฟ๐—ผ๐—ท๐—ฒ๐—ฐ๐˜ - ๐—›๐—ฒ๐˜ƒ๐˜† ๐—ฆ๐——๐—ž (https://github.com/JackEcuyer/hevy-sdk/)
I'm building a TypeScript SDK for the Hevy API, to be compatible with Node.js, JavaScript frameworks, and browsers. I chose to build this because of my love for the Hevy app, which I use to track all of my workouts (https://www.hevyapp.com/). I hope to expand the Hevy API ecosystem while improving my TypeScript skills.

โœ… ๐—›๐—ถ๐—ด๐—ต๐—น๐—ถ๐—ด๐—ต๐˜๐˜€ ๐—ฆ๐—ผ ๐—™๐—ฎ๐—ฟ
โ€ข Set up GitHub repository and version control
โ€ข Configured TypeScript to build npm package for CommonJS & ES Modules
โ€ข Developed HevyClient class for SDK interaction
โ€ข Implemented API routines to retrieve & create workout data
โ€ข Integrated Zod for schema validation when posting workouts
โ€ข Setup Jest for SDK testing
โ€ข Improved error handling with user-friendly API & validation error formatting
โ€ข Installed and configured ESLint for code consistency
โ€ข Set up Husky for pre-commit testing & linting

๐Ÿ“š ๐—ช๐—ต๐—ฎ๐˜ ๐—œโ€™๐˜ƒ๐—ฒ ๐—Ÿ๐—ฒ๐—ฎ๐—ฟ๐—ป๐—ฒ๐—ฑ
โ€ข How to configure TypeScript for both CommonJS and ES Modules
โ€ข Best practices for creating reusable and modular SDK classes (e.g. HevyClient)
โ€ข Integrating Zod for data validation and ensuring strong API request handling
โ€ข Writing effective tests for SDK functionality using Jest
โ€ข Handling and presenting API and validation errors in a user-friendly way
โ€ข Configuring ESLint to maintain consistent code quality and style
โ€ข Using Husky for automating pre-commit checks to ensure clean code
โ€ข Using the Git CLI to fix incorrect commits to Github

โš ๏ธ ๐—–๐—ต๐—ฎ๐—น๐—น๐—ฒ๐—ป๐—ด๐—ฒ๐˜€
โ€ข ESLint v9 configuration was tricky, as the new format required importing plugin modules. However, using the TypeScript ESLint package made this easier.
โ€ข I made a couple of incorrect git commits that were pushed to the remote Github repository, meaning I had to learn to correctly use the Git CLI to fix the commit history.
โ€ข While testing with ts-node, I ran into ESM syntax errors, which helped me understand the differences between ESM and CommonJS in Node.js.

๐Ÿ”œ ๐—ก๐—ฒ๐˜…๐˜ ๐—ฆ๐˜๐—ฒ๐—ฝ๐˜€
Next steps include improving test coverage by integrating mock fetch requests into Jest, adding prettier and JSDoc, and refining type checking.

If youโ€™re into learning new technologies, building personal projects, or are passionate about software - follow along!

Iโ€™ll be posting an update every week, within reason. Some weeks, circumstances may mean I canโ€™t make a progress post, but Iโ€™ll keep it as consistent as I can. Happy to connect ๐Ÿ‘‡

Top comments (0)