# teller

> Simple node.js webserver.

Latest version **0.9.0** (published 2012-08-02) · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.9.0 |
| Published | 2012-08-02 |
| First published | 2012-05-16 |
| Weekly downloads | 0 |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >= 0.8.0 |
| Dependencies | 5 |
| Known vulnerabilities | 0 (+5 in 1 direct dependencies) |
| Install scripts | no |
| Author | Craig Rogers |
| Maintainers | craigr_ |

## Links

- npm: https://www.npmjs.com/package/teller
- Repository: https://github.com/twentyrogersc/teller
- npm.io page: https://npm.io/package/teller

## Dependencies (5)

- [ejs](https://npm.io/package/ejs.md) 0.7.1
- [filed](https://npm.io/package/filed.md) 0.0.6
- [wrench](https://npm.io/package/wrench.md) 1.3.9
- [crossroads](https://npm.io/package/crossroads.md) 0.8.0
- [formidable](https://npm.io/package/formidable.md) 1.0.9

## Recent versions

- 0.9.0 (latest) — 2012-08-02
- 0.8.0 — 2012-07-13
- 0.7.0 — 2012-06-07
- 0.6.0 — 2012-05-24
- 0.5.0 — 2012-05-19
- 0.4.0 — 2012-05-17
- 0.3.0 — 2012-05-16
- 0.2.0 — 2012-05-16

## README

#teller
Simple node.js webserver.  
Dependencies: [crossroads](http://millermedeiros.github.com/crossroads.js/), [ejs](https://github.com/visionmedia/ejs), [filed](https://github.com/mikeal/filed), [formidable](https://github.com/felixge/node-formidable), [wrench](https://github.com/ryanmcgrath/wrench-js).

[![Build Status](https://secure.travis-ci.org/twentyrogersc/teller.png)](http://travis-ci.org/twentyrogersc/teller)

## Installation

```javascript
npm install teller
```

```javascript
var app = require('teller')
app.get('/', function(req, res) {
  res.json({ foo: 'bar' })
}).listen(1234)
```

## Routing

See [crossroads.addRoute](http://millermedeiros.github.com/crossroads.js/#crossroads-add_route) for more documentation on route patterns. Teller only supports string patterns, and named variables are available in [req.route](#reqroute).

### app.get(route, callback)

Add an GET route with callback.

```javascript
app.get('/', function(req, res) {
  res.send('<h1>Hello world!</h1>')
})
```

### app.post(route, callback)

Add a POST route with callback.

```javascript
app.post('/add', function(req, res) {
  res.json(req.body)
})
```

### app.delete(route, callback)

Add a DELETE route with callback.

```javascript
app.delete('/image', function(req, res) {
  res.json(req.body)
})
```

### app.settings(settings)

Settings for template rendering and static file serving.

```javascript
app.settings({
  template: { dir: __dirname+'/templates', 404: '404.ejs' },
  static: { route: '/public', dir: __dirname+'/public' }
})
```

### app.listen(port)

Begin accepting connections on the specified port.

```javascript
app.listen(1234)
```

## Request

### req.route

Contains named variables (see [Routing](#routing)) as key-value pairs.

```javascript
app.get('/:foo:', function(req, res) {
  console.log(req.route.foo)
  // GET /bar would log 'bar'
})
```

### req.query

Contains a parsed query string for GET requests.

```javascript
app.get('/qs', function(req, res) {
  console.log(req.query.foo)
  // GET /qs?foo=bar would log 'bar'
})
```

### req.body

Contains a parsed form body for POST & DELETE requests.

```javascript
app.post('/form', function(req, res) {
  console.log(req.body.foo)
  // POST /form foo=bar would log 'bar'
})
```

## Response

### res.json(obj [, statusCode])

Render the object as json.

```javascript
app.get(route, function(req, res) {
  res.json({ foo: bar })
})
```

### res.redirect(url [, statusCode])

Redirect to another url.

```javascript
app.get(route, function(req, res) {
  res.redirect('/login')
})
```

### res.render(template [, data [, statusCode]])

Render the specified template. Template directory must be specified in [app.settings()](#appsettingssettings).

```javascript
app
  .settings({ dir: __dirname+'/templates' })
  .get(route, function(req, res) {
    res.render('template.ejs', data, statusCode)
  })
```

### res.send(data [, contentType [, statusCode]])

Renders a string, with optional Content-Type header and status code.

```javascript
app.get(route, function(req, res) {
  res.send('<h1>hello</h1>')
})
```

### res.show404()

If ```settings.template['404']``` is supplied, renders a custom 404 page, otherwise sends the default 404 page.

```javascript
app.get(route, function(req, res) {
  res.show404(data)
})
```

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