Conceiving a Modern JavaScript HTTP Client

Hello, fellow developers! Today, I'm excited to share the inception of a project that's been brewing in my mind for quite some time – Dvori, a modern JavaScript HTTP client designed to bring simplicity, flexibility, and power to making HTTP requests. My journey into developing Dvori was born out of frustration and limitation; frustration with the existing solutions that often felt too rigid or cumbersome for my needs, and limitation in their ability to adapt to different environments or use cases seamlessly.

Conceptualization

The core idea behind Dvori is to wrap the native fetch API in a way that amplifies its strengths while mitigating its weaknesses. I envisioned a tool that not only simplifies making HTTP requests but also introduces a level of composability and extensibility that I found lacking. In essence, Dvori aims to be the Swiss Army knife for web requests, adaptable to any situation without breaking a sweat.

Design Principles

Embarking on this journey, I set a few key design principles to guide Dvori's development:

  • Functional Over Class-based: Inspired by the elegance and simplicity of functional programming, I decided early on to eschew classes in favor of pure functions. This choice aims to keep the library lightweight and intuitive.
  • Composability at Its Core: Drawing inspiration from React's hooks, Dvori leverages "composables" – middleware-like functions that enhance the client's capabilities, from adding OAuth tokens to handling retries and logging.
  • Modern Async/Await and TypeScript Support: Embracing the modern JavaScript landscape, Dvori is built with async/await and full TypeScript support, ensuring type safety and developer-friendly code.
  • Universal Compatibility: In today's diverse JavaScript environment, a tool that works only in the browser or only in Node.js isn't enough. Dvori is designed to run everywhere – browsers, Node.js, Deno, and beyond.

Initial Architecture Discussion

The architecture of Dvori centers around two key functions: defineClient and defineComposable. These functions are the heart and soul of Dvori, enabling developers to easily configure their HTTP client and craft custom composables for any scenario. This setup not only enhances the library's flexibility but also its ease of use, making HTTP requests a breeze across different projects and APIs.

Wrap-Up

Reflecting on the initial planning and conceptual phase, I'm filled with a mix of excitement and anticipation. The road ahead is undoubtedly challenging, but the prospect of creating a tool that could simplify and empower developers' work is incredibly motivating. Stay tuned for the next post, where I'll dive deeper into turning these concepts into code, laying the foundation for Dvori's functionality.

Until next time, happy coding!

Tags