# leafless

> Leafless ========

Latest version **0.2.3** (published 2018-03-19) · Apache-2.0 license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.2.3 |
| Published | 2018-03-19 |
| First published | 2016-06-20 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=7.6.0 |
| Dependencies | 4 |
| Unpacked size | 128.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Alloys Mila |
| Maintainers | mofax |

## Links

- npm: https://www.npmjs.com/package/leafless
- Repository: https://github.com/mofax/leafless
- Homepage: https://github.com/mofax/leafless#readme
- Issues: https://github.com/mofax/leafless/issues
- npm.io page: https://npm.io/package/leafless

## Dependencies (4)

- [mime](https://npm.io/package/mime.md) ^1.3.6
- [send](https://npm.io/package/send.md) ^0.15.3
- [parseurl](https://npm.io/package/parseurl.md) ^1.3.1
- [path-to-regexp](https://npm.io/package/path-to-regexp.md) ^1.7.0

## Recent versions

- 0.2.3 (latest) — 2018-03-19
- 0.2.2 — 2018-02-13
- 0.2.1 — 2017-09-09
- 0.2.0 — 2017-09-03
- 0.1.2 — 2017-06-09
- 0.1.1 — 2017-05-24
- 0.1.0 — 2017-05-22
- 0.0.10 — 2017-04-27
- 0.0.9 — 2017-04-26
- 0.0.8 — 2017-04-12
- 0.0.7 — 2017-02-20
- 0.0.6 — 2017-02-19
- 0.0.5 — 2017-02-09
- 0.0.4 — 2017-01-17
- 0.0.3 — 2017-01-15
- … 3 more at https://npm.io/package/leafless/versions

## README

Leafless
========

Leafless is a tiny async-await http library for [NodeJS](https://nodejs.org)  

## Installation
```bash
$ yarn add leafless
```

## Usage: Hello World
```javascript
let LL = require("leafless");
let app = new LL();

// hello world [GET]
app.route("/hello", {
  async get(ctx) {
    ctx.response.text("Hello World");
  }
})

/** a POST request to /hello returns a 405 */

// allow both POST and GET requests
app.route("/hello2", {
  async get(ctx) {
    ctx.response.text("Hello World");
  }

  // ContentType application/json
  async post(ctx) {
    ctx.response.json({ data:"Hello World"});
  }
})

// read http request body
app.route("/data", {
  async post(ctx) {
    // read request body as json
    let body = await ctx.request.json();
    if (!body.code) {
      ctx.response.status(400);
      ctx.response.json({error: "body must have code!"});
      return;
    }
    ctx.response.json({data: "everything is cool"});
  }
})

// serve a file from the filesystem as response
app.route("/data", {
  async post(ctx) {
    ctx.response.sendFile("/absolute/path/to/file");
  }
})

app.listen(8000); // listen and serve
```

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