     catch err
       res.status(500).send(error: err.toString())
 
+  render: (req, json, callback) ->
+    view_name = req.query.$view or @default_view
+    return callback(null, json) unless view_name
+    return callback(new Error "Unrecognized view: #{view_name}") unless view = @views[view_name]
 
-# TODO: allow for external caller to set CORS
-# # allow cross-origin
-# app.all route, (req, res, next) ->
-#   res.set('Access-Control-Allow-Origin', bind_options.origins)
-#   res.set('Access-Control-Allow-Headers', 'X-Requested-With,CONTENT-TYPE')
-#   res.set('Access-Control-Allow-Methods', 'GET,POST,PUT')
-#   next()
-# app.all "#{route}/:id", (req, res, next) ->
-#   res.set('Access-Control-Allow-Origin', bind_options.origins)
-#   res.set('Access-Control-Allow-Headers', 'X-Requested-With,CONTENT-TYPE')
-#   res.set('Access-Control-Allow-Methods', 'GET,PUT,DELETE')
-#   next()
-#   _enableCors: (app, url) =>
-#     app.all url, (req, res, next) ->
-#       res.set 'Access-Control-Allow-Origin', cors.origins if cors.origins
-#       res.header 'Access-Control-Allow-Headers', 'X-Requested-With,Content-Disposition,Content-Type,Content-Description,Content-Range'
-#       res.header 'Access-Control-Allow-Methods', 'HEAD, GET, POST, PUT, DELETE, OPTIONS'
-#       res.header('Access-Control-Allow-Credentials', 'true')
-#       next()
+    options = (if @viewOptions then @viewOptions(req, view_name) else {})
+    if _.isArray(json)
+      JSONUtils.renderModelsJSON _.map(json, (model_json) => new @model_type(@model_type::parse(model_json))), view, options, callback
+    else
+      JSONUtils.renderModelJSON new @model_type(@model_type::parse(json)), view, options, callback

            return res.status(404).send(error: "Model not found with id: #{req.query.id}")
          else
            res.json(json)
        return res.json(json) unless @render

        # TODO: intgrate the cache -> would need to be done as part of the fetch
        if req.query.$page
          @render req, json.rows, (err, rendered_json) =>
            return res.status(500).send(error: err.toString()) if err

          success: =>
            json = model.toJSON()
            json = _.pick(json, @white_lists.update) if @white_lists.update

            @render req, json, (err, json) =>
              return res.status(500).send(error: err.toString()) if err
              res.json(json)
