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 🙏

© 2026 – Pkg Stats / Ryan Hefner

@mcsoud/types

v1.0.2

Published

Types for laravel responses

Readme

This is a minimal npm package for Laravel types and a hook for displaying a query.

If you have a suggestion or just want to help improve this package, your contributions are very welcome!

Usage

This package provides 5 types to use for the response of a Laravel request.

LaravelResponse<T, E>; LaravelSuccess; LaravelError; LaravelObject; LaravelPagination;

LaravelResponse

This is the main type that you will use to handle the response of a Laravel request. Always use this type to handle the response of a request. It will never let you access the data of the response without checking if the success property is true.

type LaravelResponse<S = unknown, E = unknown> =
  | LaravelSuccess<S>
  | LaravelError<E>
  | undefined;

const response: LaravelResponse<User, string[]> = (await axios.get("/me")).data;
if (response?.success) {
  console.log(response.data);
} else {
  console.log(response.errors ?? "Something went wrong");
}

LaravelSuccess

This type is used when the request is successful.

interface LaravelSuccess<T = unknown> {
  success: true;
  message: string;
  data: T;
}

interface User {
  id: number;
  name: string;
  email: string;
}

const success: LaravelSuccess<User> = {
  success: true,
  message: "User retrieved",
  data: {
    id: 1,
    name: "John Doe",
    email: "[email protected]",
  },
};

LaravelError

This type is used when the request is unsuccessful. Providing an array of strings as the generic type will allow you to access the different errors of the request. Note that errors is not always defined, always have a custom fallback or refer to the message key.

interface LaravelError<T extends Array<string> | unknown = unknown> {
  success: false;
  message: string;
  errors?: T extends Array<string> ? { [k in T[number]]: string[] } : T;
}

const error: LaravelError<["email", "password"]> = {
  success: false,
  message: "Something went wrong",
  errors: {
    email: ["The email is invalid"],
    password: ["The password is invalid"],
  },
};

LaravelObject

This type is used to represent the common Laravel object.

interface LaravelObject {
  id: number;
  created_at: string;
  updated_at: string;
}

interface User extends LaravelObject {
  name: string;
  email: string;
  address: string;
}

LaravelPagination

This type is used to represent a Laravel pagination. Use it inside the LaravelResponse type to handle the pagination of a request.

interface LaravelPagination<T = unknown> {
  current_page: number;
  data: T;
  next_page_url: string | null;
  total_page: number;
  prev_page_url: string | null;
}

interface Posts
  extends LaravelResponse<LaravelPagination<Post>, ["date", "page"]> {}
type DifferentPosts = LaravelPagination<Post[]>;