# lighteral

> This is a library which you can use to define your routes as template literals. It uses express underneath.

Latest version **1.0.2** (published 2018-02-04) · MIT license · 0 weekly downloads

## Install

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

## 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 | 1.0.2 |
| Published | 2018-02-04 |
| First published | 2018-02-03 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=6 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Linus Gubenis |
| Maintainers | elgubenis |
| Keywords | express, literal |

## Links

- npm: https://www.npmjs.com/package/lighteral
- npm.io page: https://npm.io/package/lighteral

## Dependencies (1)

- [express](https://npm.io/package/express.md) ^4.16.2

## Recent versions

- 1.0.2 (latest) — 2018-02-04
- 1.0.1 — 2018-02-03
- 1.0.0 — 2018-02-03

## README

# lighteral

This is a library which you can use to define your routes as template literals. It uses express underneath.

## Install

```sh
npm i lighteral
```

## Use

```js
const { Server, Router } = require('lighteral');

const router = new Router();

const sendHello = (req, res) => {
  res.end('hello');
};

router.get`
  /
  ${sendHello}
`;

const server = new Server({ routers: [router] });

server.listen(3000, () => {
  console.log(`http://127.0.0.1:3000`);
});
```

You can also define a prefix for the routes per router:

```js
const { Server, Router } = require('lighteral');

const router = new Router('/api');

...
```

Currently the following methods are supported: use, get, post, put, patch, delete, options, all.

Note: express middleware should work, e.g. cors:

```js
const { Server, Router } = require('lighteral');
const cors = require('cors');

const router = new Router('/api');

router.post`
  /contacts
  ${cors()}
  ${(req, res, next) => res.end('hello')}
`

...
```

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