webpack_rails 0.3.0 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/webpack_rails/ErrorMessagePlugin.js +37 -0
- data/lib/webpack_rails/engine.rb +6 -5
- data/lib/webpack_rails/node_modules/cors/CONTRIBUTING.md +35 -0
- data/lib/webpack_rails/node_modules/cors/LICENSE +9 -0
- data/lib/webpack_rails/node_modules/cors/README.md +192 -0
- data/lib/webpack_rails/node_modules/cors/lib/index.js +242 -0
- data/lib/webpack_rails/node_modules/cors/node_modules/vary/HISTORY.md +29 -0
- data/lib/webpack_rails/node_modules/cors/node_modules/vary/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/cors/node_modules/vary/README.md +91 -0
- data/lib/webpack_rails/node_modules/cors/node_modules/vary/index.js +124 -0
- data/lib/webpack_rails/node_modules/cors/node_modules/vary/package.json +72 -0
- data/lib/webpack_rails/node_modules/cors/package.json +79 -0
- data/lib/webpack_rails/node_modules/cors/test/basic-auth.js +40 -0
- data/lib/webpack_rails/node_modules/cors/test/body-events.js +81 -0
- data/lib/webpack_rails/node_modules/cors/test/cors.js +652 -0
- data/lib/webpack_rails/node_modules/cors/test/error-response.js +77 -0
- data/lib/webpack_rails/node_modules/cors/test/example-app.js +98 -0
- data/lib/webpack_rails/node_modules/cors/test/issue-2.js +56 -0
- data/lib/webpack_rails/node_modules/cors/test/issue-31.js +58 -0
- data/lib/webpack_rails/node_modules/cors/test/mocha.opts +3 -0
- data/lib/webpack_rails/node_modules/express/History.md +3025 -0
- data/lib/webpack_rails/node_modules/express/LICENSE +24 -0
- data/lib/webpack_rails/node_modules/express/Readme.md +138 -0
- data/lib/webpack_rails/node_modules/express/index.js +11 -0
- data/lib/webpack_rails/node_modules/express/lib/application.js +643 -0
- data/lib/webpack_rails/node_modules/express/lib/express.js +103 -0
- data/lib/webpack_rails/node_modules/express/lib/middleware/init.js +36 -0
- data/lib/webpack_rails/node_modules/express/lib/middleware/query.js +51 -0
- data/lib/webpack_rails/node_modules/express/lib/request.js +489 -0
- data/lib/webpack_rails/node_modules/express/lib/response.js +1053 -0
- data/lib/webpack_rails/node_modules/express/lib/router/index.js +645 -0
- data/lib/webpack_rails/node_modules/express/lib/router/layer.js +176 -0
- data/lib/webpack_rails/node_modules/express/lib/router/route.js +210 -0
- data/lib/webpack_rails/node_modules/express/lib/utils.js +300 -0
- data/lib/webpack_rails/node_modules/express/lib/view.js +173 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/HISTORY.md +170 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/README.md +135 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/index.js +231 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/HISTORY.md +171 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/README.md +103 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/index.js +188 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/HISTORY.md +274 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/README.md +82 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/db.json +6474 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/index.js +11 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/node_modules/mime-db/package.json +94 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/mime-types/package.json +84 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/HISTORY.md +76 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/LICENSE +24 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/README.md +203 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/index.js +62 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/charset.js +102 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/encoding.js +118 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/language.js +112 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/lib/mediaType.js +179 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/node_modules/negotiator/package.json +86 -0
- data/lib/webpack_rails/node_modules/express/node_modules/accepts/package.json +98 -0
- data/lib/webpack_rails/node_modules/express/node_modules/array-flatten/LICENSE +21 -0
- data/lib/webpack_rails/node_modules/express/node_modules/array-flatten/README.md +43 -0
- data/lib/webpack_rails/node_modules/express/node_modules/array-flatten/array-flatten.js +64 -0
- data/lib/webpack_rails/node_modules/express/node_modules/array-flatten/package.json +62 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-disposition/HISTORY.md +40 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-disposition/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-disposition/README.md +141 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-disposition/index.js +443 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-disposition/package.json +66 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-type/HISTORY.md +9 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-type/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-type/README.md +92 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-type/index.js +214 -0
- data/lib/webpack_rails/node_modules/express/node_modules/content-type/package.json +65 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie/README.md +64 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie/index.js +116 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie/package.json +68 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie-signature/History.md +38 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie-signature/Readme.md +42 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie-signature/index.js +51 -0
- data/lib/webpack_rails/node_modules/express/node_modules/cookie-signature/package.json +59 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/History.md +195 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/Makefile +36 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/Readme.md +188 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/bower.json +28 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/browser.js +168 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/component.json +19 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/debug.js +197 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/node.js +209 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/node_modules/ms/History.md +66 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/node_modules/ms/LICENSE +20 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/node_modules/ms/README.md +35 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/node_modules/ms/index.js +125 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/node_modules/ms/package.json +47 -0
- data/lib/webpack_rails/node_modules/express/node_modules/debug/package.json +73 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/History.md +75 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/Readme.md +274 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/index.js +529 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/lib/compat/buffer-concat.js +33 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/lib/compat/callsite-tostring.js +101 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/lib/compat/index.js +69 -0
- data/lib/webpack_rails/node_modules/express/node_modules/depd/package.json +66 -0
- data/lib/webpack_rails/node_modules/express/node_modules/escape-html/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/escape-html/Readme.md +15 -0
- data/lib/webpack_rails/node_modules/express/node_modules/escape-html/index.js +29 -0
- data/lib/webpack_rails/node_modules/express/node_modules/escape-html/package.json +51 -0
- data/lib/webpack_rails/node_modules/express/node_modules/etag/HISTORY.md +71 -0
- data/lib/webpack_rails/node_modules/express/node_modules/etag/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/etag/README.md +165 -0
- data/lib/webpack_rails/node_modules/express/node_modules/etag/index.js +132 -0
- data/lib/webpack_rails/node_modules/express/node_modules/etag/package.json +73 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/HISTORY.md +90 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/README.md +133 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/index.js +151 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/node_modules/unpipe/HISTORY.md +4 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/node_modules/unpipe/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/node_modules/unpipe/README.md +43 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/node_modules/unpipe/index.js +69 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/node_modules/unpipe/package.json +59 -0
- data/lib/webpack_rails/node_modules/express/node_modules/finalhandler/package.json +81 -0
- data/lib/webpack_rails/node_modules/express/node_modules/fresh/HISTORY.md +38 -0
- data/lib/webpack_rails/node_modules/express/node_modules/fresh/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/fresh/README.md +58 -0
- data/lib/webpack_rails/node_modules/express/node_modules/fresh/index.js +57 -0
- data/lib/webpack_rails/node_modules/express/node_modules/fresh/package.json +87 -0
- data/lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/README.md +34 -0
- data/lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/index.js +57 -0
- data/lib/webpack_rails/node_modules/express/node_modules/merge-descriptors/package.json +125 -0
- data/lib/webpack_rails/node_modules/express/node_modules/methods/HISTORY.md +24 -0
- data/lib/webpack_rails/node_modules/express/node_modules/methods/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/methods/README.md +41 -0
- data/lib/webpack_rails/node_modules/express/node_modules/methods/index.js +42 -0
- data/lib/webpack_rails/node_modules/express/node_modules/methods/package.json +88 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/HISTORY.md +88 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/README.md +154 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/index.js +196 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/node_modules/ee-first/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/node_modules/ee-first/README.md +80 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/node_modules/ee-first/index.js +95 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/node_modules/ee-first/package.json +64 -0
- data/lib/webpack_rails/node_modules/express/node_modules/on-finished/package.json +71 -0
- data/lib/webpack_rails/node_modules/express/node_modules/parseurl/HISTORY.md +42 -0
- data/lib/webpack_rails/node_modules/express/node_modules/parseurl/LICENSE +24 -0
- data/lib/webpack_rails/node_modules/express/node_modules/parseurl/README.md +107 -0
- data/lib/webpack_rails/node_modules/express/node_modules/parseurl/index.js +136 -0
- data/lib/webpack_rails/node_modules/express/node_modules/parseurl/package.json +80 -0
- data/lib/webpack_rails/node_modules/express/node_modules/path-to-regexp/History.md +36 -0
- data/lib/webpack_rails/node_modules/express/node_modules/path-to-regexp/LICENSE +21 -0
- data/lib/webpack_rails/node_modules/express/node_modules/path-to-regexp/Readme.md +35 -0
- data/lib/webpack_rails/node_modules/express/node_modules/path-to-regexp/index.js +129 -0
- data/lib/webpack_rails/node_modules/express/node_modules/path-to-regexp/package.json +184 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/HISTORY.md +66 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/README.md +137 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/index.js +345 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/HISTORY.md +4 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/README.md +53 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/index.js +35 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/forwarded/package.json +65 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/Cakefile +18 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/LICENSE +19 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/README.md +161 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/ipaddr.min.js +1 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/lib/ipaddr.js +439 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/package.json +60 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/src/ipaddr.coffee +374 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/node_modules/ipaddr.js/test/ipaddr.test.coffee +262 -0
- data/lib/webpack_rails/node_modules/express/node_modules/proxy-addr/package.json +90 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/CHANGELOG.md +88 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/CONTRIBUTING.md +1 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/LICENSE +28 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/README.md +317 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/bower.json +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/lib/index.js +15 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/lib/parse.js +186 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/lib/stringify.js +121 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/lib/utils.js +190 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/package.json +56 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/test/parse.js +478 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/test/stringify.js +259 -0
- data/lib/webpack_rails/node_modules/express/node_modules/qs/test/utils.js +28 -0
- data/lib/webpack_rails/node_modules/express/node_modules/range-parser/HISTORY.md +35 -0
- data/lib/webpack_rails/node_modules/express/node_modules/range-parser/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/range-parser/README.md +48 -0
- data/lib/webpack_rails/node_modules/express/node_modules/range-parser/index.js +49 -0
- data/lib/webpack_rails/node_modules/express/node_modules/range-parser/package.json +76 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/HISTORY.md +295 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/README.md +195 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/index.js +820 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/README.md +38 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/index.js +36 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/destroy/package.json +67 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/HISTORY.md +76 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/README.md +63 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/index.js +120 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/LICENSE +16 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/README.md +42 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits.js +1 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/inherits_browser.js +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/package.json +50 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/node_modules/inherits/test.js +25 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/http-errors/package.json +85 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/LICENSE +19 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/README.md +90 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/build/build.js +11 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/build/test.js +57 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/cli.js +8 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/mime.js +108 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/package.json +73 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/mime/types.json +1 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/ms/History.md +66 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/ms/LICENSE +20 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/ms/README.md +35 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/ms/index.js +125 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/ms/package.json +47 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/statuses/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/statuses/README.md +114 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/statuses/codes.json +64 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/statuses/index.js +60 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/node_modules/statuses/package.json +84 -0
- data/lib/webpack_rails/node_modules/express/node_modules/send/package.json +89 -0
- data/lib/webpack_rails/node_modules/express/node_modules/serve-static/HISTORY.md +284 -0
- data/lib/webpack_rails/node_modules/express/node_modules/serve-static/LICENSE +25 -0
- data/lib/webpack_rails/node_modules/express/node_modules/serve-static/README.md +235 -0
- data/lib/webpack_rails/node_modules/express/node_modules/serve-static/index.js +187 -0
- data/lib/webpack_rails/node_modules/express/node_modules/serve-static/package.json +83 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/HISTORY.md +180 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/README.md +132 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/index.js +262 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/media-typer/HISTORY.md +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/media-typer/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/media-typer/README.md +81 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/media-typer/index.js +270 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/media-typer/package.json +58 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/HISTORY.md +171 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/LICENSE +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/README.md +103 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/index.js +188 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/HISTORY.md +274 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/README.md +82 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/db.json +6474 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/index.js +11 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/node_modules/mime-db/package.json +94 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/node_modules/mime-types/package.json +84 -0
- data/lib/webpack_rails/node_modules/express/node_modules/type-is/package.json +93 -0
- data/lib/webpack_rails/node_modules/express/node_modules/utils-merge/LICENSE +20 -0
- data/lib/webpack_rails/node_modules/express/node_modules/utils-merge/README.md +34 -0
- data/lib/webpack_rails/node_modules/express/node_modules/utils-merge/index.js +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/utils-merge/package.json +58 -0
- data/lib/webpack_rails/node_modules/express/node_modules/vary/HISTORY.md +23 -0
- data/lib/webpack_rails/node_modules/express/node_modules/vary/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/express/node_modules/vary/README.md +91 -0
- data/lib/webpack_rails/node_modules/express/node_modules/vary/index.js +117 -0
- data/lib/webpack_rails/node_modules/express/node_modules/vary/package.json +72 -0
- data/lib/webpack_rails/node_modules/express/package.json +167 -0
- data/lib/webpack_rails/node_modules/is-array/History.md +11 -0
- data/lib/webpack_rails/node_modules/is-array/Makefile +11 -0
- data/lib/webpack_rails/node_modules/is-array/Readme.md +27 -0
- data/lib/webpack_rails/node_modules/is-array/component.json +13 -0
- data/lib/webpack_rails/node_modules/is-array/index.js +33 -0
- data/lib/webpack_rails/node_modules/is-array/package.json +41 -0
- data/lib/webpack_rails/node_modules/is-array/test/test.html +46 -0
- data/lib/webpack_rails/node_modules/is-object/LICENSE +19 -0
- data/lib/webpack_rails/node_modules/is-object/README.md +55 -0
- data/lib/webpack_rails/node_modules/is-object/index.js +5 -0
- data/lib/webpack_rails/node_modules/is-object/package.json +91 -0
- data/lib/webpack_rails/node_modules/is-object/test/index.js +23 -0
- data/lib/webpack_rails/node_modules/is-string/CHANGELOG.md +19 -0
- data/lib/webpack_rails/node_modules/is-string/LICENSE +22 -0
- data/lib/webpack_rails/node_modules/is-string/Makefile +61 -0
- data/lib/webpack_rails/node_modules/is-string/README.md +57 -0
- data/lib/webpack_rails/node_modules/is-string/index.js +20 -0
- data/lib/webpack_rails/node_modules/is-string/package.json +93 -0
- data/lib/webpack_rails/node_modules/is-string/test.js +36 -0
- data/lib/webpack_rails/node_modules/js-string-escape/CHANGELOG.md +9 -0
- data/lib/webpack_rails/node_modules/js-string-escape/LICENSE +21 -0
- data/lib/webpack_rails/node_modules/js-string-escape/README.md +44 -0
- data/lib/webpack_rails/node_modules/js-string-escape/index.js +22 -0
- data/lib/webpack_rails/node_modules/js-string-escape/package.json +63 -0
- data/lib/webpack_rails/node_modules/js-string-escape/test/test.js +43 -0
- data/lib/webpack_rails/node_modules/strip-ansi/index.js +6 -0
- data/lib/webpack_rails/node_modules/strip-ansi/license +21 -0
- data/lib/webpack_rails/node_modules/strip-ansi/node_modules/ansi-regex/index.js +4 -0
- data/lib/webpack_rails/node_modules/strip-ansi/node_modules/ansi-regex/license +21 -0
- data/lib/webpack_rails/node_modules/strip-ansi/node_modules/ansi-regex/package.json +86 -0
- data/lib/webpack_rails/node_modules/strip-ansi/node_modules/ansi-regex/readme.md +31 -0
- data/lib/webpack_rails/node_modules/strip-ansi/package.json +85 -0
- data/lib/webpack_rails/node_modules/strip-ansi/readme.md +33 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/README.md +109 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/client-overlay.js +35 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/client.js +131 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/example/README.md +15 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/example/client.js +30 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/example/index.html +18 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/example/package.json +14 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/example/server.js +41 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/example/webpack.config.js +22 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/helpers.js +8 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/middleware.js +83 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/History.md +20 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/License.md +19 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/Readme.md +15 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/decode.js +80 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/encode.js +64 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/index.js +4 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/package.json +96 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/test/common-index.js +3 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/test/index.js +210 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/querystring/test/tap-index.js +3 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/cli.js +47 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/index.js +6 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/node_modules/ansi-regex/index.js +4 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/node_modules/ansi-regex/license +21 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/node_modules/ansi-regex/package.json +86 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/node_modules/ansi-regex/readme.md +33 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/package.json +89 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/node_modules/strip-ansi/readme.md +43 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/package.json +58 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/process-update.js +105 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/test/client-test.js +81 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/test/helpers-test.js +22 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/test/middleware-test.js +188 -0
- data/lib/webpack_rails/node_modules/webpack-hot-middleware/test/mocha.opts +1 -0
- data/lib/webpack_rails/node_modules/xtend/LICENCE +19 -0
- data/lib/webpack_rails/node_modules/xtend/Makefile +4 -0
- data/lib/webpack_rails/node_modules/xtend/README.md +32 -0
- data/lib/webpack_rails/node_modules/xtend/immutable.js +17 -0
- data/lib/webpack_rails/node_modules/xtend/mutable.js +15 -0
- data/lib/webpack_rails/node_modules/xtend/package.json +88 -0
- data/lib/webpack_rails/node_modules/xtend/test.js +63 -0
- data/lib/webpack_rails/package.json +22 -0
- data/lib/webpack_rails/processor.rb +28 -9
- data/lib/webpack_rails/require_directive_processor.rb +51 -0
- data/lib/webpack_rails/sprockets_environment.rb +45 -0
- data/lib/webpack_rails/task.rb +51 -22
- data/lib/webpack_rails/webpack-task-dev-server.js +122 -0
- data/lib/webpack_rails/{webpack-task.js → webpack-task-watch.js} +0 -0
- data/lib/webpack_rails/webpack.rake +5 -5
- data/lib/webpack_rails.rb +1 -3
- metadata +346 -5
- data/lib/webpack_rails/sprockets_base_webpack.rb +0 -14
- data/lib/webpack_rails/sprockets_index_webpack.rb +0 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e009f00ab01652e47f2ca1462e8e61e3ee41c95c
|
4
|
+
data.tar.gz: e592fb608d969c6895979ae2d58383ba922697ad
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c365e87525fd250af593a13b3e1a8bfcaf7866a4930a84483bd28f802e3d35505b8d134138c92414b71815e0f50e86705c4440d47f52dec3c68df5101864d3b4
|
7
|
+
data.tar.gz: 04f589ed5015256957a7fb347b3671d8d984df7a7eda77a749b62a548f1609cd1b00208aee91210830ffc3d1f141746cca7614ced290b63e44adf1cd8ae0b415
|
@@ -0,0 +1,37 @@
|
|
1
|
+
var stripAnsi = require('strip-ansi');
|
2
|
+
var jsStringEscape = require('js-string-escape');
|
3
|
+
|
4
|
+
// expected to be installed by the gem consumer (eg. the app)
|
5
|
+
var RawSource = require('webpack/lib/RawSource');
|
6
|
+
|
7
|
+
// a webpack plugin to inject js which renders a message upon error
|
8
|
+
function ErrorMessagePlugin() {}
|
9
|
+
ErrorMessagePlugin.prototype.apply = function(compiler) {
|
10
|
+
compiler.plugin('emit', function(compilation, callback) {
|
11
|
+
if (compilation.errors.length > 0) {
|
12
|
+
var cleanedErrorMessage = cleanCompilationErrorMessages(compilation.errors);
|
13
|
+
var errorPageHeader = ''+
|
14
|
+
'<style>body { font-family: sans-serif; }</style>'+
|
15
|
+
'<h1>Webpack Build Error</h1>';
|
16
|
+
|
17
|
+
var errorJsCode = ''+
|
18
|
+
'document.body.className += " webpack-build-error";'+
|
19
|
+
'document.body.innerHTML = "'+errorPageHeader+'";\n'+
|
20
|
+
'var errorDisplay = document.createElement("pre");\n'+
|
21
|
+
'errorDisplay.textContent = "'+jsStringEscape(cleanedErrorMessage)+'";\n'+
|
22
|
+
'document.body.appendChild(errorDisplay);\n';
|
23
|
+
|
24
|
+
Object.keys(compilation.assets).forEach(function(assetName) {
|
25
|
+
compilation.assets[assetName] = new RawSource(errorJsCode)
|
26
|
+
});
|
27
|
+
}
|
28
|
+
callback();
|
29
|
+
}.bind(this));
|
30
|
+
};
|
31
|
+
|
32
|
+
var errorTypePattern = /ModuleBuildError:[^:]*: /g;
|
33
|
+
function cleanCompilationErrorMessages(errors) {
|
34
|
+
return stripAnsi(errors.join('\n\n')).replace(errorTypePattern, '');
|
35
|
+
}
|
36
|
+
|
37
|
+
module.exports = ErrorMessagePlugin;
|
data/lib/webpack_rails/engine.rb
CHANGED
@@ -1,19 +1,20 @@
|
|
1
|
-
require_relative './
|
1
|
+
require_relative './sprockets_environment'
|
2
2
|
|
3
3
|
module WebpackRails
|
4
4
|
class Engine < ::Rails::Engine
|
5
5
|
engine_name 'webpack'
|
6
6
|
|
7
|
+
config.webpack_rails = ActiveSupport::OrderedOptions.new
|
8
|
+
|
7
9
|
initializer :setup_webpack_rails, after: 'sprockets.environment', group: :all do |app|
|
10
|
+
WebpackRails::SprocketsEnvironment.enhance!(app.assets, app.config.webpack_rails)
|
11
|
+
|
8
12
|
# where [name].bundle.js files should be
|
9
13
|
app.assets.append_path Rails.root.join('tmp/webpack/bundles')
|
10
14
|
|
11
|
-
# process
|
12
|
-
app.assets.register_preprocessor('application/javascript', WebpackRails::Processor)
|
13
|
-
|
14
15
|
# stop sprockets from ruining inline sourcemaps in dev
|
15
16
|
if Rails.env.development?
|
16
|
-
app.assets.unregister_postprocessor 'application/javascript', Sprockets::SafetyColons
|
17
|
+
app.assets.unregister_postprocessor 'application/javascript', ::Sprockets::SafetyColons
|
17
18
|
end
|
18
19
|
end
|
19
20
|
|
@@ -0,0 +1,35 @@
|
|
1
|
+
# contributing to `cors`
|
2
|
+
|
3
|
+
CORS is a node.js package for providing a [connect](http://www.senchalabs.org/connect/)/[express](http://expressjs.com/) middleware that can be used to enable [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) with various options. Learn more about the project in [the README](README.md).
|
4
|
+
|
5
|
+
[![build status](https://secure.travis-ci.org/TroyGoode/node-cors.png)](http://travis-ci.org/TroyGoode/node-cors)
|
6
|
+
|
7
|
+
## The CORS Spec
|
8
|
+
|
9
|
+
[http://www.w3.org/TR/cors/](http://www.w3.org/TR/cors/)
|
10
|
+
|
11
|
+
## Pull Requests Welcome
|
12
|
+
|
13
|
+
* Include `'use strict';` in every javascript file.
|
14
|
+
* 2 space indentation.
|
15
|
+
* Please run the testing steps below before submitting.
|
16
|
+
|
17
|
+
## Testing
|
18
|
+
|
19
|
+
```bash
|
20
|
+
$ npm install
|
21
|
+
$ npm test
|
22
|
+
```
|
23
|
+
|
24
|
+
## Interactive Testing Harness
|
25
|
+
|
26
|
+
[http://node-cors-client.herokuapp.com](http://node-cors-client.herokuapp.com)
|
27
|
+
|
28
|
+
Related git repositories:
|
29
|
+
|
30
|
+
* [https://github.com/TroyGoode/node-cors-server](https://github.com/TroyGoode/node-cors-server)
|
31
|
+
* [https://github.com/TroyGoode/node-cors-client](https://github.com/TroyGoode/node-cors-client)
|
32
|
+
|
33
|
+
## License
|
34
|
+
|
35
|
+
[MIT License](http://www.opensource.org/licenses/mit-license.php)
|
@@ -0,0 +1,9 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013 Troy Goode <troygoode@gmail.com>
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
6
|
+
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
8
|
+
|
9
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -0,0 +1,192 @@
|
|
1
|
+
# `cors`
|
2
|
+
|
3
|
+
CORS is a node.js package for providing a [Connect](http://www.senchalabs.org/connect/)/[Express](http://expressjs.com/) middleware that can be used to enable [CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) with various options.
|
4
|
+
|
5
|
+
**[Follow me (@troygoode) on Twitter!](https://twitter.com/intent/user?screen_name=troygoode)**
|
6
|
+
|
7
|
+
[![NPM](https://nodei.co/npm/cors.png?downloads=true&stars=true)](https://nodei.co/npm/cors/)
|
8
|
+
|
9
|
+
[![build status](https://secure.travis-ci.org/expressjs/cors.png)](http://travis-ci.org/expressjs/cors)
|
10
|
+
* [Installation](#installation)
|
11
|
+
* [Usage](#usage)
|
12
|
+
* [Simple Usage](#simple-usage-enable-all-cors-requests)
|
13
|
+
* [Enable CORS for a Single Route](#enable-cors-for-a-single-route)
|
14
|
+
* [Configuring CORS](#configuring-cors)
|
15
|
+
* [Configuring CORS Asynchronously](#configuring-cors-asynchronously)
|
16
|
+
* [Enabling CORS Pre-Flight](#enabling-cors-pre-flight)
|
17
|
+
* [Configuration Options](#configuration-options)
|
18
|
+
* [Demo](#demo)
|
19
|
+
* [License](#license)
|
20
|
+
* [Author](#author)
|
21
|
+
|
22
|
+
## Installation (via [npm](https://npmjs.org/package/cors))
|
23
|
+
|
24
|
+
```bash
|
25
|
+
$ npm install cors
|
26
|
+
```
|
27
|
+
|
28
|
+
## Usage
|
29
|
+
|
30
|
+
### Simple Usage (Enable *All* CORS Requests)
|
31
|
+
|
32
|
+
```javascript
|
33
|
+
var express = require('express')
|
34
|
+
, cors = require('cors')
|
35
|
+
, app = express();
|
36
|
+
|
37
|
+
app.use(cors());
|
38
|
+
|
39
|
+
app.get('/products/:id', function(req, res, next){
|
40
|
+
res.json({msg: 'This is CORS-enabled for all origins!'});
|
41
|
+
});
|
42
|
+
|
43
|
+
app.listen(80, function(){
|
44
|
+
console.log('CORS-enabled web server listening on port 80');
|
45
|
+
});
|
46
|
+
```
|
47
|
+
|
48
|
+
### Enable CORS for a Single Route
|
49
|
+
|
50
|
+
```javascript
|
51
|
+
var express = require('express')
|
52
|
+
, cors = require('cors')
|
53
|
+
, app = express();
|
54
|
+
|
55
|
+
app.get('/products/:id', cors(), function(req, res, next){
|
56
|
+
res.json({msg: 'This is CORS-enabled for all origins!'});
|
57
|
+
});
|
58
|
+
|
59
|
+
app.listen(80, function(){
|
60
|
+
console.log('CORS-enabled web server listening on port 80');
|
61
|
+
});
|
62
|
+
```
|
63
|
+
|
64
|
+
### Configuring CORS
|
65
|
+
|
66
|
+
```javascript
|
67
|
+
var express = require('express')
|
68
|
+
, cors = require('cors')
|
69
|
+
, app = express();
|
70
|
+
|
71
|
+
var corsOptions = {
|
72
|
+
origin: 'http://example.com'
|
73
|
+
};
|
74
|
+
|
75
|
+
app.get('/products/:id', cors(corsOptions), function(req, res, next){
|
76
|
+
res.json({msg: 'This is CORS-enabled for only example.com.'});
|
77
|
+
});
|
78
|
+
|
79
|
+
app.listen(80, function(){
|
80
|
+
console.log('CORS-enabled web server listening on port 80');
|
81
|
+
});
|
82
|
+
```
|
83
|
+
|
84
|
+
### Configuring CORS w/ Dynamic Origin
|
85
|
+
|
86
|
+
```javascript
|
87
|
+
var express = require('express')
|
88
|
+
, cors = require('cors')
|
89
|
+
, app = express();
|
90
|
+
|
91
|
+
var whitelist = ['http://example1.com', 'http://example2.com'];
|
92
|
+
var corsOptions = {
|
93
|
+
origin: function(origin, callback){
|
94
|
+
var originIsWhitelisted = whitelist.indexOf(origin) !== -1;
|
95
|
+
callback(null, originIsWhitelisted);
|
96
|
+
}
|
97
|
+
};
|
98
|
+
|
99
|
+
app.get('/products/:id', cors(corsOptions), function(req, res, next){
|
100
|
+
res.json({msg: 'This is CORS-enabled for a whitelisted domain.'});
|
101
|
+
});
|
102
|
+
|
103
|
+
app.listen(80, function(){
|
104
|
+
console.log('CORS-enabled web server listening on port 80');
|
105
|
+
});
|
106
|
+
```
|
107
|
+
|
108
|
+
### Enabling CORS Pre-Flight
|
109
|
+
|
110
|
+
Certain CORS requests are considered 'complex' and require an initial
|
111
|
+
`OPTIONS` request (called the "pre-flight request"). An example of a
|
112
|
+
'complex' CORS request is one that uses an HTTP verb other than
|
113
|
+
GET/HEAD/POST (such as DELETE) or that uses custom headers. To enable
|
114
|
+
pre-flighting, you must add a new OPTIONS handler for the route you want
|
115
|
+
to support:
|
116
|
+
|
117
|
+
```javascript
|
118
|
+
var express = require('express')
|
119
|
+
, cors = require('cors')
|
120
|
+
, app = express();
|
121
|
+
|
122
|
+
app.options('/products/:id', cors()); // enable pre-flight request for DELETE request
|
123
|
+
app.del('/products/:id', cors(), function(req, res, next){
|
124
|
+
res.json({msg: 'This is CORS-enabled for all origins!'});
|
125
|
+
});
|
126
|
+
|
127
|
+
app.listen(80, function(){
|
128
|
+
console.log('CORS-enabled web server listening on port 80');
|
129
|
+
});
|
130
|
+
```
|
131
|
+
|
132
|
+
You can also enable pre-flight across-the-board like so:
|
133
|
+
|
134
|
+
```
|
135
|
+
app.options('*', cors()); // include before other routes
|
136
|
+
```
|
137
|
+
|
138
|
+
### Configuring CORS Asynchronously
|
139
|
+
|
140
|
+
```javascript
|
141
|
+
var express = require('express')
|
142
|
+
, cors = require('cors')
|
143
|
+
, app = express();
|
144
|
+
|
145
|
+
var whitelist = ['http://example1.com', 'http://example2.com'];
|
146
|
+
var corsOptionsDelegate = function(req, callback){
|
147
|
+
var corsOptions;
|
148
|
+
if(whitelist.indexOf(req.header('Origin')) !== -1){
|
149
|
+
corsOptions = { origin: true }; // reflect (enable) the requested origin in the CORS response
|
150
|
+
}else{
|
151
|
+
corsOptions = { origin: false }; // disable CORS for this request
|
152
|
+
}
|
153
|
+
callback(null, corsOptions); // callback expects two parameters: error and options
|
154
|
+
};
|
155
|
+
|
156
|
+
app.get('/products/:id', cors(corsOptionsDelegate), function(req, res, next){
|
157
|
+
res.json({msg: 'This is CORS-enabled for a whitelisted domain.'});
|
158
|
+
});
|
159
|
+
|
160
|
+
app.listen(80, function(){
|
161
|
+
console.log('CORS-enabled web server listening on port 80');
|
162
|
+
});
|
163
|
+
```
|
164
|
+
|
165
|
+
## Configuration Options
|
166
|
+
|
167
|
+
* `origin`: Configures the **Access-Control-Allow-Origin** CORS header. Expects a string (ex: "http://example.com"). Set to `true` to reflect the [request origin](http://tools.ietf.org/html/draft-abarth-origin-09), as defined by `req.header('Origin')`. Set to `false` to disable CORS. Can also be set to a function, which takes the request origin as the first parameter and a callback (which expects the signature `err [object], allow [bool]`) as the second. Finally, it can also be a regular expression (`/example\.com$/`) or an array of regular expressions and/or strings to match against.
|
168
|
+
* `methods`: Configures the **Access-Control-Allow-Methods** CORS header. Expects a comma-delimited string (ex: 'GET,PUT,POST') or an array (ex: `['GET', 'PUT', 'POST']`).
|
169
|
+
* `allowedHeaders`: Configures the **Access-Control-Allow-Headers** CORS header. Expects a comma-delimited string (ex: 'Content-Type,Authorization') or an array (ex: `['Content-Type', 'Authorization']`). If not specified, defaults to reflecting the headers specified in the request's **Access-Control-Request-Headers** header.
|
170
|
+
* `exposedHeaders`: Configures the **Access-Control-Expose-Headers** CORS header. Expects a comma-delimited string (ex: 'Content-Range,X-Content-Range') or an array (ex: `['Content-Range', 'X-Content-Range']`). If not specified, no custom headers are exposed.
|
171
|
+
* `credentials`: Configures the **Access-Control-Allow-Credentials** CORS header. Set to `true` to pass the header, otherwise it is omitted.
|
172
|
+
* `maxAge`: Configures the **Access-Control-Allow-Max-Age** CORS header. Set to an integer to pass the header, otherwise it is omitted.
|
173
|
+
* `preflightContinue`: Pass the CORS preflight response to the next handler.
|
174
|
+
|
175
|
+
For details on the effect of each CORS header, [read this article on HTML5 Rocks](http://www.html5rocks.com/en/tutorials/cors/).
|
176
|
+
|
177
|
+
## Demo
|
178
|
+
|
179
|
+
A demo that illustrates CORS working (and not working) using jQuery is available here: [http://node-cors-client.herokuapp.com/](http://node-cors-client.herokuapp.com/)
|
180
|
+
|
181
|
+
Code for that demo can be found here:
|
182
|
+
|
183
|
+
* Client: [https://github.com/TroyGoode/node-cors-client](https://github.com/TroyGoode/node-cors-client)
|
184
|
+
* Server: [https://github.com/TroyGoode/node-cors-server](https://github.com/TroyGoode/node-cors-server)
|
185
|
+
|
186
|
+
## License
|
187
|
+
|
188
|
+
[MIT License](http://www.opensource.org/licenses/mit-license.php)
|
189
|
+
|
190
|
+
## Author
|
191
|
+
|
192
|
+
[Troy Goode](https://github.com/TroyGoode) ([troygoode@gmail.com](mailto:troygoode@gmail.com))
|
@@ -0,0 +1,242 @@
|
|
1
|
+
(function () {
|
2
|
+
|
3
|
+
'use strict';
|
4
|
+
|
5
|
+
var vary = require('vary');
|
6
|
+
|
7
|
+
var defaults = {
|
8
|
+
origin: '*',
|
9
|
+
methods: 'GET,HEAD,PUT,PATCH,POST,DELETE',
|
10
|
+
preflightContinue: false
|
11
|
+
};
|
12
|
+
|
13
|
+
function isString(s) {
|
14
|
+
return typeof s === 'string' || s instanceof String;
|
15
|
+
}
|
16
|
+
|
17
|
+
function isOriginAllowed(origin, allowedOrigin) {
|
18
|
+
if (Array.isArray(allowedOrigin)) {
|
19
|
+
for (var i = 0; i < allowedOrigin.length; ++i) {
|
20
|
+
if (isOriginAllowed(origin, allowedOrigin[i])) {
|
21
|
+
return true;
|
22
|
+
}
|
23
|
+
}
|
24
|
+
return false;
|
25
|
+
} else if (isString(allowedOrigin)) {
|
26
|
+
return origin === allowedOrigin;
|
27
|
+
} else if (allowedOrigin instanceof RegExp) {
|
28
|
+
return allowedOrigin.test(origin);
|
29
|
+
} else {
|
30
|
+
return !!allowedOrigin;
|
31
|
+
}
|
32
|
+
}
|
33
|
+
|
34
|
+
function configureOrigin(options, req) {
|
35
|
+
var requestOrigin = req.headers.origin,
|
36
|
+
headers = [],
|
37
|
+
isAllowed;
|
38
|
+
|
39
|
+
if (!options.origin || options.origin === '*') {
|
40
|
+
// allow any origin
|
41
|
+
headers.push([{
|
42
|
+
key: 'Access-Control-Allow-Origin',
|
43
|
+
value: '*'
|
44
|
+
}]);
|
45
|
+
} else if (isString(options.origin)) {
|
46
|
+
// fixed origin
|
47
|
+
headers.push([{
|
48
|
+
key: 'Access-Control-Allow-Origin',
|
49
|
+
value: options.origin
|
50
|
+
}]);
|
51
|
+
headers.push([{
|
52
|
+
key: 'Vary',
|
53
|
+
value: 'Origin'
|
54
|
+
}]);
|
55
|
+
} else {
|
56
|
+
isAllowed = isOriginAllowed(requestOrigin, options.origin);
|
57
|
+
// reflect origin
|
58
|
+
headers.push([{
|
59
|
+
key: 'Access-Control-Allow-Origin',
|
60
|
+
value: isAllowed ? requestOrigin : false
|
61
|
+
}]);
|
62
|
+
if (isAllowed) {
|
63
|
+
headers.push([{
|
64
|
+
key: 'Vary',
|
65
|
+
value: 'Origin'
|
66
|
+
}]);
|
67
|
+
}
|
68
|
+
}
|
69
|
+
|
70
|
+
return headers;
|
71
|
+
}
|
72
|
+
|
73
|
+
function configureMethods(options) {
|
74
|
+
var methods = options.methods || defaults.methods;
|
75
|
+
if (methods.join) {
|
76
|
+
methods = options.methods.join(','); // .methods is an array, so turn it into a string
|
77
|
+
}
|
78
|
+
return {
|
79
|
+
key: 'Access-Control-Allow-Methods',
|
80
|
+
value: methods
|
81
|
+
};
|
82
|
+
}
|
83
|
+
|
84
|
+
function configureCredentials(options) {
|
85
|
+
if (options.credentials === true) {
|
86
|
+
return {
|
87
|
+
key: 'Access-Control-Allow-Credentials',
|
88
|
+
value: 'true'
|
89
|
+
};
|
90
|
+
}
|
91
|
+
return null;
|
92
|
+
}
|
93
|
+
|
94
|
+
function configureAllowedHeaders(options, req) {
|
95
|
+
var headers = options.allowedHeaders || options.headers;
|
96
|
+
if (!headers) {
|
97
|
+
headers = req.headers['access-control-request-headers']; // .headers wasn't specified, so reflect the request headers
|
98
|
+
} else if (headers.join) {
|
99
|
+
headers = headers.join(','); // .headers is an array, so turn it into a string
|
100
|
+
}
|
101
|
+
if (headers && headers.length) {
|
102
|
+
return {
|
103
|
+
key: 'Access-Control-Allow-Headers',
|
104
|
+
value: headers
|
105
|
+
};
|
106
|
+
}
|
107
|
+
return null;
|
108
|
+
}
|
109
|
+
|
110
|
+
function configureExposedHeaders(options) {
|
111
|
+
var headers = options.exposedHeaders;
|
112
|
+
if (!headers) {
|
113
|
+
return null;
|
114
|
+
} else if (headers.join) {
|
115
|
+
headers = headers.join(','); // .headers is an array, so turn it into a string
|
116
|
+
}
|
117
|
+
if (headers && headers.length) {
|
118
|
+
return {
|
119
|
+
key: 'Access-Control-Expose-Headers',
|
120
|
+
value: headers
|
121
|
+
};
|
122
|
+
}
|
123
|
+
return null;
|
124
|
+
}
|
125
|
+
|
126
|
+
function configureMaxAge(options) {
|
127
|
+
var maxAge = options.maxAge && options.maxAge.toString();
|
128
|
+
if (maxAge && maxAge.length) {
|
129
|
+
return {
|
130
|
+
key: 'Access-Control-Max-Age',
|
131
|
+
value: maxAge
|
132
|
+
};
|
133
|
+
}
|
134
|
+
return null;
|
135
|
+
}
|
136
|
+
|
137
|
+
function applyHeaders(headers, res) {
|
138
|
+
for (var i = 0, n = headers.length; i < n; i++) {
|
139
|
+
var header = headers[i];
|
140
|
+
if (header) {
|
141
|
+
if (Array.isArray(header)) {
|
142
|
+
applyHeaders(header, res);
|
143
|
+
} else if (header.key === 'Vary' && header.value) {
|
144
|
+
vary(res, header.value);
|
145
|
+
} else if (header.value) {
|
146
|
+
res.setHeader(header.key, header.value);
|
147
|
+
}
|
148
|
+
}
|
149
|
+
}
|
150
|
+
}
|
151
|
+
|
152
|
+
function cors(options, req, res, next) {
|
153
|
+
var headers = [],
|
154
|
+
method = req.method && req.method.toUpperCase && req.method.toUpperCase();
|
155
|
+
|
156
|
+
if (method === 'OPTIONS') {
|
157
|
+
// preflight
|
158
|
+
headers.push(configureOrigin(options, req));
|
159
|
+
headers.push(configureCredentials(options, req));
|
160
|
+
headers.push(configureMethods(options, req));
|
161
|
+
headers.push(configureAllowedHeaders(options, req));
|
162
|
+
headers.push(configureMaxAge(options, req));
|
163
|
+
headers.push(configureExposedHeaders(options, req));
|
164
|
+
applyHeaders(headers, res);
|
165
|
+
|
166
|
+
if (options.preflightContinue ) {
|
167
|
+
next();
|
168
|
+
} else {
|
169
|
+
res.statusCode = 204;
|
170
|
+
res.end();
|
171
|
+
}
|
172
|
+
} else {
|
173
|
+
// actual response
|
174
|
+
headers.push(configureOrigin(options, req));
|
175
|
+
headers.push(configureCredentials(options, req));
|
176
|
+
headers.push(configureExposedHeaders(options, req));
|
177
|
+
applyHeaders(headers, res);
|
178
|
+
next();
|
179
|
+
}
|
180
|
+
}
|
181
|
+
|
182
|
+
function middlewareWrapper(o) {
|
183
|
+
// if no options were passed in, use the defaults
|
184
|
+
if (!o) {
|
185
|
+
o = {};
|
186
|
+
}
|
187
|
+
if (o.origin === undefined) {
|
188
|
+
o.origin = defaults.origin;
|
189
|
+
}
|
190
|
+
if (o.methods === undefined) {
|
191
|
+
o.methods = defaults.methods;
|
192
|
+
}
|
193
|
+
if (o.preflightContinue === undefined) {
|
194
|
+
o.preflightContinue = defaults.preflightContinue;
|
195
|
+
}
|
196
|
+
|
197
|
+
// if options are static (either via defaults or custom options passed in), wrap in a function
|
198
|
+
var optionsCallback = null;
|
199
|
+
if (typeof o === 'function') {
|
200
|
+
optionsCallback = o;
|
201
|
+
} else {
|
202
|
+
optionsCallback = function (req, cb) {
|
203
|
+
cb(null, o);
|
204
|
+
};
|
205
|
+
}
|
206
|
+
|
207
|
+
return function (req, res, next) {
|
208
|
+
optionsCallback(req, function (err, options) {
|
209
|
+
if (err) {
|
210
|
+
next(err);
|
211
|
+
} else {
|
212
|
+
var originCallback = null;
|
213
|
+
if (options.origin && typeof options.origin === 'function') {
|
214
|
+
originCallback = options.origin;
|
215
|
+
} else if (options.origin) {
|
216
|
+
originCallback = function (origin, cb) {
|
217
|
+
cb(null, options.origin);
|
218
|
+
};
|
219
|
+
}
|
220
|
+
|
221
|
+
if (originCallback) {
|
222
|
+
originCallback(req.headers.origin, function (err2, origin) {
|
223
|
+
if (err2 || !origin) {
|
224
|
+
next(err2);
|
225
|
+
} else {
|
226
|
+
var corsOptions = Object.create(options);
|
227
|
+
corsOptions.origin = origin;
|
228
|
+
cors(corsOptions, req, res, next);
|
229
|
+
}
|
230
|
+
});
|
231
|
+
} else {
|
232
|
+
next();
|
233
|
+
}
|
234
|
+
}
|
235
|
+
});
|
236
|
+
};
|
237
|
+
}
|
238
|
+
|
239
|
+
// can pass either an options hash, an options delegate, or nothing
|
240
|
+
module.exports = middlewareWrapper;
|
241
|
+
|
242
|
+
}());
|
@@ -0,0 +1,29 @@
|
|
1
|
+
1.1.0 / 2015-09-29
|
2
|
+
==================
|
3
|
+
|
4
|
+
* Only accept valid field names in the `field` argument
|
5
|
+
- Ensures the resulting string is a valid HTTP header value
|
6
|
+
|
7
|
+
1.0.1 / 2015-07-08
|
8
|
+
==================
|
9
|
+
|
10
|
+
* Fix setting empty header from empty `field`
|
11
|
+
* perf: enable strict mode
|
12
|
+
* perf: remove argument reassignments
|
13
|
+
|
14
|
+
1.0.0 / 2014-08-10
|
15
|
+
==================
|
16
|
+
|
17
|
+
* Accept valid `Vary` header string as `field`
|
18
|
+
* Add `vary.append` for low-level string manipulation
|
19
|
+
* Move to `jshttp` orgainzation
|
20
|
+
|
21
|
+
0.1.0 / 2014-06-05
|
22
|
+
==================
|
23
|
+
|
24
|
+
* Support array of fields to set
|
25
|
+
|
26
|
+
0.0.0 / 2014-06-04
|
27
|
+
==================
|
28
|
+
|
29
|
+
* Initial release
|
@@ -0,0 +1,22 @@
|
|
1
|
+
(The MIT License)
|
2
|
+
|
3
|
+
Copyright (c) 2014-2015 Douglas Christopher Wilson
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
'Software'), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
19
|
+
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
20
|
+
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
21
|
+
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
22
|
+
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|