# w-restapi

> A REST API server with swagger.

Latest version **1.0.32** (published 2026-09-18) · MIT license · 0 weekly downloads

## Install

```sh
npm install w-restapi
pnpm add w-restapi
yarn add w-restapi
bun add w-restapi
```

## Health

**Score 55/100 (C)** — status: active.

Positive: no vulnerabilities; recently updated; high maintenance score.

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

## Facts

| | |
|---|---|
| Version | 1.0.32 |
| Published | 2026-09-18 |
| First published | 2019-10-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 12.3 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | yuda-lyu |
| Maintainers | semisphere |
| Keywords | package, tool, http, server, rest, api, hapi, swagger, nodejs |

## Links

- npm: https://www.npmjs.com/package/w-restapi
- Repository: https://github.com/yuda-lyu/w-restapi
- Homepage: https://github.com/yuda-lyu/w-restapi#readme
- Issues: https://github.com/yuda-lyu/w-restapi/issues
- npm.io page: https://npm.io/package/w-restapi

## Dependencies (3)

- [wsemi](https://npm.io/package/wsemi.md) ^1.9.1
- [@hapi/hapi](https://npm.io/package/@hapi/hapi.md) ^21.3.7
- [@hapi/inert](https://npm.io/package/@hapi/inert.md) ^7.1.0

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.0.32 (latest) — 2026-09-18
- 1.0.31 — 2026-09-18
- 1.0.30 — 2026-09-13
- 1.0.29 — 2026-09-05
- 1.0.28 — 2026-09-02
- 1.0.27 — 2026-09-01
- 1.0.26 — 2026-08-26
- 1.0.25 — 2026-08-21
- 1.0.24 — 2026-08-19
- 1.0.23 — 2026-08-18
- 1.0.22 — 2026-08-18
- 1.0.21 — 2026-08-18
- 1.0.20 — 2026-08-18
- 1.0.19 — 2026-08-08
- 1.0.18 — 2026-08-07
- … 18 more at https://npm.io/package/w-restapi/versions

## README

# w-restapi
A REST API server with swagger.

![language](https://img.shields.io/badge/language-JavaScript-orange.svg) 
[![npm version](http://img.shields.io/npm/v/w-restapi.svg?style=flat)](https://npmjs.org/package/w-restapi) 
[![license](https://img.shields.io/npm/l/w-restapi.svg?style=flat)](https://npmjs.org/package/w-restapi) 
[![npm download](https://img.shields.io/npm/dt/w-restapi.svg)](https://npmjs.org/package/w-restapi) 
[![npm download](https://img.shields.io/npm/dm/w-restapi.svg)](https://npmjs.org/package/w-restapi) 
[![jsdelivr download](https://img.shields.io/jsdelivr/npm/hm/w-restapi.svg)](https://www.jsdelivr.com/package/npm/w-restapi)

## Documentation
To view documentation or get support, visit [docs](https://yuda-lyu.github.io/w-restapi/global.html).

## Installation

### Using npm(ES6 module):
```alias
npm i w-restapi
```

#### Example for `w-restapi`:
> **Link:** [[dev source code](https://github.com/yuda-lyu/w-restapi/blob/master/srv.mjs)]
```alias
import WRestapi from 'w-restapi'

let routes = [
    {
        apiName: 'store',
        props: {
            'id': {
                'type': 'string',
                'description': 'id description',
            },
            'prodcname': {
                'type': 'string',
                'description': 'prodcname description',
            },
            'price': {
                'type': 'number',
                'description': 'price description',
            }
        },
    },
    {
        apiName: 'pet',
        props: {
            'id': {
                'type': 'string',
                'description': 'id description',
            },
            'petname': {
                'type': 'string',
                'description': 'petname description',
            },
            'belognname': {
                'type': 'string',
                'description': 'belognname description',
            }
        },
    },
]

function proc({ method, apiName, propName, propValue, payload, pm, req, res }) {
    //可由req內資訊做身份驗證

    //resolve
    pm.resolve(JSON.stringify({ method, apiName, propName, propValue, payload }))
    console.log(method, apiName, propName, propValue, payload)

}

new WRestapi({ routes, proc })

//view swagger: http://localhost:8080/swdoc/index.html
```

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