ute

0.1.6 • Public • Published
Avatar

Build Status Dependencies Status Coverage Status Published Version
npm Badge

Ute

Ute is an unframework for simple node.js web application.

This is handy if you want to run your web app by specifying route + environment configuration files and handler functions, with less repetitive boilerplate code.

Under the hood, Ute uses Express, EJS (with Partials), and nconf.

Installation

npm install ute

or as a dependency in package.json file:

"dependencies": {
  "ute": "x.y.z"
}

Usage

Specify handler functions:

function homeCb(req, res) {
  res.render('home.html', {
    layout: 'mylayout',
    locals: {
      name: 'Bob'
    }
  });
}

function dataCb(req, res) {
  res.json({ foo: 'bar' });
}

Create a Ute instance and call start:

var Ute = require('ute');
var ute = new Ute();

var handlers = { home: homeCb, data: dataCb }

ute.start(handlers);

Place mylayout.html and home.html under views directory:

mylayout.html

<html>
<head><title>My Site</title></head>
<body>
  <%- body %>
</body>
</html>

home.html

Hello <%= name %>!

Configuration

Set application name and port in conf/.json:

{
  "app": {
    "name": "myapp",
    "port": 9000
  }
}

Set log4js configuration in conf/-log4js.json, e.g.

{
  "appenders": [
    {
      "type": "console"
    },
    {
      "type": "file",
      "filename": "someapp.log",
      "maxLogSize": 10240000,
      "backups": 10
    }
  ],
  "replaceConsole": true
}

Set routes path and handler mappings in conf/routes.json:

[
  { "method": "GET", "path": "/", "handler": "home" },
  { "method": "POST", "path": "/data", "handler": "data" }
]

Colophon

Developer's Guide

Build reports:

Package Sidebar

Install

npm i ute

Weekly Downloads

3

Version

0.1.6

License

none

Last publish

Collaborators

  • cliffano