From f0b071ffe849c40f1ecc53dda17c865554a67782 Mon Sep 17 00:00:00 2001 From: Rajiv Tirumalareddy Date: Tue, 2 Sep 2014 14:08:07 -0700 Subject: [PATCH 1/2] new syntax --- libs/fetcher.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/fetcher.js b/libs/fetcher.js index 5533c5e5..fa83f515 100644 --- a/libs/fetcher.js +++ b/libs/fetcher.js @@ -94,7 +94,7 @@ module.exports = function createFetcherClass (options) { config: {}, callback: function (err, data) { if (err) { - res.send('400', 'request failed'); + res.status('400').send('request failed'); } res.json(data); } From c046b61d16d3b1e51833cd7a8264d8a822df0062 Mon Sep 17 00:00:00 2001 From: Rajiv Tirumalareddy Date: Wed, 3 Sep 2014 14:14:25 -0700 Subject: [PATCH 2/2] No longer need to swap fetcher.js and fetcher.client.js manually via webpack --- README.md | 15 --------------- examples/simple/webpack.config.js | 8 +------- package.json | 3 +++ 3 files changed, 4 insertions(+), 22 deletions(-) diff --git a/README.md b/README.md index 6f8a271e..d65b4baf 100644 --- a/README.md +++ b/README.md @@ -137,21 +137,6 @@ var fetchr = require('fetchr'), //... ``` - -## 5. Swap Fetchr <=> Fetchr.client - -Fetchr relies on a build process that swaps out `lib/fetchr.js` with `lib/fetchr.client.js` in the bundle that is generated for client side use. Usually the bundle is generated using tools like [webpack](http://webpack.github.io/) or [browserify](http://browserify.org/). - -``` -//webpack config -plugins: [ - //... - //Replace fetcher lib with client side fetcher lib - new webpack.NormalModuleReplacementPlugin(/^fetchr$/, require.resolve('fetchr/libs/fetcher.client.js')) - //... -] -``` - # Usage Examples See the [simple example](https://github.com/yahoo/fetchr/tree/master/examples/simple) diff --git a/examples/simple/webpack.config.js b/examples/simple/webpack.config.js index a1eb3eaf..129686a0 100644 --- a/examples/simple/webpack.config.js +++ b/examples/simple/webpack.config.js @@ -2,16 +2,10 @@ * Copyright 2014, Yahoo! Inc. * Copyrights licensed under the New BSD License. See the accompanying LICENSE file for terms. */ -var webpack = require('webpack'), - path = require('path'); module.exports = { entry: require.resolve('./client/app.js'), output: { path: __dirname+'/client/build/', filename: "app.js" - }, - plugins: [ - //Replace fetcher lib with client side fetcher lib - new webpack.NormalModuleReplacementPlugin(/^..\/..\/..\/libs\/fetcher.js$/, path.resolve('../../libs/fetcher.client.js')) - ] + } }; diff --git a/package.json b/package.json index 9ff9475f..af6f0090 100644 --- a/package.json +++ b/package.json @@ -43,6 +43,9 @@ "mockery": "^1.4.0", "precommit-hook": "^1.0.2" }, + "browser": { + "./libs/fetcher.js": "./libs/fetcher.client.js" + }, "jshintConfig": { "node": true },