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

kahana-lib

v1.0.36

Published

An object and reusable function library for kahana

Downloads

225

Readme

Kahana Library

An object and reusable function library for kahana

Contents

Data Transfer Objects

Authentication

SignUpDTO

| Field | Type | Required | Description | | -------------- | -------- | -------- | ------------------------------------------------- | | firstName | string | Yes | Please enter your first name. | | lastName | string | Yes | Please enter your last name. | | emailAddress | string | Yes | Please enter a valid email address. | | phoneNumber | string | No | Please enter your phone number. | | password | string | Yes | Please enter a password longer than 8 characters. |

VerifyEmailDTO

| Field | Type | Required | Description | | -------------- | -------- | -------- | --------------------------------------- | | emailAddress | string | Yes | Please enter a valid email address. | | token | string | Yes | Please provide your verification token. |

ForgotPasswordDTO

| Field | Type | Required | Description | | -------------- | -------- | -------- | ----------------------------------- | | emailAddress | string | Yes | Please enter a valid email address. |

SetPasswordDTO

| Field | Type | Required | Description | | ---------- | -------- | -------- | ------------------------------------------------- | | token | string | Yes | Please provide your verification token. | | password | string | Yes | Please enter a password longer than 8 characters. |

LoginDTO

| Field | Type | Required | Description | | -------------- | -------- | -------- | ----------------------------------- | | emailAddress | string | Yes | Please enter a valid email address. | | password | string | Yes | Please enter your password. |

LoginResponse

| Field | Type | Required | Description | | ----------------- | --------- | -------- | --------------------------------------------- | | token | string | Yes | Authentication token. | | twoFactorAction | boolean | Yes | Indicates if a two-factor action is required. | | message | string | No | Optional message. |

Groups

CreateGroupTripDTO

| Field | Type | Required | Description | | --------------- | --------- | -------- | ---------------------------------------------------------------- | | name | string | Yes | Oops! Looks like this trip needs a name. | | description | string | Yes | Don't forget to give your trip a description! | | imageUrl | string | No | Hmm, the image URL should be a valid string if provided. | | adminUserId | string | No | Admin user should be a valid string if provided. | | destination | string | Yes | Where's the trip headed? Please provide a destination. | | departureDate | Date | Yes | When does the trip start? Please provide a valid departure date. | | returnDate | Date | Yes | When does the trip end? Please provide a valid return date. | | createdAt | Date | No | Timestamp for when the trip was created. | | updatedAt | Date | No | Timestamp for when the trip was last updated. | | archived | boolean | No | Whether the trip is archived. Defaults to false. | | deletedAt | Date | No | Timestamp for when the trip was deleted. |

CreateInviteDTO

| Field | Type | Required | Description | | ------------- | -------- | -------- | --------------------------------------- | | token | string | No | Please enter your authentication token. | | tokenExpiry | Date | No | Expiration date of the token. | | groupId | string | Yes | Please select a group. | | userId | string | Yes | Who's attempting to create this invite. | | status | string | No | Please provide a valid account type. |

VerifyInviteDTO

| Field | Type | Required | Description | | ------- | -------- | -------- | --------------------------------------- | | token | string | Yes | Please enter your authentication token. |

AcceptInviteDTO

| Field | Type | Required | Description | | -------- | -------- | -------- | ------------------------------------------------- | | token | string | Yes | Token not provided. Please contact our support. | | userId | string | Yes | User ID not provided. Please contact our support. |

UpdateGroupTripDTO

| Field | Type | Required | Description | | ----------------------------------------------- | -------- | -------- | ---------------------------------- | | id | string | Yes | Please provide a group identifier. | | (Inherits all fields from CreateGroupTripDTO) |

UpdateInviteDTO

| Field | Type | Required | Description | | -------------------------------------------- | -------- | -------- | ------------------------ | | id | string | Yes | Please select an invite. | | (Inherits all fields from CreateInviteDTO) |

RemoveGroupMemberDTO

| Field | Type | Required | Description | | --------- | -------- | -------- | ---------------------- | | groupId | string | Yes | Please select a group. | | userId | string | Yes | Please select a user. |

Exceptions

Base Exception: KahanaException

Description

The KahanaException class serves as the base exception class for all custom exceptions. It provides a structured way to handle errors with the following properties:

| Property | Type | Description | | ------------- | -------- | -------------------------------------------------------------- | | message | string | A message describing the error to a non technical user | | description | string | Additional details about the error for debugging. | | status | number | HTTP status code associated with the error. Defaults to 500. | | context | string | Optional context for additional information about the error. | | data | any | Additional data or payload relevant to the error. |


Derived Exceptions

Each derived exception extends KahanaException, providing more specific error scenarios. All inherited properties (message, description, status, context, and data) are available for each exception.

InvalidCredentialsException

Represents an error caused by invalid login credentials.


InvalidUserException

Represents an error caused by an invalid user.


InactiveUserException

Represents an error caused by attempting to interact with an inactive user.


IncompleteProcessException

Represents an error caused by an incomplete process or workflow.


InvalidAuthorizationException

Represents an error caused by invalid authorization details.


ExpiredAuthorizationException

Represents an error caused by expired authorization.


InvalidPayloadException

Represents an error caused by an invalid payload in a request.


DatabaseProcessException

Represents an error caused by issues during database operations.


MessagingException

Represents an error caused by messaging system failures (e.g., email or SMS).


ThirdPartyIntegrationException

Represents an error caused by a failure in third-party integrations.


ResourceNotFoundException

Represents an error caused by a requested resource not being found.


ResourceExistsException

Represents an error caused by attempting to create a resource that already exists.


UnauthorizedResourceActionException

Represents an error caused by unauthorized actions on a resource.


ExpiredResourceException

Represents an error caused by using an expired resource.


Usage

To throw an exception, create an instance of any of the classes and provide an ErrorContent object.

throw new InvalidCredentialsException({
  message: "Invalid credentials",
  description: "The username or password provided is incorrect.",
  status: 401,
  context: "AuthenticationService",
  data: { attemptedUserId: "12345" },
});