# kippa-utils

> A Utility package for functions that cuts across all kippa microservices

Latest version **1.0.22** (published 2021-11-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install kippa-utils
pnpm add kippa-utils
yarn add kippa-utils
bun add kippa-utils
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.22 |
| Published | 2021-11-29 |
| First published | 2021-10-27 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 356.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Akande Samson |
| Maintainers | iamcodehead |

## Links

- npm: https://www.npmjs.com/package/kippa-utils
- npm.io page: https://npm.io/package/kippa-utils

## Dependencies (5)

- [rxjs](https://npm.io/package/rxjs.md) ^7.4.0
- [ts-proto](https://npm.io/package/ts-proto.md) ^1.85.0
- [@grpc/grpc-js](https://npm.io/package/@grpc/grpc-js.md) ^1.4.3
- [cache-manager](https://npm.io/package/cache-manager.md) ^3.4.4
- [@nestjs/microservices](https://npm.io/package/@nestjs/microservices.md) ^8.2.0

## Recent versions

- 1.0.22 (latest) — 2021-11-29
- 1.0.21 — 2021-11-29
- 1.0.20 — 2021-11-29
- 1.0.19 — 2021-11-17
- 1.0.18 — 2021-11-17
- 1.0.17 — 2021-11-17
- 1.0.16 — 2021-11-17
- 1.0.15 — 2021-11-17
- 1.0.14 — 2021-11-17
- 1.0.13 — 2021-11-17
- 1.0.12 — 2021-11-17
- 1.0.11 — 2021-11-16
- 1.0.10 — 2021-11-16
- 1.0.9 — 2021-11-16
- 1.0.8 — 2021-11-16
- … 7 more at https://npm.io/package/kippa-utils/versions

## README

### Description

[Kippa](https://kippa.africa) utillity package.

### Installing

```bash
$ npm install kippa-utils
```

**statusCode**

 - 00 (Success)
 - 99 (Server Error)
 - 94 (Duplicate Resource)
 - 96 (Resource Not Found)


### Usage

**kippaGrpcResponse()**

```bash
import {kippaGrpcResponse} from 'kippa-utils';

const data = {
    name: "Kippa",
    mode: "dev"
};

return kippaGrpcResponse(data, statusCode.success, 'successful');
```
statusCode is "00" by default

message is "Operation Successful" by default

randomNumbergenerator(min, max)

```bash
const betweenOneAndTen = randomNumbergenerator(1, 10);

# this generates a number between 1 and 10
```

**ErrorMessages**

- isRequired(fieldName);

- isNotValid(fieldName);

- isNotBoolean(fieldName);

- isNotValidDataType(variableName, fieldName);

- isEmpty(fieldName);

- isTaken(fieldName);

- isNotprovided(fieldName);

- notAuthorized(fieldName);

- internalServerError(fieldName);

- requestTimeout(fieldName);

- alreadyExists(fieldName);

- isNotFound(fieldName);

- isRequired(fieldName);

### Example

```bash

import {ErrorMessages} from 'kippa-utils';

const user = [];

if(user.length == 0) {
    return kippaResponse(user, statusCode.NotFound, ErrorMessages.isNotFound('user'));
}

# The above show return:

# {
#     statusCode: "96",
#     message: "User not found",
#     data: []
# }

const amount = 'x';

if(typeof(amount) !== number) {
    return kippaResponse({}, statusCode.NotFound, ErrorMessages.isNotValidDataType('number', amount));
}

# The above show return:

# {
#     statusCode: "96",
#     message: "Kindly enter a valid number for amount",
#     data: {}
# }
```

---
_Source: https://npm.io/package/kippa-utils · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
