open-index/open-npm huggingface dataset:
npm package: @isimisi/adonis-sse
Description: Adonis SSE plugin
Author: isimisi
Latest version: 0.0.12

# SSE Plugin for AdonisJS v5

This plugin is an updated version of adonis-sse from the following repository https://github.com/stitchng/adonis-sse 

## Getting Started

```
npm i @isimisi/adonis-sse
```
```
yarn add @isimisi/adonis-sse
```

## Configure
```sh
node ace configure @isimisi/adonis-sse
```

## Register

Register the following middleware inside `start/kernel.js`

 ```ts
 Server.middleware.registeredNamed({
    sse: () => import ("@ioc:isimisi/SSE")
 })
 ```

 > or optionally register it as a gloabl middleware

## Usage

```ts
Route.get("/sse", ({ sse }) => {
    sse.send({ message: "To the moon!🚀" });
}).middleware(["sse"])
```

### Connecting in React
```ts
import { useEffect, useState } from "react";

function MyComponent() {
    const [message, setMessage] = useState("");

    useEffect(() => {
        const eventSource = new EventSource("http://localhost:3333/sse");

        eventSource.addEventListener("message", (event) => {
            const data = JSON.parse(event.data); // { message: "To the moon!🚀" }
            setMessage(data.message);
        }, false)

        return () => eventSource.close();
    }, [])

    return(
        <div>{message}</div>
    )
}

export default MyComponent
```

## Disclamer

I have not created tests via. japa but I have tested the functionallity. Please feel free to report any issues.
npm package: @isimisi/sse.ts
Description: EventSource rewritten from sse.js and fetch api
Author: isimisi
Latest version: 0.0.2

# sse.ts
> this project was inspired by sse.js

- [sse.ts](#ssets)
  - [usage in react](#usage-in-react)
  - [API reference](#api-reference)

## installation
```
yarn add @isimisi/sse.ts
```


## usage in react
```ts
export default function MyComponent() {
    const [source, setSource] = useState<Source | null>(null)
    const [message, setMessage] = useState<string>("")

    useEffect(() => {
        const src = Source.get('http://localhost:3333/sse')

        setSource(src);

        return () => {
            src.close()
        }
    }, [])

    useEffect(() => {
        if (source) {
            source.on('message', e => {
                setMessage(e.data.message);
            })
        }

        return () => {
            if (source) {
                source.off('message')
            }
        }
    }, [source])

    return <div>{message}</div>
};

```

## API reference

| Type   | Method      | returns |            args        |                                    |        |
|--------|-------------|---------|--------------------|------------------------------------|--------|
| static | Source.get  | Source  | url: string \| URL | config                             |        |
| static | Source.post | Source  | url: string \| URL | body: object                       | config |
| public | source.on   | void    | event: string      | listener: (e: SourceEvent) => void |        |
| public | source.off  | void    | event: string      |                                    |        |
| public | source.close  | void    |      |                                    |        |

| Type        | Interface                                                                                                           |
|-------------|---------------------------------------------------------------------------------------------------------------------|
| Config      | { <br>  headers?: Record<string, string \| number \| boolean>, <br>  withCredentials?: boolean <br>}                 |
| SourceEvent | extends CustomEvent <br>{ <br>  data: any, <br>  id?: string, <br>  source?: Source, <br>  readyState?: number<br>} |
npm package: @isimmons/create-app
Description: Create an app from my starter template
Author: Ian Simmons
Latest version: 1.0.3

**create-app**

Create an app from my starter template, [Thing-1](https://github.com/isimmons/thing-1)

## Installation

```bash
npx @isimmons/create-app [app-name]
```

## Usage

Whatever you want to build.