Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Osprey Controller #98

Open
blakeembrey opened this issue Mar 3, 2016 · 1 comment
Open

Osprey Controller #98

blakeembrey opened this issue Mar 3, 2016 · 1 comment

Comments

@blakeembrey
Copy link
Contributor

Replace the manual router usage with a controller generator. Unsure whether names or paths should be used (maybe use annotations with 1.0 standardised from mulesoft-labs/raml-generator#14). Using an controller interface would allow wildly improved autocompletion and type checking in typed languages like TypeScript. It can also allow late-binding of the middleware methods, and allow errors to be thrown when the users controller does not match implementation at startup.

Simple example API:

var controller = require('osprey').controller(raml)

controller({
  '/users/{userId}': function (req, res) {

  },
  // Or using named annotations:
  getUser: function (req, res) {
  }
})
@agalazis
Copy link

No sure if that's a good idea middleware makes more sense people may want to combine it with other controllers like inversify utils controller etc

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants