smollweide / node-mock-server

File based Node REST API mock server
MIT License
255 stars 65 forks source link

Demo - /products does not work for Windows #78

Closed TimCluyts closed 6 years ago

TimCluyts commented 7 years ago

When running node demo and surfing to localhost:3001/products I get following response:

Error: ENOENT: no such file or directory, open 'c:\products#\GET\mock\response.txt' at Error (native) at Object.fs.openSync (fs.js:640:18) at Object.fs.writeFileSync (fs.js:1333:33) at MockController.writeFile (c:\projects\nodeMocker\node-mock-server\lib\Utils.js:152:6) at MockController._handleMockRequest (c:\projects\nodeMocker\node-mock-server\lib\controller\MockController.js:193:9) at Layer.handle [as handle_request] (c:\projects\nodeMocker\node-mock-server\node_modules\express\lib\router\layer.js:95:5) at next (c:\projects\nodeMocker\node-mock-server\node_modules\express\lib\router\route.js:137:13) at next (c:\projects\nodeMocker\node-mock-server\node_modules\express\lib\router\route.js:131:14) at next (c:\projects\nodeMocker\node-mock-server\node_modules\express\lib\router\route.js:131:14) at next (c:\projects\nodeMocker\node-mock-server\node_modules\express\lib\router\route.js:131:14)

The path c:\products#\GET....... should actually be c:\projects\nodeMocker\node-mock-server\demo..... It seems that the full path is not taken on windows when running locally and moving it to the default path instead.

After some debugging it turns out to be the package itself in MockController.js. It assumes that the whole path is using forward slashes while on Windows, a local path is built with backward slashes in stead.

This issue is - by the way - not limited to /products only but any route when running locally.

BTMPL commented 6 years ago

@timcluyts can you still reproduce this issue? Please note that the proper URL would be http://localhost:3001/rest/v1/products/ not http://localhost:3001/products/

This might have been changed and resolved since this report.