Browse files

added documentation for express-integration

  • Loading branch information...
1 parent c0909c4 commit c3ad218385d1d9467cfa8d48c1376140bf17b659 @warmuuh committed Apr 5, 2013
Showing with 35 additions and 1 deletion.
  1. +1 −0
  2. +22 −0 yaap/
  3. +12 −1 yaap/docs/
@@ -8,6 +8,7 @@ See [Readme](yaap) for more information.
There are also two examples for server and client scenario:
* On [Node](node-example)
+* With [Express.js] [Node](express-example)
* In [Browser](browser-example)
@@ -6,6 +6,8 @@ Yaap is a generic annotation processor for javascript. It can be used to impleme
It [integrates](#wirejs-integration) with [wire.js]( (part of [cujo.js](, which enables Spring-style wiring (i.e. dependency injection) of your javascript applications.
With the `yaap/wire` plugin, @Autowired applications are possible
+It also [integrates](#expressjs-integration) with Express.js to achieve a SpringMVC-style framework for webapps.
`Remark:` This is an experimentational library and should not be used in production.
An overview of out-of-the-box supported annotations is available [here](docs/
@@ -17,6 +19,7 @@ Installation for node: `npm install yaap`
* [Annotations for JavaScript](
* [@Autowired for JavaScript](
+* [Express.js the SpringMVC-way](
@@ -115,3 +118,22 @@ module.exports = {
The yaap/wire plugin will be called after the bean was created. That means, the constructor itself will not be affected by annotations.
As a workaround, use a separate initialize-method (using the [init-facade]( of wire).
+##Express.js integration
+There are also out-of-the-box annotations included for creating webapps in a springMVC-like manner. A simple example of a service:
+MyService.prototype = {
+ index: function ()/*@GET*/ {
+ return 'index';
+ },
+ submit: function (name, age)/*@POST @Param*/ {
+ var msg = (age < 18)? "You are too young" : "You are welcome!";
+ return {view:'greet', model:{name: name, msg: msg}};
+ }
+As known from SpringMVC, the returned values determine, which view will be called and with what parameters.
+More details on this in my [blogpost](
@@ -23,11 +23,22 @@ Some annotations can only be used on parameters while others can also be used at
* `@PreDestroy` (function): the annotated function will be called, if context.destroy() is called.
###browser-specific wire annotations
-for these annotations, you need to add the additional `yaao/wire/html`-plugin!
+for these annotations, you need to add the additional `yaap/wire/html`-plugin! (as shown in the browser-example)
* `@On(<refName>, <event>)` (function): the annotated function will automatically be bound the the event of the given dom-node.
This is intended to be used with the `wire/dom`-plugin. <refName> can reference one or more elements in the dom (though
it is probably better practice to reference a bean in the wirecontext, which itself references the dom-nodes).
For example, you could bind a clickhandler with this annotation: `@On("dom.all!.btn","click")`.
The annotated method accepts one argument that is the event (though you could add additional @autowired arguments, if you want)
+###Node-Specific wire-annotations (Express.js)
+for these annotations, you need to add the additional `yaap/wire/express`-plugin! (and you need to feed the express-application into the plugin as shown in the express-example)
+* `@GET/POST/PUT/DELETE([<pathspec>])` (function): registeres the function as an endpoint in an express-application with either the given path
+ or the functionname as path, if omitted.
+* `@Param([<name>])` (parameter/function): fetches the annotated parameter from the query/path/post parameters.
+ If annotation is on function-level, all parameters (except `@Body`-annotated parameters) are injected by-name.
+* `@Body` (parameter/function): if parameter-level, then the request-body will be injected. If on function-level,
+ it states that the return-value will be returned as-is (Just like @ResponseBody does in SpringMVC).
+* `@JSON` (function): states, that the returned value will be send as response in json-format. (using [response.json](

0 comments on commit c3ad218

Please sign in to comment.