teller

Simple node.js webserver.

#teller Simple node.js webserver.

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

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

app.get(route, function(reqres) {
  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(reqres) {
  console.log(req.body)
})

Begin accepting connections on the specified port.

app.listen(1234)

Render the specified template. In order to call this, app.setTemplateDir() is required to set the directory of the templates. Data and statusCode are not required.

app.setTemplateDir(__dirname)
app.get(route, function(reqres) {
  res.render('template.ejs', data, statusCode)
})

Render the object as json. StatusCode is not required.

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

Redirect to another url. StatusCode is not required.

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