open-index/open-npm huggingface dataset:
npm package: @mp281x/realtime
Description: A library designed to handle server-sent events (SSE) with full type-safety in SvelteKit, Next.js and Astro.
Latest version: 1.0.0-4908cc4

# @mp281x/realtime

A library designed to handle server-sent events (SSE) with full type-safety in SvelteKit, Next.js and Astro.

## Features

- Full type-safety for client and frontend
- Simplified management of server-sent events.
- Seamless integration with SvelteKit, Next.js and Astro.

## Installation

```sh
npm install @mp281x/realtime
```

### CLI

Before using this package you need to run the integrated CLI to generate the types for the current project.

- the types needs to be regenerated only when a new endpoint is added or removed
- you don't need to regenerate the types if you only change the type of one of the endpoints

The easiest way to run it is to configure the project like this:

#### package.json

```json
{
	"scripts": {
		"dev": "realtime && pnpm next dev --turbo",
		"build": "realtime && pnpm next build"
	}
}
```

#### tsconfig.json

```json
{
    ...
	"include": [".codegen/sse.g.ts", ...]
}
```

### Server

- sveltekit: +server.ts
- next.js: route.ts

```ts
import { sseServer } from '@mp281x/realtime'

export const GET = sseServer(async function* () {
	for (let i = 0; true; i += 1) {
		yield { value: i }
		await new Promise(r => void setTimeout(r, 100))
	}
})

// pub/sub
import { sseServer, redisPubSub } from '@mp281x/realtime'

import { createClient } from 'redis'
export const redis = await createClient().connect()

const { iterator } = await redisPubSub<{ value: number }>(redis, 'test-channel')
export const GET = sseServer(async function* () {
	yield* iterator('*')
})
```

### Client

```ts
import { sseClient } from '@mp281x/realtime'

// Replace '/...' with your endpoint (the endpoints are typed)
sseClient('/...', x => console.log(x))
```
npm package: @mp281x/shared-config
Description: A shared configuration package for Biome and TypeScript. This package enforces strict coding standards to ensure uniform code style and prevent subtle bugs.
Latest version: 1.0.0-4d365f3

# @mp281x/shared-config

A shared configuration package for Biome and TypeScript.
This package enforces strict coding standards to ensure uniform code style and prevent subtle bugs.

## Features

- Strict Biome and TypeScript settings.
- Scripts for linting and cleaning the project

## Installation

To configure the package, use the following `package.json` or merge it with your current one:

```jsonc
{
 "name": "projectName",
 "type": "module",

 "scripts": {
    "dev": "x index.ts",
	
    "fix": "x fix",
    "test": "x test",
    "check": "x check",
    "setup": "x setup",
    "docker": "x docker"
 },

 "devDependencies": { "@mp281x/shared-config": "latest" }
}
```
Install the packages and run the setup script

```sh
pnpm i && pnpm run setup
```

## CLI

This package includes a CLI for filtering and highlighting useful information from the logs of other tools.

### Usage and Example

Prepend your command with x

```sh
pnpm x index.ts
```