# srpc-framework

> JSON-RPC over HTTP web 'framework'

Latest version **5.0.0** (published 2024-06-19) · ISC license · 0 weekly downloads

## Install

```sh
npm install srpc-framework
pnpm add srpc-framework
yarn add srpc-framework
bun add srpc-framework
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2024-06-19 |
| First published | 2019-05-22 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 343 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | piliponful@gmail.com |
| Maintainers | piliponful |
| Keywords | web, app, http, application, framework, middleware, rack |

## Links

- npm: https://www.npmjs.com/package/srpc-framework
- Repository: https://github.com/piliponful/srpc-framework
- Homepage: https://github.com/piliponful/srpc-framework#readme
- Issues: https://github.com/piliponful/srpc-framework/issues
- npm.io page: https://npm.io/package/srpc-framework

## Dependencies (2)

- [raw-body](https://npm.io/package/raw-body.md) ^2.4.0
- [parse-json](https://npm.io/package/parse-json.md) ^4.0.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2024-06-19
- 3.1.1 — 2024-06-19
- 3.1.0 — 2024-06-19
- 4.0.3 — 2022-08-16
- 4.0.2 — 2022-06-01
- 4.0.1 — 2022-06-01
- 4.0.0 — 2022-06-01
- 3.0.0 — 2021-09-15
- 2.0.17 — 2021-04-03
- 2.0.16 — 2021-04-03
- 2.0.15 — 2021-04-03
- 2.0.14 — 2021-04-03
- 2.0.13 — 2021-04-03
- 2.0.12 — 2021-04-03
- 2.0.11 — 2021-04-03
- … 31 more at https://npm.io/package/srpc-framework/versions

## README

<p align="center"><img src="srpc-logo.png" /></p>
<p align="center">
  <a href="https://github.com/standard/standard">
    <img alt="JavaScript Style Guide" src="https://cdn.rawgit.com/standard/standard/master/badge.svg" />
  </a>
</p>
<p align="center">
  <a href="https://nodei.co/npm/srpc-framework.png?downloads=true&downloadRank=true&stars=true">
    <img alt="Link to npm package" src="https://nodei.co/npm/srpc-framework.png?downloads=true&downloadRank=true&stars=true" />
  </a>
</p>

## Usage
```js
const { createServer, createInvalidParamsError } = require('srpc-framework')

const { createServer } = require('http') // or https

const functions = { add: ({ a, b }) => a + b }
const paramsValidationFunctions = {
  add: (params) => {
    if (params instanceof Object !== true) {
      return false
    }

    return typeof params.a === number && typeof params.b === number
  }
}

const limit = '1mb'
const port = 8080
const onStartText = `Server successfully launched on port ${port}`

const { listen: startServer } = createServer({ functions, paramsValidationFunctions, limit, createServer })

startServer(port, onStartText)
```

## Overview
JSON-RPC over HTTP web 'framework'

## Specification
It adhere to [JSON-RPC 2.0](https://www.jsonrpc.org/specification)

Exceptions:
1. No id field - no point in it when over HTTP
2. No batch requests - if you need batch requests you wrote your back end poorly and need to refactor it

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