Created
November 14, 2012 01:57
-
-
Save themasch/4069769 to your computer and use it in GitHub Desktop.
idea: javascript annotation powered controllers (for express)
This file contains hidden or 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
| Controller.create('Test', { | |
| /** | |
| * @Route('/') | |
| */ | |
| indexAction: function(req, res) | |
| { | |
| }, | |
| /** | |
| * @Route('/edit', { method: POST }) | |
| * @Route('/edit', POST) | |
| */ | |
| editMethod: function(req, res) | |
| { | |
| }, | |
| /** | |
| * @Route('/hello/:name') | |
| * @Route('/hello/') | |
| * @FilterBefore('Test.loadStuff') | |
| */ | |
| hello: function(req, res) | |
| { | |
| if(req.param('name')) { | |
| res.end('Hello ' + req.param('name')) | |
| } else { | |
| res.end('Hello ' + res.locals.world +'!') | |
| } | |
| }, | |
| /** | |
| * @ProvidesFilter('loadStuff') | |
| */ | |
| loadStuffINeed: function(req, res, next) | |
| { | |
| res.locals.world = "World" | |
| next() | |
| } | |
| }); | |
| /** | |
| * there should be a way to create new annotations like: | |
| * @LoadSomeStuffINeed | |
| * @RequirePermission('edit_this_stuff') | |
| * | |
| * These Annotations should be provided by other modules. | |
| */ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment