# awy2

> simple,small web framework

Latest version **2.1.0** (published 2019-08-11) · MIT license · 0 weekly downloads

## Install

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

## 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 | 2.1.0 |
| Published | 2019-08-11 |
| First published | 2019-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 32.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | BraveWang |
| Maintainers | ant-army |
| Keywords | awy, awy2, web, framework, http2, http/https, middleware |

## Links

- npm: https://www.npmjs.com/package/awy2
- Repository: https://github.com/master-genius/awyjs
- Homepage: https://github.com/master-genius/awyjs#readme
- Issues: https://github.com/master-genius/awyjs/issues
- npm.io page: https://npm.io/package/awy2

## 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

- 2.1.0 (latest) — 2019-08-11
- 2.0.4 — 2019-08-10
- 2.0.3 — 2019-08-09
- 2.0.2 — 2019-08-09
- 2.0.1 — 2019-08-09
- 1.3.2 — 2019-08-09
- 1.3.1 — 2019-08-08
- 1.3.0 — 2019-08-07
- 1.2.3 — 2019-08-07
- 1.2.2 — 2019-08-05
- 1.2.1 — 2019-07-26
- 1.2.0 — 2019-07-22
- 1.1.1 — 2019-04-24
- 1.1.0 — 2019-04-24
- 1.0.3 — 2019-04-02
- … 3 more at https://npm.io/package/awy2/versions

## README

### awy框架

awy2是一个基于Node.js的HTTP/2模块开发的Web框架，基于async/await关键字。


#### 支持功能
* 中间件
* 路由
* 路由分组
* 中间件按照路由规则匹配执行
* 解析Body数据
* 解析上传的文件
* 启用守护进程模式
* 配置HTTPS


#### 使用示例

``` JavaScript

const awy = require('awy2');

var ar = new awy();

ar.config.https_on = true;
ar.config.https_options.cert = '../rsa/localhost-cert.pem';
ar.config.https_options.key = '../rsa/localhost-privkey.pem';

/*
一定要注意的是：
    回调函数要写成async rr的形式。
rr是打包了request和response的对象：
    {
        req,
        res
    }
    
*/

ar.get('/', async rr => {
    rr.res.Body = 'success';        
});

ar.run('localhost', 8080);

```

```

curl 'http://localhost:8080/'

输出结果：
  success

```

#### 获取URL参数（QueryString参数）

``` JavaScript

const awy = require('awy2');

var ar = new awy();

ar.config.https_on = true;
ar.config.https_options.cert = '../rsa/localhost-cert.pem';
ar.config.https_options.key = '../rsa/localhost-privkey.pem';

ar.get('/test', async rr => {
    var {name} = rr.req.Param;
    console.log(name);
    rr.res.Body = name;
});

ar.run('localhost', 8080);

```

```

curl 'http://localhost:8080/test?name=helo'

输出结果：
  helo

```

#### 获取POST提交的数据

``` JavaScript

const awy = require('awy');

var ar = new awy();

ar.config.https_on = true;
ar.config.https_options.cert = '../rsa/localhost-cert.pem';
ar.config.https_options.key = '../rsa/localhost-privkey.pem';

ar.post('/pt', async rr => {
    var {username} = rr.req.BodyParam;
    rr.res.Body = username;
});

ar.run('localhost', 8080);

```

```

curl 'http://localhost:8080/pt' -d 'username=albert'

返回结果：
  albert

```

[完整文档](https://github.com/master-genius/awyjs/blob/master/README.md)

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