Skip to content

Instantly share code, notes, and snippets.

@edymerchk
Created May 25, 2013 22:10
Show Gist options
  • Save edymerchk/5650943 to your computer and use it in GitHub Desktop.
Save edymerchk/5650943 to your computer and use it in GitHub Desktop.
REST routes for node.js project
URL_ROOT = "/api"
## Traditional REST
app.get "#{URL_ROOT}/:controller" , (req, res, next) ->
routeMvc(req.params.controller, "index",req,res, next)
app.post "#{URL_ROOT}/:controller", (req, res, next) ->
routeMvc(req.params.controller, 'create', req, res, next)
app.get "#{URL_ROOT}/:controller/:id" , (req, res, next) ->
routeMvc(req.params.controller, 'get', req, res, next)
app.put "#{URL_ROOT}/:controller/:id" , (req, res, next) ->
routeMvc(req.params.controller, 'update', req, res, next)
app.delete "#{URL_ROOT}/:controller/:id" , (req, res, next) ->
routeMvc(req.params.controller, 'delete', req, res, next)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment