# vien-simple-router

> ### Install the npm package from terminal ``` npm i --S vien-simple-router ```

Latest version **1.3.1** (published 2016-07-26) · ISC license · 0 weekly downloads

## Install

```sh
npm install vien-simple-router
pnpm add vien-simple-router
yarn add vien-simple-router
bun add vien-simple-router
```

## 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.3.1 |
| Published | 2016-07-26 |
| First published | 2016-07-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | vienly |

## Links

- npm: https://www.npmjs.com/package/vien-simple-router
- Repository: https://github.com/vienly/router
- Homepage: https://github.com/vienly/router#readme
- Issues: https://github.com/vienly/router/issues
- npm.io page: https://npm.io/package/vien-simple-router

## Recent versions

- 1.3.1 (latest) — 2016-07-26
- 1.3.0 — 2016-07-25
- 1.2.1 — 2016-07-25
- 1.2.0 — 2016-07-25
- 1.1.2 — 2016-07-25
- 1.1.1 — 2016-07-25
- 1.1.0 — 2016-07-25
- 1.0.0 — 2016-07-25

## README

#My Simple Router (as an exercise, don't actually use it)

### Install the npm package from terminal
```
npm i --S vien-simple-router
```

### Require in the http module
```javascript
const http = require('http')
```

### Require the router module
```javascript
const Router = require('vien-simple-router')
```

### Construct a new Router object with a root path
```javascript
let router = new Router('/api');
```

### Define the routes
```javascript
router.get('/hello', (req, res) => {
  res.writeHead(200, {
    'Content-Type': 'application/json'
  });
  res.write('{"msg": "hello world"}');
  res.end();
});
```

### Start and tell the server to listen to a specific port
```javascript
http.createServer(router.route()).listen(port)
```

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