@kazion/node-utils
v0.11.0
Published
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.
Downloads
9
Maintainers
Readme
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
- [email protected]