# piserve

> say server

Latest version **1.1.3** (published 2022-10-27) · GPLv3 license · 0 weekly downloads

## Install

```sh
npm install piserve
pnpm add piserve
yarn add piserve
bun add piserve
```

Provides the command `piserve`.

## Health

**Score 40/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2022-10-27 |
| First published | 2022-07-30 |
| Weekly downloads | 0 |
| License | GPLv3 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 5 |
| Unpacked size | 21.6 KB |
| Known vulnerabilities | 0 (+4 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Snowstar Miao |
| Maintainers | snomiao |
| Keywords | cli |

## Links

- npm: https://www.npmjs.com/package/piserve
- Repository: https://github.com/snomiao/js.git#master
- Homepage: https://github.com/snomiao/js/tree/master/packages/piserve#readme
- Issues: https://github.com/snomiao/js/issues?q=is%3Aissue+is%3Aopen+piserve
- npm.io page: https://npm.io/package/piserve

## Dependencies (5)

- [yargs](https://npm.io/package/yargs.md) 17.6.0
- [express](https://npm.io/package/express.md) 4.18.2
- [body-parser](https://npm.io/package/body-parser.md) 1.20.1
- [@types/express](https://npm.io/package/@types/express.md) 4.17.14
- [@types/body-parser](https://npm.io/package/@types/body-parser.md) ^1.19.2

## Alternatives

- [@salesforce/cli](https://npm.io/package/@salesforce/cli.md) — 389.7K weekly downloads
- [@mintlify/cli](https://npm.io/package/@mintlify/cli.md) — 208.9K weekly downloads
- [@grafana/e2e-selectors](https://npm.io/package/@grafana/e2e-selectors.md) — 128.7K weekly downloads
- [mintlify](https://npm.io/package/mintlify.md) — 112.0K weekly downloads
- [@intlayer/cli](https://npm.io/package/@intlayer/cli.md) — 22.8K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2022-10-27
- 1.1.0 — 2022-07-30

## README

# PiServer

Dead simple piping server connecting two universe between HTTP-requests and stdio-CLI. Worked line by line.

## Usage

```shell
piserve | snosay --voice "Microsoft David Desktop"
```

```shell

# sending text to stdout
curl http://localhost:25971/ -d "Hello, World" -H "content-type: text/plain"
curl http://localhost:25971/text/Hello,%20World
curl http://localhost:25971/?text=Hello,+World
curl http://localhost:25971/ -d "{""text"":""Hello, World""}" -H "content-type: application/json"

# stop server
curl http://localhost:25971/stop
```

## Example Scenarios

While I receive lots of messages from my gf. I want know what she's talking about as soon as possible, even without switching into my telegram app. So I made this to SPEAK the latest message from telegram.

1. Run command to setup an speaking server

```batch
piserve | snosay --voice "Microsoft David Desktop"
```

1. Copy and paste the this userscript to your tampermonkey

```js
// ==UserScript==
// @name               Telegram Speaker
// @namespace          snomiao@gmail.com
// @author             snomiao@gmail.com
// @version            0.0.1
// @description        Speak telegram
// @match              https://*.telegram.org/z/
// @grant              none
// @run-at             document-start
// @license            GPL-3.0+
// @supportURL         https://github.com/snomiao/userscript.js/issues
// @contributionURL    https://snomiao.com/donate
// ==/UserScript==
//
// Prepare scripts sample:
//
// npm i -g piserve snosay
// piserve | snosay --voice "Microsoft Huihui Desktop"
//
const lastMsg = () =>
  [...document.querySelectorAll(".Message:not(.own) .text-content")]
    .map((e) => e.textContent)
    .reverse()[0];
const say = (s) => s && fetch("http://localhost:25971/?text=" + encodeURIComponent(s));
const chagnedFilterMaker = (init) => (e) => e !== init ? (init = e) : undefined;
const changedFilter = chagnedFilterMaker("");
const looper = () => (say(changedFilter(lastMsg())), 1);
while (looper()) await new Promise((r) => setTimeout(r, 1000));
```

## TODO

- [x] Should never run any command by http requests
- [ ] Read stdin by http requests
- [ ] Add host and port options
- [ ] Sending binary by base64
- [ ] Files upload or download

## Reference

- [https://www.npmjs.com/package/stdserve](https://www.npmjs.com/package/stdserve)

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