Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
yaap during connectphase, express-integration
- Loading branch information
Showing
8 changed files
with
161 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,19 @@ | |||
"use strict"; | |||
|
|||
function MyService() { | |||
} | |||
|
|||
|
|||
MyService.prototype = { | |||
|
|||
handleGet: function (req, res, next)/*@GET("/")*/ { | |||
res.send('Look ma, no HTML!'); | |||
} | |||
|
|||
}; | |||
|
|||
|
|||
module.exports = MyService; | |||
|
|||
|
|||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,20 @@ | |||
/*jshint node:true*/ | |||
"use strict"; | |||
|
|||
|
|||
var wire = require("wire"); | |||
|
|||
wire({ | |||
app: { create: 'express' , ready:{listen:[8000]}}, | |||
myService: { create: './MyService' }, | |||
|
|||
plugins: [ | |||
{module: "../yaap/wire"}, | |||
{module: "../yaap/wire/express", server: "app"} | |||
] | |||
}, {require: require}).then(function(ctx){ | |||
|
|||
console.log("----- initialized -----"); | |||
//ctx.destroy(); | |||
}, function(err){console.error(err);}); | |||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,3 @@ | |||
{ | |||
"main":"./wireplugin" | |||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,58 @@ | |||
/** @license MIT License (c) copyright 2013 original author or authors */ | |||
|
|||
/** | |||
* @Autowired annotation processor. | |||
* | |||
* Autowires parameters of function calls based on a given or the parameter name. | |||
* | |||
* needs wire to be in the configuration object. | |||
* | |||
* | |||
* Licensed under the MIT License at: | |||
* http://www.opensource.org/licenses/mit-license.php | |||
* | |||
* @author Peter Mucha | |||
* | |||
* @version 0.0.3 | |||
*/ | |||
"use strict"; | |||
(function(define) { | |||
define([ "when"], | |||
function(when) { | |||
|
|||
return [ | |||
{ | |||
annotation: "@GET", | |||
processFunction: function(obj, fnDescription, annotationParams, context){ | |||
context.express.get(annotationParams[0], function(req, res, next){ | |||
obj[fnDescription.name](req, res, next); //dynamic call because there could be other annotations | |||
}); | |||
} | |||
}, | |||
{ | |||
annotation: "@PUT", | |||
processFunction: function(obj, fnDescription, annotationParams, context){ | |||
context.express.put(annotationParams[0], function(req, res, next){ | |||
obj[fnDescription.name](req, res, next); //dynamic call because there could be other annotations | |||
}); | |||
} | |||
}, | |||
{ | |||
annotation: "@POST", | |||
processFunction: function(obj, fnDescription, annotationParams, context){ | |||
context.express.post(annotationParams[0], function(req, res, next){ | |||
obj[fnDescription.name](req, res, next); //dynamic call because there could be other annotations | |||
}); | |||
} | |||
}, | |||
{ | |||
annotation: "@DELETE", | |||
processFunction: function(obj, fnDescription, annotationParams, context){ | |||
context.express["delete"](annotationParams[0], function(req, res, next){ | |||
obj[fnDescription.name](req, res, next); //dynamic call because there could be other annotations | |||
}); | |||
} | |||
} | |||
]; | |||
|
|||
});})(typeof define == 'function'? define: function(deps, factory) {module.exports = factory.apply(this, deps.map(function(x) {return require(x);}));}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Original file line | Diff line number | Diff line change |
---|---|---|---|
@@ -0,0 +1,37 @@ | |||
/** @license MIT License (c) copyright Peter Mucha */ | |||
|
|||
/** | |||
* yaap/wire plugin | |||
* wire plugin that provides annotation processing of components, e.g. @Autowired | |||
* | |||
* wire is part of the cujo.js family of libraries (http://cujojs.com/) | |||
* | |||
* Licensed under the MIT License at: | |||
* http://www.opensource.org/licenses/mit-license.php | |||
*/ | |||
(function(define) { | |||
define(["underscore", "../../yaap", | |||
"./plugins/VerbProcessors", | |||
"wire"], function(_, yaap, VERBS, wire) { | |||
"use strict"; | |||
|
|||
|
|||
return { | |||
wire$plugin: function(ready, destroyed, options) { | |||
if (!options.server) | |||
throw "yaap/wire/express needs server reference"; | |||
|
|||
//register for wiring | |||
yaap.config = yaap.config || {}; | |||
yaap.config.express = {$ref: options.server}; | |||
for(var i = 0; i < VERBS.length; ++i) | |||
yaap.register(VERBS[i]); | |||
return {}; | |||
} | |||
}; | |||
|
|||
}); | |||
}( | |||
typeof define == 'function' && define.amd ? define : function(deps, factory) { | |||
module.exports = factory.apply(this, deps.map(require)); | |||
})); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters