open-index/open-npm huggingface dataset:
npm package: @inderes/ir-publications-client
Description: How to use the publications client.
Latest version: 1.0.0

# Publications client

How to use the publications client.

```javascript
// initialize the client
const publicationsClient = new PublicationsClient({
  organizations: mockOrganizations,
});

// JSON Feed
const jsonFeed = publicationsClient.toJsonFeed({ publications: mockPublications });

// JSON Feed Item
const jsonItem = publicationsClient.publicationToFeedItem({ publication: mockPublications[0] });

// NewsML 1.2 Feed
const newsml1Feed = publicationsClient.toNewsML1Feed({ publications: mockPublications });

// NewsML 1.2 Item
const newsml1Item = publicationsClient.publicationToNewsML1Item({ publication: mockPublications[0] });
```
npm package: @inderes/redis-client
Description: The RedisClient library is a TypeScript utility designed to simplify interactions with Redis databases. It provides a streamlined interface for setting, getting, and deleting data in Redis, with support for JSON data handling and schema validation using Z
Latest version: 1.2.1

## Description

The RedisClient library is a TypeScript utility designed to simplify interactions with Redis databases. It provides a streamlined interface for setting, getting, and deleting data in Redis, with support for JSON data handling and schema validation using Zod. The library also integrates custom logging capabilities to aid in debugging and operational monitoring.

## Features

- Easy configuration and initialization of Redis connections.
- Support for JSON data serialization and deserialization.
- Schema validation with Zod for robust data integrity.
- Flexible data expiry settings for various time-to-live requirements.

### Initializing the Client

First, import and initialize the RedisClient with your Redis server configuration and logger instance.

```typescript
import Logger from "@inderes/logger";
import { RedisClient, RedisClientOptions } from "./path/to/redisClient";

const options: RedisClientOptions = {
  host: "localhost",
  port: 6379,
  logger: new Logger(),
};

const client = new RedisClient(options);
```

### Setting Data

To set data in Redis, use the set method. You can specify a key, value, and optionally a schema for validation and an expiry time.

```typescript
import { z } from "zod";

const testObject = {
  name: "John Doe",
  age: 30,
};

await client.set({
  key: "user:1",
  value: testObject,
  expiry: "1h", // Data expires in 1 hour
});

const mySchema = z.object({
  name: z.string(),
  age: z.number(),
});

await redisClient.set({ key: "mySchema", value: testObject, schema: mySchema });
```

### Getting Data

Retrieve data from Redis using the get method. You can also specify a schema to validate the data upon retrieval.

```typescript
const userData = await client.get({
  key: "user:1",
  schema: userSchema, // Assuming userSchema is a Zod schema
});
```

### Deleting Data

Remove data from Redis by specifying the key in the delete method.

```typescript
const deletedCount = await client.delete({ key: "user:1" });
```