Permalink
Browse files

setting the scope for minimal usage of the api and adding examples

  • Loading branch information...
1 parent fc6c594 commit cccfbd0593c83f7637bc986e7cfde4193da94888 @mvrilo committed Dec 4, 2011
Showing with 20 additions and 11 deletions.
  1. +5 −0 examples/hello-world.js
  2. +5 −0 examples/minimal-hello-world.js
  3. +10 −11 lib/frank.js
View
@@ -0,0 +1,5 @@
+var frank = require('../lib/frank'),
+ server = frank();
+
+server.get('/').send('not so minimal api ftw too');
+server.listen(8000)
@@ -0,0 +1,5 @@
+var f = require('../lib/frank'), server = f(),
+ get = server.get, run = server.run;
+
+get('/').send('minimal api ftw');
+run(8000);
View
@@ -5,24 +5,26 @@ var connect = require('connect'),
function frank() {
if (!(this instanceof frank)) return new frank();
- this.server = connect.createServer();
- this.handler = {};
+ this.scope = true;
}
-merge(request, response);
frank.fn = frank.prototype;
+frank.fn.__proto__ = merge(request, response);
+module.exports = frank;
+
'get post put head'.split(' ').forEach(function(method) {
frank.fn[method] = function(path) {
- if (!this.handler) {
- this.server = connect();
- this.handler = {};
- }
+ this.server = connect();
+ this.handler = {};
+
this.path = path;
this.route = [method.toUpperCase(), path].join(' ');
+
this.handler[this.route] = {};
this.handler[this.route]['method'] = method.toUpperCase();
this.handler[this.route]['path'] = path;
- this.__proto__ = request;
+
+ if (!this.scope) this.__proto__ = frank.fn.__proto__;
return this;
};
});
@@ -38,7 +40,6 @@ frank.fn.listen = function(port, msg) {
frank.server.call(this).listen(port);
console.log(msg);
};
-
frank.fn.run = frank.fn.listen;
frank.server = function() {
@@ -61,5 +62,3 @@ frank.server = function() {
}
return server;
};
-
-module.exports = frank;

0 comments on commit cccfbd0

Please sign in to comment.