Skip to content
This repository has been archived by the owner on Nov 9, 2022. It is now read-only.

Support SJS controllers #640

Closed
grtjn opened this issue Jul 28, 2016 · 1 comment
Closed

Support SJS controllers #640

grtjn opened this issue Jul 28, 2016 · 1 comment
Assignees
Milestone

Comments

@grtjn
Copy link
Contributor

grtjn commented Jul 28, 2016

ml extend only supports xqy extensions, and samples doesn't include sjs samples either..

prestonmcgowan pushed a commit to prestonmcgowan/roxy that referenced this issue Oct 19, 2016
Add <uri-param name="language">sjs</uri-param> to your request
definition to make use of a SJS controller.
Issue marklogic-community#640.
@prestonmcgowan
Copy link

prestonmcgowan commented Oct 19, 2016

/app/config/config.xqy

<request uri="^/api/print/here$" endpoint="/roxy/query-router.xqy">
  <http method="GET"/>
  <uri-param name="controller">test</uri-param>
  <uri-param name="language">sjs</uri-param>
  <uri-param name="func">print</uri-param>
  <uri-param name="format">json</uri-param>
</request>
<request uri="^/api/compute/area/(\d+)$" endpoint="/roxy/update-router.xqy">
  <http method="PUT"/>
  <uri-param name="controller">test</uri-param>
  <uri-param name="language">sjs</uri-param>
  <uri-param name="func">area</uri-param>
  <uri-param name="width">$1</uri-param>
  <uri-param name="format">json</uri-param>
</request>

/app/config/controllers/test.sjs

var req = require("/roxy/lib/request.xqy");

module.exports = {

  print : function () {
    return "here";
  },
  area  : function () {
    var width = req.get("width");
    return width * width;
  }
};

I didn't see any tests in the roxy codebase to include the above sample in.

Would an update to the project's wiki be the best?

prestonmcgowan pushed a commit to prestonmcgowan/roxy that referenced this issue Oct 20, 2016
Updated previous changes based on dcassel's suggestions.
Tested using the sample SJS requests and test.sjs in marklogic-community#640.
dmcassel added a commit that referenced this issue Oct 20, 2016
#640: Support SJS with a language property
@dmcassel dmcassel added this to the 1.7.4 milestone Oct 20, 2016
dmcassel added a commit to dmcassel/roxy that referenced this issue Oct 20, 2016
@dmcassel dmcassel changed the title Provide sjs samples (and include in scaffolding?) Support SJS controllers Oct 20, 2016
RobertSzkutak added a commit that referenced this issue Oct 21, 2016
#640 updating unit tests for SJS controllers
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

4 participants