1.9.0 • Published 5 months ago

@kernelsoftware/shared v1.9.0

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

Shared Project

Made using Typescript Release npm package

Library for important resources when there is a chance that these resources will be used in many projects

How to use this lib

$ npm install @kernelsoftware/shared

💻 Requirements

Before starting, make sure you've met the following requirements:

🚀 Features

This library provides a robust set of functionalities designed to assist in application development:

  • Logging: A logging system using the Logger module.
  • Base Entity: The BaseEntity offers an initial structure for your entities.
  • Base Model: The BaseModel offers an initial structure for your models.

  • Response Management: Effortlessly manage your application's responses with a variety of tools, including:

    • ApplicationResult: A generic application response manager.
    • ApplicationResultSuccess: Specifically designed for handling successful responses.
    • ApplicationResultError: For handling generic error responses.
    • ApplicationResultNotFound: To address 'Not Found' scenarios.
    • ApplicationResultUnauthorized: For handling unauthorized accesses.
    • ApplicationResultForbidden: To manage 'Access Forbidden' scenarios.
  • Currency Conversion:

    • centavosToReal: Convert centavo values (integer representation of currency) to its real (BRL) formatted string counterpart, e.g., converting 100 centavos to R$1,00.
    • realToCentavos: Convert a real (BRL) formatted string to its centavo integer representation, e.g., converting R$1,00 to 100 centavos.
  • Environment Variable Management:

    • getEnvOrThrow: Retrieve the value of a specified environment variable or throw an error if it's not set.
    • getEnvOrDefault: Retrieve the value of a specified environment variable or return a default value if it's not set.
  • HTTP Error Handling:

    • ErrorHttpHandler: Provides an implementation to handle validation errors in an HTTP context, logging the errors and returning a formatted response.
  • Base Controller:

    • BaseController: Abstract controller offering a handleResult method to convert application results into HTTP responses. Useful for keeping the responses consistent.
  • IUsecase:

    • IUsecase: Provides a contract to usecases methods.
  • Data Transfer Object (DTO) Utilities:

    • BaseDTO: Offers static validation utility for validating DTOs based on class-validator rules and converting plain objects to DTO instances.
  • Object Key Conversion Utilities:

    • toCamelCase(obj: object): Converts the keys of an object to camelCase format. Useful for standardizing object keys to camelCase before saving to databases or sending to APIs.
    • toSnakeCase(obj: object): Converts the keys of an object to snake_case format. Useful for APIs that require snake_case keys in payloads.
  • DynamoHelper: This utility class helps with common DynamoDB operations.

    • upsert(Model: ModelType<AnyItem>, data: Record<string, unknown>): Performs an upsert operation. Inserts the record if it does not exist or updates it if it does. The Model parameter specifies the DynamoDB model, and the data parameter specifies the data to be inserted or updated.
    • findOne(model: ModelType<AnyItem>, key: string, value: string): Finds a single record that matches the specified key and value. Returns null if no match is found.
1.9.0

5 months ago

1.8.13

7 months ago

1.8.12

7 months ago

1.8.11

7 months ago

1.8.10

8 months ago

1.8.9

8 months ago

1.8.8

8 months ago

1.8.7

8 months ago

1.8.6

8 months ago

1.8.5

8 months ago

1.8.4

8 months ago

1.8.3

8 months ago

1.8.2

8 months ago

1.8.1

8 months ago

1.8.0

8 months ago

1.7.0

8 months ago

1.6.0

8 months ago

1.5.1

8 months ago

1.5.0

8 months ago

1.4.2

8 months ago

1.4.1

8 months ago

1.4.0

8 months ago

1.3.0

8 months ago

1.2.1

8 months ago

1.2.0

8 months ago

1.1.0

8 months ago

1.0.0

8 months ago