open-index/open-npm huggingface dataset:
npm package: @nostrify/db
Description: This package offers Nostrify SQL storages built on [Kysely](https://github.com/kysely-org/kysely).
Latest version: 0.39.28

# Nostrify SQL Databases

This package offers Nostrify SQL storages built on [Kysely](https://github.com/kysely-org/kysely).

Full documentation: https://nostrify.dev/store/sql

## Postgres

The `NPostgres` class is specialized for high performance in Postgres, making use of jsonb for tag queries and FTS for NIP-50 search. It contains a single `nostr_events` table with unique indexes for replaceable and parameterized replaceable events, upserting newer entries for the best performance. This implementation is used by Ditto in production and is the recommended database adapter.

## SQLite, MySQL, and others

The `NDatabase` class is a general-purpose SQL database using standard SQL. It is meant to be compatible with a variety of SQL databases, and is a good place to start if you want to use SQLite and then change to a different database later. However, it is optimized for simplicity and flexibility, not for performance.

It has a `nostr_events` table, and a separate `nostr_tags` table it joins with to resolve tag queries. Replaceable events delete older entries in a transaction before inserting new ones.

## Usage

### Postgres

```ts
import { NPostgres } from '@nostrify/db';
import { Kysely } from 'kysely';

const kysely = new Kysely(/* set up your database */);

const db = new NPostgres(kysely);
await db.migrate();
```

### SQLite, MySQL, and others

```ts
import { NDatabase } from '@nostrify/db';
import { Kysely } from 'kysely';

const kysely = new Kysely(/* set up your database */);

const db = new NDatabase(kysely);
await db.migrate();
```

## License

MIT
npm package: @nostrify/ndk
Description: This package connects [NDK](https://github.com/nostr-dev-kit/ndk) with Nostrify, allowing you to use NDK as a regular Nostrify relay.
Latest version: 0.35.24

# Nostrify ❤️ NDK

This package connects [NDK](https://github.com/nostr-dev-kit/ndk) with Nostrify, allowing you to use NDK as a regular Nostrify relay.

```ts
import NDK from '@nostr-dev-kit/ndk';
import { NDKStore } from '@nostrify/ndk';

const ndk = new NDK(/* set up NDK */);
await ndk.connect();

const relay = new NDKStore(ndk); // `NStore` compatible
```

## License

MIT
npm package: @nostrify/policies
Description: Policies allow you to prevent spam on your relay (or in your client).
Latest version: 0.36.26

# Nostrify Policies

Policies allow you to prevent spam on your relay (or in your client).

Policies inspect one event at a time, which they either accept or reject. It's up to the application to decide how to handle the result.

```ts
import {
  AntiDuplicationPolicy,
  FiltersPolicy,
  HellthreadPolicy,
  KeywordPolicy,
  PipePolicy,
  PowPolicy,
  RegexPolicy,
} from '@nostrify/policies';

const policy = new PipePolicy([
  new FiltersPolicy([{ kinds: [0, 1, 3, 5, 7, 1984, 9734, 9735, 10002] }]),
  new KeywordPolicy(['https://t.me/']),
  new RegexPolicy(/(🟠|🔥|😳)ChtaGPT/i),
  new PubkeyBanPolicy(['e810fafa1e89cdf80cced8e013938e87e21b699b24c8570537be92aec4b12c18']),
  new HellthreadPolicy({ limit: 100 }),
  new AntiDuplicationPolicy({ kv: await Deno.openKv(), expireIn: 60000, minLength: 50 }),
]);

const [_, eventId, ok, reason] = await policy.call(event);
```

Full documentation: https://nostrify.dev/policy

## License

MIT
npm package: @nostrify/react
Description: React components and hooks for Nostrify, a comprehensive Nostr framework.
Latest version: 0.5.0

# @nostrify/react

React components and hooks for Nostrify, a comprehensive Nostr framework.

## Installation

::: code-group

```sh [npm]
npx jsr add @nostrify/react
```

```sh [Deno]
deno add jsr:@nostrify/react
```

```sh [yarn]
yarn add jsr:@nostrify/react
```

```sh [pnpm]
pnpm add jsr:@nostrify/react
```

```sh [Bun]
bunx jsr add @nostrify/react
```

:::

## Usage

### NostrContext Provider

```tsx
import { NostrContext } from '@nostrify/react';
import { NRelay1 } from '@nostrify/nostrify';

function App() {
  return (
    <NostrContext.Provider
      value={{
        relay: new NRelay1('wss://relay.example.com'),
      }}
    >
      <YourApp />
    </NostrContext.Provider>
  );
}
```

### Login Provider

```tsx
import { NostrLoginProvider } from '@nostrify/react/login';

function App() {
  return (
    <NostrLoginProvider storageKey='nostrify-logins'>
      <YourApp />
    </NostrLoginProvider>
  );
}
```

### Using Hooks

```tsx
import { useNostr } from '@nostrify/react';
import { useNostrLogin } from '@nostrify/react/login';

function YourComponent() {
  const { relay } = useNostr();
  const { logins, addLogin, removeLogin } = useNostrLogin();

  // Your component logic here
}
```

## Developer Notes

This package uses a preprocess script to compile TSX files to JavaScript for Node.js compatibility.
npm package: @nostrify/strfry
Description: This package adapts [Nostrify policies](https://nostrify.dev/policy/) for use in [strfry policy plugins](https://github.com/hoytech/strfry/blob/master/docs/plugins.md).
Latest version: 0.2.10

# Nostrify Strfry Policies

This package adapts [Nostrify policies](https://nostrify.dev/policy/) for use in [strfry policy plugins](https://github.com/hoytech/strfry/blob/master/docs/plugins.md).

## Example

```ts
#!/bin/sh
//bin/true; exec deno run -A "$0" "$@"
import {
  AntiDuplicationPolicy,
  FiltersPolicy,
  HellthreadPolicy,
  KeywordPolicy,
  PipePolicy,
  PowPolicy,
  RegexPolicy,
} from '@nostrify/policies';
import { strfry } from '@nostrify/strfry';

// Create a regular policy object however you want.
const policy = new PipePolicy([
  new FiltersPolicy([{ kinds: [0, 1, 3, 5, 7, 1984, 9734, 9735, 10002] }]),
  new KeywordPolicy(['https://t.me/']),
  new RegexPolicy(/(🟠|🔥|😳)ChtaGPT/i),
  new PubkeyBanPolicy(['e810fafa1e89cdf80cced8e013938e87e21b699b24c8570537be92aec4b12c18']),
  new HellthreadPolicy({ limit: 100 }),
  new AntiDuplicationPolicy({ kv: await Deno.openKv(), expireIn: 60000, minLength: 50 }),
]);

// Call the `strfry` function at the bottom of the file.
// This hooks up to stdin/stdout and runs the policy on strfry input.
await strfry(policy);
```
npm package: @nostrify/types
Description: TypeScript types for Nostr. This package includes Nostr standardized types from the NIPs, as well as useful interfaces that promote consistency across your applications.
Latest version: 0.36.9

# Nostrify Types

TypeScript types for Nostr. This package includes Nostr standardized types from the NIPs, as well as useful interfaces that promote consistency across your applications.

The goal of this package is to create a TypeScript standard for Nostr, so that developers and library authors can create reusable components that can be easily swapped out. A lot of thought has been put into these types, so that they are simple, powerful, and feel natural to use.

It is a types-only package, so you can use it for free in any project.

```ts
import { NostrEvent, NostrFilter, NStore } from '@nostr/types';

export class MyStore implements NStore {
  async query(filters: NostrFilter[]): Promise<NostrEvent[]> {
    // Your implementation here
  }
}
```

## Naming Convention

- Types that start with `Nostr*` are standardized types from the NIPs.
- Types that start with `N*` are Nostrify types.

## Honorable Mentions

Here are a few examples of types provided by this package:

- `NostrEvent` - NIP-01 Nostr event. It is specifically not called `Event` to avoid conflicts with the built-in type.
- `NostrFilter` - NIP-01 Nostr filter.
- `NostrSigner` - NIP-07 signer interface. Nostrify contains a handful of implementations.
- `NStore` - Nostrify event storage. Can be a cache, a database, or any other storage. It returns events from Nostr filters and should implement NIP-01 functionality for replaceable events, NIP-09 deletions etc., so the event set is always valid.
- `NRelay` - Nostrify relay client. It extends NStore with a `.req` method for streaming. Single relay connections and relay pools both use this interface.
- `NPolicy` - Nostrify policy function for filtering out spam events and other unwanted content.
- `NUploader` - Nostrify file uploader. Accepts a `File` object and returns NIP-94 data. Has implementations for nostr.build and Blossom.

## License

MIT