npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tsdl/react-query

v0.3.9

Published

TSDL React Query integration

Downloads

95

Readme

TSDL React Query integration

@tsdl/bun, @tsdl/client, @tsdl/core, @tsdl/dashboard, @tsdl/express, @tsdl/gui, @tsdl/node, @tsdl/react-query, @tsdl/server, @tsdl/tree


TSDL, short for Type-Safe Data Layer, is a transport layer designed to blur the line between client and server side. TSDL is an end-to-end http communication framework that makes your backend a type-safe library for your frontend.

👉 Installation

Example code

Server side

const router = tsdl.router({
   auth: tsdl.router({
      login: tsdl // ✓ structured and nestable routes, easily refactored
         .use(logger) // ✓ reusable and powerful middleware support
         .use(cors)
         .input(loginSchema) // ✓ Zod, Ajv, Joi, Yup etc. or custom
         .query(async ({ input }) => {
            input.username // ✓ type inferred and input schema validated
            const user = await db.findOne({
               where: { username: input.username }
            });

            if (!user) {
               // ✓ consistent and simple error handling
               throw new TSDLError(404, "oops");
            }
            // ✓ return any JS value to the client
            return user;
         }),
   }),
});

Client side

const onSubmit = async () => {
   try {
      const result = await tsdl.auth.login({
         username: form.username, // ✓ write with confidence, inputs are type safe
      });

      // ✓ correctly inferred JSON serialized type
      console.log(result);
   } catch(e) {
      // (e is unknown by default, this is just for type inference)
      if (e instanceof TSDLError) {
         // ✓ handle errors with confidence and consistency
         console.log(e.message); // "oops"
         console.log(e.code); // "Not Found"
         console.log(e.numberCode); // 404
      }
   }
}

Ready to dive in? Getting started guide

Links

Features

Replaces

  • ~~Rest APIs~~
  • ~~Express/Koa/Nest etc.~~
  • ~~GraphQL~~

Introduces

Contributing

TSDL is developed as a monorepo using Nx for cloud runs and caching as well as Lerna for package linking and publishing.

  1. Clone the repository
    git clone https://github.com/asplunds/tsdl.git tsdl
  2. Install dependencies (also initializes husky, & symlinks packages)
    npm i
  3. Start hacking! Unit tests are located in /tests. For playing, use /playground (it's git ignored but included in workspaces). You can find examples in /examples.

Docs (nextra)

  1. cd meta/docs
  2. npm run dev (assuming dependencies are installed)
  3. npm run build check that it builds
  4. npm run start preview

Publishing (access only)

Publish npm packages

  1. Run lints, build packages, bump package versions and publish
    npm run release

Detecting circular dependencies

If you suspect you have caused a circular dependency (easily done in monorepos), you can run npx madge -c in the project root.

Deploying documentation

Merge into branch preview (for preview) or branch docs for live. The CI/CD workflows will automatically build the Nextra documentation site and deploy it to Cloudflare.

Credits

TSDL was originally created by the developers at Enter Technologies, it's used internally on projects such as GyRank and markanvisning.se but was later open sourced.


This README is auto-generated