1.0.31 • Published 5 months ago

kahana-lib v1.0.31

Weekly downloads
-
License
ISC
Repository
-
Last release
5 months ago

Kahana Library

An object and reusable function library for kahana

Contents

Data Transfer Objects

Authentication

SignUpDTO

FieldTypeRequiredDescription
firstNamestringYesPlease enter your first name.
lastNamestringYesPlease enter your last name.
emailAddressstringYesPlease enter a valid email address.
phoneNumberstringNoPlease enter your phone number.
passwordstringYesPlease enter a password longer than 8 characters.

VerifyEmailDTO

FieldTypeRequiredDescription
emailAddressstringYesPlease enter a valid email address.
tokenstringYesPlease provide your verification token.

ForgotPasswordDTO

FieldTypeRequiredDescription
emailAddressstringYesPlease enter a valid email address.

SetPasswordDTO

FieldTypeRequiredDescription
tokenstringYesPlease provide your verification token.
passwordstringYesPlease enter a password longer than 8 characters.

LoginDTO

FieldTypeRequiredDescription
emailAddressstringYesPlease enter a valid email address.
passwordstringYesPlease enter your password.

LoginResponse

FieldTypeRequiredDescription
tokenstringYesAuthentication token.
twoFactorActionbooleanYesIndicates if a two-factor action is required.
messagestringNoOptional message.

Groups

CreateGroupTripDTO

FieldTypeRequiredDescription
namestringYesOops! Looks like this trip needs a name.
descriptionstringYesDon't forget to give your trip a description!
imageUrlstringNoHmm, the image URL should be a valid string if provided.
adminUserIdstringNoAdmin user should be a valid string if provided.
destinationstringYesWhere's the trip headed? Please provide a destination.
departureDateDateYesWhen does the trip start? Please provide a valid departure date.
returnDateDateYesWhen does the trip end? Please provide a valid return date.
createdAtDateNoTimestamp for when the trip was created.
updatedAtDateNoTimestamp for when the trip was last updated.
archivedbooleanNoWhether the trip is archived. Defaults to false.
deletedAtDateNoTimestamp for when the trip was deleted.

CreateInviteDTO

FieldTypeRequiredDescription
tokenstringNoPlease enter your authentication token.
tokenExpiryDateNoExpiration date of the token.
groupIdstringYesPlease select a group.
userIdstringYesWho's attempting to create this invite.
statusstringNoPlease provide a valid account type.

VerifyInviteDTO

FieldTypeRequiredDescription
tokenstringYesPlease enter your authentication token.

AcceptInviteDTO

FieldTypeRequiredDescription
tokenstringYesToken not provided. Please contact our support.
userIdstringYesUser ID not provided. Please contact our support.

UpdateGroupTripDTO

FieldTypeRequiredDescription
idstringYesPlease provide a group identifier.
(Inherits all fields from CreateGroupTripDTO)

UpdateInviteDTO

FieldTypeRequiredDescription
idstringYesPlease select an invite.
(Inherits all fields from CreateInviteDTO)

RemoveGroupMemberDTO

FieldTypeRequiredDescription
groupIdstringYesPlease select a group.
userIdstringYesPlease 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:

PropertyTypeDescription
messagestringA message describing the error to a non technical user
descriptionstringAdditional details about the error for debugging.
statusnumberHTTP status code associated with the error. Defaults to 500.
contextstringOptional context for additional information about the error.
dataanyAdditional 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" },
});
1.0.31

5 months ago

1.0.30

5 months ago

1.0.29

5 months ago

1.0.28

5 months ago

1.0.27

5 months ago

1.0.26

5 months ago

1.0.25

5 months ago

1.0.24

5 months ago

1.0.23

5 months ago

1.0.22

5 months ago

1.0.21

5 months ago

1.0.20

5 months ago

1.0.19

5 months ago

1.0.18

5 months ago

1.0.17

5 months ago

1.0.16

5 months ago

1.0.15

5 months ago

1.0.14

5 months ago

1.0.13

6 months ago

1.0.12

6 months ago

1.0.11

6 months ago

1.0.10

6 months ago

1.0.9

6 months ago

1.0.8

6 months ago

1.0.7

6 months ago

1.0.6

6 months ago

1.0.5

6 months ago

1.0.4

6 months ago

1.0.3

6 months ago

1.0.2

6 months ago

1.0.1

6 months ago

1.0.0

6 months ago