lockit-utils

utilities for lockit

npm install lockit-utils
3 downloads in the last day
47 downloads in the last week
202 downloads in the last month

Lockit utilities

Build Status NPM version

Small utilities module for lockit.

Installation

npm install lockit-utils

var utls = require('lockit-utils');

Configuration

// redirect target when requesting restricted page
exports.loginRoute = '/login';

// database connection string
// CouchDB
exports.db = 'http://127.0.0.1:5984/';

// MongoDB
// exports.db = {
//   url: 'mongodb://127.0.0.1/',
//   name: 'test',
//   collection: 'users'
// };

// PostgreSQL
// exports.db = {
//   url: 'postgres://127.0.0.1:5432/',
//   name: 'users',
//   collection: 'my_user_table'
// };

// MySQL
// exports.db = {
//   url: 'mysql://127.0.0.1:3306/',
//   name: 'users',
//   collection: 'my_user_table'
// };

// SQLite
// exports.db = {
//   url: 'sqlite://',
//   name: ':memory:',
//   collection: 'my_user_table'
// };

Features

  • protect routes from unauthorized access and redirect
  • get database and lockit adapter from connection string

Methods

utls.restrict(config)
var config = require('./config.js');

app.get('/private', utls.restrict(config), function(req, res) {
  res.send('only a registered user can see this');
})

utls.getDatabase(config)

var config = require('./config.js');

var db = utls.getDatabase(config);

// db is an object containing the keys 'type' and 'adapter'
// {
//   type: 'couchdb',
//   adapter: 'lockit-couchdb-adapter'
// }

Test

grunt

License

MIT

npm loves you