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

@naveen-g09/zod-medium-types

v1.0.1

Published

`@naveen-g09/zod-medium-types` is an NPM module designed to facilitate the use of Zod types for authentication in both frontend and backend applications. By using this package, you can ensure consistent type validation across your entire application, redu

Downloads

4

Readme

@naveen-g09/zod-medium-types

Overview

@naveen-g09/zod-medium-types is an NPM module designed to facilitate the use of Zod types for authentication in both frontend and backend applications. By using this package, you can ensure consistent type validation across your entire application, reducing the risk of mismatched expectations between client and server.

Features

  • Provides Zod types for common authentication scenarios.
  • Ensures consistent type validation on both frontend and backend.
  • Simplifies the process of maintaining validation logic across your application.

Installation

To get started with @naveen-g09/zod-medium-types, you need to install the package via npm:

npm install @naveen-g09/zod-medium-types

Usage

Frontend

Import the inferred types for signing in and signing up:

import { SignupInput, signupInput } from "@naveen-g09/zod-medium-types";

Backend

Import the types for signing in and signing up, and use them for validation:

import { signInInput, signupInput } from "@naveen-g09/zod-medium-types";

userRouter.post('/signup', async (c) => {
    const body = await c.req.json();
    const { success } = signInInput.safeParse(body);
    if (!success) {
        // Handle validation error
    }
    // Proceed with your signup logic
});

Examples

Frontend

Here's an example of how you might use the types in a frontend application:

import { SignupInput, signupInput } from "@naveen-g09/zod-medium-types";

// Example signup function
const handleSignup = async (data) => {
    const validationResult = signupInput.safeParse(data);
    if (!validationResult.success) {
        // Handle validation error
    } else {
        // Proceed with sending data to backend
    }
};

Backend

An example of using the types in a backend route:

import { signInInput, signupInput } from "@naveen-g09/zod-medium-types";

userRouter.post('/signup', async (c) => {
    const body = await c.req.json();
    const { success, error } = signupInput.safeParse(body);
    if (!success) {
        // Handle validation error
        return c.res.status(400).send(error.errors);
    }
    // Proceed with your signup logic
});

Conclusion

@naveen-g09/zod-medium-types provides a simple yet powerful way to ensure type-safe authentication across both frontend and backend applications. By using this package, you can reduce the risk of inconsistencies and streamline your validation logic.

For more information and detailed documentation, visit the NPM page.