Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Simple node.js webserver.
JavaScript
tree: 5fcdd49350

Fetching latest commit…

Cannot retrieve the latest commit at this time

Failed to load latest commit information.
test
.DS_Store
.gitignore
.travis.yml
Makefile
README.md
index.js
package.json

README.md

teller

Simple node.js webserver.

Build Status

Installation

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

Request

app.get()

Add an GET route with callback. The query string will be parsed and available in req.query.

app.get(route, function(req, res) {
  console.log(req.query)
})

app.post()

Add a POST route with callback. The body and files in the request will be parsed and available in req.body and req.files.

app.post(route, function(req, res) {
  console.log(req.body)
})

app.settings()

Settings for template rendering and static file serving.

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

app.listen()

Begin accepting connections on the specified port.

app.listen(1234)

Response

res.render()

Render the specified template, the path of which must be specified in app.settings(). Data and statusCode are not required.

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

res.json()

Render the object as json. StatusCode is not required.

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

res.redirect()

Redirect to another url. StatusCode is not required.

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

res.show404()

Sends the default 404 page.

app.get(route, function(req, res) {
  res.show404()
})
Something went wrong with that request. Please try again.