0.11.0 • Published 3 months ago

@kazion/node-utils v0.11.0

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

Node Utils

Description

This is a collection of utilities when create Rest or Graphql apis. It is a work in progress and will be updated as I add more functionality.

Installation

pnpm add @kazion/node-utils
yarn add @kazion/node-utils

Usage

import { hashPassword } from "@kazion/node-utils";

const hashedPassword = await hashPassword("password");

Functions

createGraphqlTestClient

Creates a test client for testing graphql resolvers.

import { createGraphqlTestClient } from "@kazion/node-utils";

const { query, mutate } = createGraphqlTestClient(schema);

formatZodError

Formats zod errors into a readable format.

import { formatZodError } from "@kazion/node-utils";

const formattedError = formatZodError(error);

logger

Creates a logger.

import { logger } from "@kazion/node-utils";

const log = logger("my-logger");

createToken

Creates a jwt token.

import { createToken } from "@kazion/node-utils";

const token = createToken({ id: 1 });

decodeToken

Decodes a jwt token.

import { decodeToken } from "@kazion/node-utils";

const decodedToken = decodeToken(token);

verifyToken

Verifies a jwt token.

import { verifyToken } from "@kazion/node-utils";

const decodedToken = verifyToken(token);

hashPassword

Hashes a password using bcrypt.

import { hashPassword } from "@kazion/node-utils";

const hashedPassword = await hashPassword("password");

comparePassword

Compares a password to a hashed password using bcrypt.

import { comparePassword } from "@kazion/node-utils";

const isPasswordValid = await comparePassword("password", hashedPassword);

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

Author

  • Patrick Kabwe
  • patrickckabwe@gmail.com
0.11.0

3 months ago

0.9.0

7 months ago

0.8.0

7 months ago

0.7.0

7 months ago

0.6.0

7 months ago

0.5.0

7 months ago

0.4.0

7 months ago

0.3.0

7 months ago

0.2.0

7 months ago

0.1.0

7 months ago