Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Required querystring parameter name was being concatenated to last va…

…riable name in the route.
  • Loading branch information...
commit 0b490412348df49bc970e02d255e72a4c51cf8bd 1 parent f9fbb82
@knowlecules authored
View
236 .idea/workspace.xml
@@ -6,10 +6,10 @@
</component>
<component name="ChangeListManager">
<list default="true" id="a45be2db-3362-4ea6-8ecc-68d7ca31ceee" name="Default" comment="">
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/Project_Default.xml" />
- <change type="NEW" beforePath="" afterPath="$PROJECT_DIR$/.idea/inspectionProfiles/profiles_settings.xml" />
<change type="MODIFICATION" beforePath="$PROJECT_DIR$/.idea/workspace.xml" afterPath="$PROJECT_DIR$/.idea/workspace.xml" />
- <change type="MODIFICATION" beforePath="$PROJECT_DIR$/package.json" afterPath="$PROJECT_DIR$/package.json" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/examples/client.js" afterPath="$PROJECT_DIR$/examples/client.js" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/examples/server.js" afterPath="$PROJECT_DIR$/examples/server.js" />
+ <change type="MODIFICATION" beforePath="$PROJECT_DIR$/spec/routes-spec.js" afterPath="$PROJECT_DIR$/spec/routes-spec.js" />
</list>
<ignored path="rapid-rest.iws" />
<ignored path=".idea/workspace.xml" />
@@ -26,6 +26,7 @@
<component name="DaemonCodeAnalyzer">
<disable_hints />
</component>
+ <component name="ExecutionTargetManager" SELECTED_TARGET="default_target" />
<component name="FavoritesManager">
<favorites_list name="rapid-rest" />
</component>
@@ -34,25 +35,25 @@
<file leaf-file-name="rapid-rest.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/lib/rapid-rest.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="154" column="2" selection-start="5497" selection-end="5497" vertical-scroll-proportion="0.0">
+ <state line="154" column="0" selection-start="6051" selection-end="6051" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="routes-spec.js" pinned="false" current="false" current-in-tab="false">
- <entry file="file://$PROJECT_DIR$/spec/routes-spec.js">
+ <file leaf-file-name="package.json" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor">
- <state line="50" column="3" selection-start="1862" selection-end="1862" vertical-scroll-proportion="0.0">
+ <state line="11" column="1" selection-start="268" selection-end="268" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
</entry>
</file>
- <file leaf-file-name="package.json" pinned="false" current="true" current-in-tab="true">
- <entry file="file://$PROJECT_DIR$/package.json">
+ <file leaf-file-name="routes-spec.js" pinned="false" current="false" current-in-tab="false">
+ <entry file="file://$PROJECT_DIR$/spec/routes-spec.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="2" column="23" selection-start="51" selection-end="51" vertical-scroll-proportion="0.04920405">
+ <state line="16" column="46" selection-start="628" selection-end="628" vertical-scroll-proportion="0.0">
<folding />
</state>
</provider>
@@ -61,7 +62,16 @@
<file leaf-file-name="client.js" pinned="false" current="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/examples/client.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="56" column="67" selection-start="1607" selection-end="1607" vertical-scroll-proportion="0.0">
+ <state line="67" column="73" selection-start="1828" selection-end="1828" vertical-scroll-proportion="0.0">
+ <folding />
+ </state>
+ </provider>
+ </entry>
+ </file>
+ <file leaf-file-name="server.js" pinned="false" current="true" current-in-tab="true">
+ <entry file="file://$PROJECT_DIR$/examples/server.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="15" column="27" selection-start="363" selection-end="363" vertical-scroll-proportion="0.3690304">
<folding />
</state>
</provider>
@@ -93,14 +103,14 @@
<option name="changedFiles">
<list>
<option value="$PROJECT_DIR$/README.md" />
- <option value="$PROJECT_DIR$/examples/client.js" />
- <option value="$PROJECT_DIR$/examples/server.js" />
<option value="$PROJECT_DIR$/test/routes-test.js" />
<option value="$PROJECT_DIR$/spec/routes-test.js" />
<option value="$PROJECT_DIR$/lib/rapid-rest2.js" />
- <option value="$PROJECT_DIR$/spec/routes-spec.js" />
<option value="$PROJECT_DIR$/lib/rapid-rest.js" />
<option value="$PROJECT_DIR$/package.json" />
+ <option value="$PROJECT_DIR$/spec/routes-spec.js" />
+ <option value="$PROJECT_DIR$/examples/client.js" />
+ <option value="$PROJECT_DIR$/examples/server.js" />
</list>
</option>
</component>
@@ -152,16 +162,6 @@
<sortByType />
</navigator>
<panes>
- <pane id="Scope">
- <subPane subId="Project Files">
- <PATH>
- <PATH_ELEMENT USER_OBJECT="Root">
- <option name="myItemId" value="" />
- <option name="myItemType" value="" />
- </PATH_ELEMENT>
- </PATH>
- </subPane>
- </pane>
<pane id="ProjectPane">
<subPane>
<PATH>
@@ -204,6 +204,24 @@
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
<PATH_ELEMENT>
+ <option name="myItemId" value="projectFilesBackup" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value=".idea" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ </PATH>
+ <PATH>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="rapid-rest" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.ProjectViewProjectNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
+ <option name="myItemId" value="rapid-rest" />
+ <option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
+ </PATH_ELEMENT>
+ <PATH_ELEMENT>
<option name="myItemId" value="lib" />
<option name="myItemType" value="com.intellij.ide.projectView.impl.nodes.PsiDirectoryNode" />
</PATH_ELEMENT>
@@ -224,43 +242,102 @@
</PATH>
</subPane>
</pane>
+ <pane id="Scope">
+ <subPane subId="Project Files">
+ <PATH>
+ <PATH_ELEMENT USER_OBJECT="Root">
+ <option name="myItemId" value="" />
+ <option name="myItemType" value="" />
+ </PATH_ELEMENT>
+ </PATH>
+ </subPane>
+ </pane>
</panes>
</component>
<component name="PropertiesComponent">
<property name="options.splitter.main.proportions" value="0.3" />
<property name="WebServerToolWindowFactoryState" value="false" />
- <property name="options.lastSelected" value="preferences.externalResources" />
<property name="recentsLimit" value="5" />
- <property name="options.searchVisible" value="true" />
+ <property name="options.lastSelected" value="preferences.externalResources" />
+ <property name="last_opened_file_path" value="C:/dev/nodejs/node.exe" />
+ <property name="restartRequiresConfirmation" value="true" />
+ <property name="FullScreen" value="true" />
<property name="options.splitter.details.proportions" value="0.2" />
+ <property name="options.searchVisible" value="true" />
</component>
- <component name="RunManager" selected="Node JS.client.js">
- <configuration default="false" name="server.js" type="NodeJSConfigurationType" factoryName="Node JS" temporary="true" path-to-node="C:/Program Files (x86)/nodejs/node" path-to-js-file="$PROJECT_DIR$/examples/server.js" working-dir="$PROJECT_DIR$" coffeescript-run="false">
- <RunnerSettings RunnerId="NodeJS.debug" />
- <RunnerSettings RunnerId="NodeJS.run" />
- <ConfigurationWrapper RunnerId="NodeJS.debug" />
- <ConfigurationWrapper RunnerId="NodeJS.run" />
+ <component name="RunManager">
+ <configuration default="false" name="routes-spec.js" type="JSTestDriver:ConfigurationType" factoryName="JsTestDriver" temporary="true">
+ <setting name="configLocationType" value="JS_FILE" />
+ <setting name="configType" value="FILE_PATH" />
+ <setting name="settingsFile" value="" />
+ <setting name="jsFile" value="$PROJECT_DIR$/spec/routes-spec.js" />
+ <setting name="serverType" value="INTERNAL" />
<method />
</configuration>
- <configuration default="false" name="client.js" type="NodeJSConfigurationType" factoryName="Node JS" temporary="true" path-to-node="C:/Program Files (x86)/nodejs/node" path-to-js-file="$PROJECT_DIR$/examples/client.js" working-dir="$PROJECT_DIR$" coffeescript-run="false">
- <RunnerSettings RunnerId="NodeJS.run" />
- <ConfigurationWrapper RunnerId="NodeJS.run" />
+ <configuration default="true" type="JSTestDriver:ConfigurationType" factoryName="JsTestDriver">
+ <setting name="configLocationType" value="CONFIG_FILE" />
+ <setting name="settingsFile" value="" />
+ <setting name="serverType" value="INTERNAL" />
<method />
</configuration>
- <configuration default="true" type="NodeJSConfigurationType" factoryName="Node JS" working-dir="$PROJECT_DIR$" coffeescript-run="false">
+ <configuration default="true" type="NodeunitConfigurationType" factoryName="Nodeunit">
+ <setting name="nodePath" value="/usr/local/bin/node" />
+ <setting name="nodeunitModuleDir" value="$PROJECT_DIR$/../../node_modules/nodeunit" />
+ <setting name="workingDirectory" value="$PROJECT_DIR$" />
+ <setting name="testType" value="JS_FILE" />
+ <setting name="jsFile" value="" />
+ <method />
+ </configuration>
+ <configuration default="true" type="XSLT" factoryName="XSLT">
+ <option name="myOutputFile" />
+ <option name="myOpenOutputFile" value="false" />
+ <option name="myOpenInBrowser" value="false" />
+ <option name="mySmartErrorHandling" value="true" />
+ <option name="myRunnerPort" value="34873" />
+ <option name="myVmArguments" />
+ <option name="myWorkingDirectory" />
+ <option name="myModule" />
+ <option name="myJdk" />
+ <parameters />
+ <OutputType value="CONSOLE" save-to-file="false" />
+ <FileType name="XML" />
+ <JdkChoice value="FROM_MODULE" />
+ <method />
+ </configuration>
+ <configuration default="true" type="JavascriptDebugSession" factoryName="Remote">
+ <JSRemoteDebuggerConfigurationSettings>
+ <option name="engineId" value="chrome" />
+ <option name="fileUrl" value="" />
+ </JSRemoteDebuggerConfigurationSettings>
<method />
</configuration>
<configuration default="true" type="JavascriptDebugSession" factoryName="Local">
<JSDebuggerConfigurationSettings>
- <option name="engineId" value="embedded" />
+ <option name="engineId" value="chrome" />
<option name="fileUrl" />
</JSDebuggerConfigurationSettings>
<method />
</configuration>
- <list size="2">
- <item index="0" class="java.lang.String" itemvalue="Node JS.server.js" />
- <item index="1" class="java.lang.String" itemvalue="Node JS.client.js" />
+ <list size="1">
+ <item index="0" class="java.lang.String" itemvalue="JsTestDriver.routes-spec.js" />
</list>
+ <configuration default="true" type="NodeJSConfigurationType" factoryName="Node.js" working-dir="$PROJECT_DIR$" coffeescript-run="false">
+ <method />
+ </configuration>
+ <configuration default="false" name="server.js" type="NodeJSConfigurationType" factoryName="Node.js" temporary="true" path-to-node="C:/dev/nodejs/node" path-to-js-file="examples/server.js" working-dir="$PROJECT_DIR$">
+ <RunnerSettings RunnerId="NodeJS.debug" />
+ <RunnerSettings RunnerId="NodeJS.run" />
+ <ConfigurationWrapper RunnerId="NodeJS.debug" />
+ <ConfigurationWrapper RunnerId="NodeJS.run" />
+ <method />
+ </configuration>
+ <configuration default="false" name="client.js" type="NodeJSConfigurationType" factoryName="Node.js" temporary="true" path-to-node="C:/dev/nodejs/node" path-to-js-file="examples/client.js" working-dir="$PROJECT_DIR$">
+ <RunnerSettings RunnerId="NodeJS.debug" />
+ <RunnerSettings RunnerId="NodeJS.run" />
+ <ConfigurationWrapper RunnerId="NodeJS.debug" />
+ <ConfigurationWrapper RunnerId="NodeJS.run" />
+ <method />
+ </configuration>
</component>
<component name="ShelveChangesManager" show_recycled="false" />
<component name="SvnConfiguration" maxAnnotateRevisions="500" myUseAcceleration="nothing" myAutoUpdateAfterCommit="false" cleanupOnStartRun="false">
@@ -295,7 +372,11 @@
<created>1336525870388</created>
<updated>1336525870388</updated>
</task>
- <option name="localTasksCounter" value="3" />
+ <task id="LOCAL-00003" summary="Updated version number">
+ <created>1342830967663</created>
+ <updated>1342830967664</updated>
+ </task>
+ <option name="localTasksCounter" value="4" />
<servers />
</component>
<component name="ToolWindowManager">
@@ -305,11 +386,11 @@
<window_info id="Changes" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="TODO" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="6" side_tool="false" content_ui="tabs" />
<window_info id="Structure" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="1" side_tool="true" content_ui="tabs" />
- <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.24984147" sideWeight="0.6703911" order="0" side_tool="false" content_ui="combo" />
- <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.39944133" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
+ <window_info id="Project" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="true" weight="0.14774889" sideWeight="0.6019553" order="0" side_tool="false" content_ui="combo" />
+ <window_info id="Debug" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3980447" sideWeight="0.5" order="3" side_tool="false" content_ui="tabs" />
<window_info id="Favorites" active="false" anchor="left" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="2" side_tool="true" content_ui="tabs" />
<window_info id="Event Log" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="true" content_ui="tabs" />
- <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.3282123" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
+ <window_info id="Run" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32681563" sideWeight="0.5" order="2" side_tool="false" content_ui="tabs" />
<window_info id="JsTestDriver Server" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.33" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Version Control" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.32960895" sideWeight="0.5" order="7" side_tool="false" content_ui="tabs" />
<window_info id="Cvs" active="false" anchor="bottom" auto_hide="false" internal_type="DOCKED" type="DOCKED" visible="false" weight="0.25" sideWeight="0.5" order="4" side_tool="false" content_ui="tabs" />
@@ -360,7 +441,7 @@
<option name="SHOW_VCS_ERROR_NOTIFICATIONS" value="true" />
<option name="FORCE_NON_EMPTY_COMMENT" value="false" />
<option name="CLEAR_INITIAL_COMMIT_MESSAGE" value="false" />
- <option name="LAST_COMMIT_MESSAGE" value="Supports enforceable query string parameters. Added jasmine specs" />
+ <option name="LAST_COMMIT_MESSAGE" value="Updated version number" />
<option name="MAKE_NEW_CHANGELIST_ACTIVE" value="false" />
<option name="OPTIMIZE_IMPORTS_BEFORE_PROJECT_COMMIT" value="false" />
<option name="CHECK_FILES_UP_TO_DATE_BEFORE_COMMIT" value="false" />
@@ -375,19 +456,40 @@
<option name="FILE_HISTORY_SPLITTER_PROPORTION" value="0.6" />
<MESSAGE value="Initial commit of actual source ;-)" />
<MESSAGE value="Supports enforceable query string parameters. Added jasmine specs" />
+ <MESSAGE value="Updated version number" />
</component>
<component name="XDebuggerManager">
<breakpoint-manager />
</component>
<component name="editorHistoryManager">
- <entry file="file://$PROJECT_DIR$/README.md">
+ <entry file="file://$PROJECT_DIR$/lib/rapid-rest.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="5" column="0" selection-start="51" selection-end="51" vertical-scroll-proportion="0.0" />
+ <state line="154" column="0" selection-start="6051" selection-end="6051" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/examples/server.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="11" column="0" selection-start="156" selection-end="290" vertical-scroll-proportion="0.0" />
+ <state line="0" column="39" selection-start="39" selection-end="39" vertical-scroll-proportion="0.0" />
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/examples/client.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="20" column="24" selection-start="644" selection-end="644" vertical-scroll-proportion="0.0" />
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/package.json">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="11" column="1" selection-start="268" selection-end="268" vertical-scroll-proportion="0.0" />
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/spec/routes-spec.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="16" column="46" selection-start="628" selection-end="628" vertical-scroll-proportion="0.0" />
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/lib/rapid-rest.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="154" column="0" selection-start="6051" selection-end="6051" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/spec/routes-spec.js">
@@ -395,21 +497,49 @@
<state line="50" column="3" selection-start="1862" selection-end="1862" vertical-scroll-proportion="0.0" />
</provider>
</entry>
+ <entry file="file://$PROJECT_DIR$/package.json">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="11" column="1" selection-start="268" selection-end="268" vertical-scroll-proportion="0.0" />
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/examples/server.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="0" column="39" selection-start="39" selection-end="39" vertical-scroll-proportion="0.0" />
+ </provider>
+ </entry>
<entry file="file://$PROJECT_DIR$/examples/client.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="56" column="67" selection-start="1607" selection-end="1607" vertical-scroll-proportion="0.0" />
+ <state line="6" column="97" selection-start="183" selection-end="183" vertical-scroll-proportion="0.0" />
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/README.md">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="5" column="0" selection-start="51" selection-end="51" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/lib/rapid-rest.js">
<provider selected="true" editor-type-id="text-editor">
- <state line="154" column="2" selection-start="5497" selection-end="5497" vertical-scroll-proportion="0.0">
- <folding />
- </state>
+ <state line="154" column="0" selection-start="6051" selection-end="6051" vertical-scroll-proportion="0.0" />
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/package.json">
<provider selected="true" editor-type-id="text-editor">
- <state line="2" column="23" selection-start="51" selection-end="51" vertical-scroll-proportion="0.04920405">
+ <state line="11" column="1" selection-start="268" selection-end="268" vertical-scroll-proportion="0.0" />
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/spec/routes-spec.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="16" column="46" selection-start="628" selection-end="628" vertical-scroll-proportion="0.0" />
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/examples/client.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="67" column="73" selection-start="1828" selection-end="1828" vertical-scroll-proportion="0.0" />
+ </provider>
+ </entry>
+ <entry file="file://$PROJECT_DIR$/examples/server.js">
+ <provider selected="true" editor-type-id="text-editor">
+ <state line="15" column="27" selection-start="363" selection-end="363" vertical-scroll-proportion="0.3690304">
<folding />
</state>
</provider>
View
29 examples/client.js
@@ -73,4 +73,33 @@ req.on('error', function(e) {
req.write(JSON.stringify(survey.answers));
req.end();
+// calling jsonp
+// http://127.0.0.1:8124/bw?table=words&level=11&callback=babyword=dojo.io.script.jsonp_dojoIoScript1._jsonpCallback
+var collection = "there";
+var survey = surveys[1];
+options.path = '/bw?table=words&level=11&callback=babyword=dojo.io.script.jsonp_dojoIoScript1._jsonpCallback';
+
+var req = http.request(options, function(res) {
+ if(res.statusCode != 201){
+ console.log('STATUS: ' + res.statusCode);
+ console.log('HEADERS: ' + JSON.stringify(res.headers));
+ }else{
+ console.log('SUCCESS: ' + JSON.stringify(res.headers));
+ }
+ res.setEncoding('utf8');
+
+ res.on('data', function (chunk) {
+ console.log('BODY: ' + chunk);
+ });
+});
+
+
+req.on('error', function(e) {
+ console.log('problem with request: ' + e.message);
+});
+
+// write data to request body
+req.write(JSON.stringify(survey.answers));
+req.end();
+
console.log(" interacting on port:" + port);
View
19 examples/server.js
@@ -20,6 +20,14 @@ routes('/there/:over_name')
});
routes.listen(port);
+/* Attempts to miss-match
+ params.level_name != params.level
+ */
+routes('/callback/:table_name?level_name={level_name}&callback={callback}')
+ ('get', function(req, res, params, jsonData){
+ callbackWords(req, res, params, jsonData);
+ });
+
var interval;
function here(req, res, params, bodyContents) {
var msg = "got 'here'";
@@ -40,4 +48,15 @@ function there(req, res, params, bodyContents) {
res.writeHead(201,'' , {'Content-Type': 'text/html'});
res.end(msg);
};
+
+function callbackWords(req, res, params, bodyContents) {
+ var msg = "went 'callbackwords'";
+ console.log(msg);
+ console.dir(bodyContents);
+ console.dir(params);
+
+ res.writeHead(201,'' , {'Content-Type': 'text/html'});
+ res.end(msg);
+};
+
console.log(" listening on port:" + port);
View
1  index.js
@@ -0,0 +1 @@
+module.exports = require(__dirname + '/lib/rapid-rest');
View
24 lib/rapid-rest.js
@@ -9,16 +9,16 @@ var http = require('http');
var url = require('url');
-module.exports = function() {
+module.exports = function () {
/* Syntax to enable the following invocation signature :
routes('/my_path')('get', myFunc);
*/
- var rest = function(route) {
+ var rest = function (route) {
return rest.handlers(rest.router.add(route));
};
rest.matchDefs = {};
rest.methods = {};
- rest.respond = function(res, code, headers, data) {
+ rest.respond = function (res, code, headers, data) {
// Handles empty responses more gracefully for feedback purposes
if (code && headers && !data) {
data = headers;
@@ -43,17 +43,17 @@ module.exports = function() {
res.writeHead(code, headers);
res.end(data);
};
- rest.handlers = function(route){
+ rest.handlers = function (route){
// Create options collection if it doesn't exist
- route.methods.options = route.methods.options || function(req, res, params) {
- var methods = Object.keys(route.methods).filter(function(key) {
+ route.methods.options = route.methods.options || function (req, res, params) {
+ var methods = Object.keys(route.methods).filter(function (key) {
return key !== 'options';
});
rest.respond(res, 200, methods);
};
// Request services are found at the intersection of service pattern and verb name
- route.method = function(rawVerb, accept, fn) {
+ route.method = function (rawVerb, accept, fn) {
// Handle overloads
if (rawVerb && accept && !fn) {
@@ -64,12 +64,12 @@ module.exports = function() {
var verb = rawVerb.toLowerCase();
if (verb[0] !== 'p') {
// verbs that don't send data such as GET, SEARCH
- route.methods[verb] = function(req, res, segments) {
+ route.methods[verb] = function (req, res, segments) {
fn(req, res, segments);
};
}else{
// Expecting POST or PUT verb
- route.methods[verb] = function(req, res, segments) {
+ route.methods[verb] = function (req, res, segments) {
var body = '';
// Data accepting event
req.on('data', function (data) {
@@ -114,13 +114,13 @@ module.exports = function() {
var urlDef = url.parse(urlPath, true);
var urlMatch = urlDef.pathname.replace(/[\-\[\]\{\}\(\)\*\+\?\.,\/\\\^\$\|#\s]/g, "\\$&").replace(/(:[^(\\/)]+)/g,"([^/]*)");
var patternRE = new RegExp(urlMatch);
- var paramKeys = (urlPath.indexOf("/:") > -1) ? urlPath.replace(/(\/[^:][^\/]+)/g, '').substr(2).split("/:") :[];
+ var paramKeys = (urlPath.indexOf("/:") > -1) ? urlDef.pathname.replace(/(\/[^:][^\/]+)/g, '').substr(2).split("/:") :[];
var queryKeys = urlDef.query;
rest.matchDefs[urlMatch] = rest.matchDefs[urlMatch] || {re:patternRE, paramKeys:paramKeys, queryKeys:queryKeys, methods:{}};
return rest.matchDefs[urlMatch];
},
- handle : function(req, res) {
+ handle : function (req, res) {
var paramKeys, urlDef, pattern, key, ikey;
// Handle options
var method = req.method.toLowerCase();
@@ -178,7 +178,7 @@ module.exports = function() {
};
}());
- rest.listen = function(host, port, cb) {
+ rest.listen = function (host, port, cb) {
http.createServer(rest.router.handle).listen(host, port, cb);
};
View
8 spec/routes-spec.js
@@ -1,15 +1,15 @@
var routes = require("../lib/rapid-rest")();
-describe('rapid-rest-routes', function(){
+describe('rapid-rest-routes', function () {
- it('path with url params', function(){
+ it('path with url params', function () {
routes('/here/:here_name/:user')
- ('post', function(req, res, params, jsonData){
+ ('post', function (req, res, params, jsonData) {
here(req, res, params, jsonData);
});
var rePattern = "\\/here\\/([^/]*)\\/([^/]*)";
- var matchDef = routes.matchDefs[rePattern] ;
+ var matchDef = routes.matchDefs[rePattern];
expect(matchDef).not.toEqual(null);
expect(matchDef.re).toEqual(/\/here\/([^/]*)\/([^/]*)/);
Please sign in to comment.
Something went wrong with that request. Please try again.