Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added Server

  • Loading branch information...
commit 1ae9f40372137fe9eaa97562166397a182a73739 1 parent bf3553c
@tj authored
Showing with 66 additions and 2 deletions.
  1. +1 −1  index.js
  2. +21 −1 lib/nedis.js
  3. +32 −0 lib/server.js
  4. +12 −0 test/redis.test.js
View
2  index.js
@@ -1,2 +1,2 @@
-module.exports = require('./lib');
+module.exports = require('./lib/nedis');
View
22 lib/nedis.js
@@ -6,7 +6,27 @@
*/
/**
+ * Module dependencies.
+ */
+
+var Server = require('./server');
+
+/**
* Library version.
*/
-exports.version = '0.0.1';
+exports.version = '0.0.1';
+
+/**
+ * Initialize a new `Server` with the given `port` and `host`
+ * defaulting to 6379 and 127.0.0.1
+ *
+ * @param {Number} port
+ * @param {String} host
+ * @return {Server}
+ * @api public
+ */
+
+exports.createServer = function(port, host) {
+ return new Server(port, host);
+};
View
32 lib/server.js
@@ -0,0 +1,32 @@
+
+/*!
+ * Nedis - Server
+ * Copyright(c) 2010 TJ Holowaychuk <tj@vision-media.ca>
+ * MIT Licensed
+ */
+
+/**
+ * Default portno.
+ */
+
+var defaultPort = 6379;
+
+/**
+ * Default hostname.
+ */
+
+var defaultHost = '127.0.0.1';
+
+/**
+ * Initialize a new `Server` with the given `port` and `host`
+ * defaulting to 6379 and 127.0.0.1
+ *
+ * @param {Number} port
+ * @param {String} host
+ * @api public
+ */
+
+var Server = module.exports = function Server(port, host) {
+ this.port = port || defaultPort;
+ this.host = host || defaultHost;
+};
View
12 test/redis.test.js
@@ -9,5 +9,17 @@ var nedis = require('nedis')
module.exports = {
'test .version': function(assert){
nedis.version.should.match(/^\d+\.\d+\.\d+$/);
+ },
+
+ 'test createServer()': function(){
+ var server = nedis.createServer();
+ server.should.have.property('port', 6379);
+ server.should.have.property('host', '127.0.0.1');
+ },
+
+ 'test createServer(port, host)': function(){
+ var server = nedis.createServer(3000, '1.1.1.1');
+ server.should.have.property('port', 3000);
+ server.should.have.property('host', '1.1.1.1');
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.