Skip to content
This repository has been archived by the owner on Oct 17, 2018. It is now read-only.

jonhester/hapi-nedb-connector

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

hapi-nedb-connector NPM version Build Status

A simple connector for hapi and nedb

Installation

npm install hapi-nedb-connector

Usage

var Hapi = require('hapi');

// Create a server with a host and port
var server = new Hapi.Server();

server.connection({
    host: 'localhost',
    port: 8000
});

server.register({
	register: require('hapi-nedb-connector'),
	options: {
		directory: 'data/'
	}
}, function (err) {

	server.route({
		method: 'GET',
		path: '/',
		handler: function (request, reply) {
			// Access plugin
			var db = server.plugins['hapi-nedb-connector'].db;
			
			// Use requests database and create requests database if it does not exist
			db('requests').insert(request.info, function(err, newRequest) {
				reply({message: 'request added to database'});
			});

		}
	});
});

// Start the server
server.start(function() {
     console.log('Server running at:', server.info.uri);
});

About

A simple connector for hapi and nedb

Resources

License

Stars

Watchers

Forks

Packages

No packages published