{
  "name": "grunt-contrib-connect",
  "description": "Start a connect web server.",
  "version": "0.8.0",
  "homepage": "https://github.com/gruntjs/grunt-contrib-connect",
  "author": {
    "name": "Grunt Team",
    "url": "http://gruntjs.com/"
  },
  "repository": {
    "type": "git",
    "url": "git://github.com/gruntjs/grunt-contrib-connect.git"
  },
  "bugs": {
    "url": "https://github.com/gruntjs/grunt-contrib-connect/issues"
  },
  "licenses": [
    {
      "type": "MIT",
      "url": "https://github.com/gruntjs/grunt-contrib-connect/blob/master/LICENSE-MIT"
    }
  ],
  "engines": {
    "node": ">= 0.8.0"
  },
  "scripts": {
    "test": "grunt jshint test"
  },
  "dependencies": {
    "connect": "~2.19.5",
    "connect-livereload": "~0.4.0",
    "open": "0.0.5",
    "portscanner": "~0.2.3",
    "async": "~0.9.0"
  },
  "devDependencies": {
    "grunt-contrib-jshint": "~0.10.0",
    "grunt-contrib-nodeunit": "~0.4.0",
    "grunt-contrib-internal": "~0.4.10",
    "grunt": "~0.4.5",
    "grunt-cli": "~0.1.13"
  },
  "peerDependencies": {
    "grunt": "~0.4.0"
  },
  "keywords": [
    "gruntplugin",
    "server",
    "connect",
    "http"
  ],
  "files": [
    "tasks",
    "LICENSE-MIT"
  ],
  "readme": "# grunt-contrib-connect v0.8.0 [![Build Status: Linux](https://travis-ci.org/gruntjs/grunt-contrib-connect.png?branch=master)](https://travis-ci.org/gruntjs/grunt-contrib-connect)\n\n> Start a connect web server.\n\n\n\n## Getting Started\nThis plugin requires Grunt `~0.4.0`\n\nIf you haven't used [Grunt](http://gruntjs.com/) before, be sure to check out the [Getting Started](http://gruntjs.com/getting-started) guide, as it explains how to create a [Gruntfile](http://gruntjs.com/sample-gruntfile) as well as install and use Grunt plugins. Once you're familiar with that process, you may install this plugin with this command:\n\n```shell\nnpm install grunt-contrib-connect --save-dev\n```\n\nOnce the plugin has been installed, it may be enabled inside your Gruntfile with this line of JavaScript:\n\n```js\ngrunt.loadNpmTasks('grunt-contrib-connect');\n```\n\n\n\n\n## Connect task\n_Run this task with the `grunt connect` command._\n\nNote that this server only runs as long as grunt is running. Once grunt's tasks have completed, the web server stops. This behavior can be changed with the [keepalive](#keepalive) option, and can be enabled ad-hoc by running the task like `grunt connect:keepalive`.\n\nThis task was designed to be used in conjunction with another task that is run immediately afterwards, like the [grunt-contrib-qunit plugin](https://github.com/gruntjs/grunt-contrib-qunit) `qunit` task.\n### Options\n\n#### port\nType: `Integer`  \nDefault: `8000`\n\nThe port on which the webserver will respond. The task will fail if the specified port is already in use. You can use the special values `0` or `'?'` to use a system-assigned port.\n\n#### protocol\nType: `String`  \nDefault: `'http'`\n\nMay be `'http'` or `'https'`.\n\n#### hostname\nType: `String`  \nDefault: `'0.0.0.0'`\n\nThe hostname the webserver will use.\n\nSetting it to `'*'` will make the server accessible from anywhere.\n\n#### base\nType: `String` or `Array`  \nDefault: `'.'`\n\nThe base (or root) directory from which files will be served. Defaults to the project Gruntfile's directory.\n\nCan be an array of bases to serve multiple directories. The last base given will be the directory to become browse-able.\n\n#### directory\nType: `String`  \nDefault: `null`\n\nSet to the directory you wish to be browse-able. Used to override the `base` option browse-able directory.\n\n#### keepalive\nType: `Boolean`  \nDefault: `false`\n\nKeep the server alive indefinitely. Note that if this option is enabled, any tasks specified after this task will _never run_. By default, once grunt's tasks have completed, the web server stops. This option changes that behavior.\n\nThis option can also be enabled ad-hoc by running the task like `grunt connect:targetname:keepalive`\n\n#### debug\nType: `Boolean`  \nDefault: `false`\n\nSet the `debug` option to true to enable logging instead of using the `--debug` flag.\n\n#### livereload\nType: `Boolean` or `Number`  \nDefault: `false`\n\nSet to `true` or a port number to inject a live reload script tag into your page using [connect-livereload](https://github.com/intesso/connect-livereload).\n\n*This does not perform live reloading. It is intended to be used in tandem with grunt-contrib-watch or another task that will trigger a live reload server upon files changing.*\n\n#### open\nType: `Boolean` or `String` or `Object`\nDefault: `false`\n\nOpen the served page in your default browser. Specifying `true` opens the default server URL, specifying a URL opens that URL or specify an object with the following keys to configure open directly (each are optional):\n\n```js\n{\n  target: 'http://localhost:8000', // target url to open\n  appName: 'open', // name of the app that opens, ie: open, start, xdg-open\n  callback: function() {} // called when the app has opened\n}\n```\n\n#### useAvailablePort\n  Type: `Boolean`\n  Default: `false`\n\nIf `true` the task will look for the next available port after the set `port` option.\n\n#### onCreateServer\nType: `Function` or `Array`\nDefault: `null`\n\nA function to be called after the server object is created, to allow integrating libraries that need access to connect's server object. A Socket.IO example:\n\n```js\ngrunt.initConfig({\n  connect: {\n    server: {\n      options: {\n        port: 8000,\n        hostname: '*',\n        onCreateServer: function(server, connect, options) {\n          var io = require('socket.io').listen(server);\n          io.sockets.on('connection', function(socket) {\n            // do something with socket\n          });\n        }\n      }\n    }\n  }\n});\n```\n\n#### middleware\nType: `Function` or `Array`\nDefault: `Array` of connect middlewares that use `options.base` for static files and directory browsing\n\nAs an `Array`:\n\n```js\ngrunt.initConfig({\n  connect: {\n    server: {\n      options: {\n        middleware: [\n          function myMiddleware(req, res, next) {\n            res.end('Hello, world!');\n          }\n        ],\n      },\n    },\n  },\n});\n```\n\nAs a `function`:\n\n```js\ngrunt.initConfig({\n  connect: {\n    server: {\n      options: {\n        middleware: function(connect, options, middlewares) {\n          // inject a custom middleware into the array of default middlewares\n          middlewares.push(function(req, res, next) {\n            if (req.url !== '/hello/world') return next();\n\n            res.end('Hello, world from port #' + options.port + '!');\n          });\n\n          return middlewares;\n        },\n      },\n    },\n  },\n});\n```\n\nLets you add in your own Connect middlewares. This option expects a function that returns an array of middlewares. See the [project Gruntfile][] and [project unit tests][] for a usage example.\n\n[project Gruntfile]: Gruntfile.js\n[project unit tests]: test/connect_test.js\n\n### Usage examples\n\n#### Basic Use\nIn this example, `grunt connect` (or more verbosely, `grunt connect:server`) will start a static web server at `http://localhost:9001/`, with its base path set to the `www-root` directory relative to the gruntfile, and any tasks run afterwards will be able to access it.\n\n```javascript\n// Project configuration.\ngrunt.initConfig({\n  connect: {\n    server: {\n      options: {\n        port: 9001,\n        base: 'www-root'\n      }\n    }\n  }\n});\n```\n\nIf you want your web server to use the default options, just omit the `options` object. You still need to specify a target (`uses_defaults` in this example), but the target's configuration object can otherwise be empty or nonexistent. In this example, `grunt connect` (or more verbosely, `grunt connect:uses_defaults`) will start a static web server using the default options.\n\n```javascript\n// Project configuration.\ngrunt.initConfig({\n  connect: {\n    uses_defaults: {}\n  }\n});\n```\n\n#### Multiple Servers\nYou can specify multiple servers to be run alone or simultaneously by creating a target for each server. In this example, running either `grunt connect:site1` or `grunt connect:site2` will  start the appropriate web server, but running `grunt connect` will run _both_. Note that any server for which the [keepalive](#keepalive) option is specified will prevent _any_ task or target from running after it.\n\n```javascript\n// Project configuration.\ngrunt.initConfig({\n  connect: {\n    site1: {\n      options: {\n        port: 9000,\n        base: 'www-roots/site1'\n      }\n    },\n    site2: {\n      options: {\n        port: 9001,\n        base: 'www-roots/site2'\n      }\n    }\n  }\n});\n```\n\n#### Roll Your Own\nLike the [Basic Use](#basic-use) example, this example will start a static web server at `http://localhost:9001/`, with its base path set to the `www-root` directory relative to the gruntfile. Unlike the other example, this is done by creating a brand new task. in fact, this plugin isn't even installed!\n\n```javascript\n// Project configuration.\ngrunt.initConfig({ /* Nothing needed here! */ });\n\n// After running \"npm install connect --save-dev\" to add connect as a dev\n// dependency of your project, you can require it in your gruntfile with:\nvar connect = require('connect');\n\n// Now you can define a \"connect\" task that starts a webserver, using the\n// connect lib, with whatever options and configuration you need:\ngrunt.registerTask('connect', 'Start a custom static web server.', function() {\n  grunt.log.writeln('Starting static web server in \"www-root\" on port 9001.');\n  connect(connect.static('www-root')).listen(9001);\n});\n```\n\n#### Support for HTTPS\n\nA default certificate authority, certificate and key file are provided and pre-\nconfigured for use when `protocol` has been set to `https`.\n\nNOTE: No passphrase set for the certificate.\nIf you are getting warnings in Google Chrome, add 'server.crt' (from 'node_modules/tasks/certs')\nto your keychain.\nIn OS X, after you add 'server.crt', right click on the certificate,\nselect 'Get Info' - 'Trust' - 'Always Trust', close window, restart Chrome.\n\n###### Advanced HTTPS config\n\nIf the default certificate setup is unsuitable for your environment, OpenSSL\ncan be used to create a set of self-signed certificates with a local ca root.\n\n```shell\n### Create ca.key, use a password phrase when asked\n### When asked 'Common Name (e.g. server FQDN or YOUR name) []:' use your hostname, i.e 'mysite.dev'\nopenssl genrsa -des3 -out ca.key 1024\nopenssl req -new -key ca.key -out ca.csr\nopenssl x509 -req -days 365 -in ca.csr -out ca.crt -signkey ca.key\n\n### Create server certificate\nopenssl genrsa -des3 -out server.key 1024\nopenssl req -new -key server.key -out server.csr\n\n### Remove password from the certificate\ncp server.key server.key.org\nopenssl rsa -in server.key.org -out server.key\n\n### Generate self-siged certificate\nopenssl x509 -req -days 365 -in server.csr -signkey server.key -out server.crt\n```\n\nFor more details on the various options that can be set when configuring SSL,\nplease see the Node documentation for [TLS][].\n\nGrunt configuration would become\n\n```javascript\n// Project configuration.\ngrunt.initConfig({\n  connect: {\n    server: {\n      options: {\n        protocol: 'https',\n        port: 8443,\n        key: grunt.file.read('server.key').toString(),\n        cert: grunt.file.read('server.crt').toString(),\n        ca: grunt.file.read('ca.crt').toString()\n      },\n    },\n  },\n});\n```\n\n[TLS]: http://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener\n\n#### Grunt Events\nThe connect plugin will emit a grunt event, `connect.{taskName}.listening`, once the server has started. You can listen for this event to run things against a keepalive server, for example:\n\n```javascript\ngrunt.registerTask('jasmine-server', 'start web server for jasmine tests in browser', function() {\n  grunt.task.run('jasmine:tests:build');\n\n  grunt.event.once('connect.tests.listening', function(host, port) {\n    var specRunnerUrl = 'http://' + host + ':' + port + '/_SpecRunner.html';\n    grunt.log.writeln('Jasmine specs available at: ' + specRunnerUrl);\n    require('open')(specRunnerUrl);\n  });\n\n  grunt.task.run('connect:tests:keepalive');\n});\n```\n\n\n## Release History\n\n * 2014-06-09   v0.8.0   Update connect and connect-livereload.\n * 2014-02-27   v0.7.1   Fixes issue with the '*' hostname option.\n * 2014-02-18   v0.7.0   Update connect to ~2.13.0. Default hostname switched to '0.0.0.0'. Modified options.middleware to accept an array or a function.\n * 2013-12-29   v0.6.0   Open options.hostname if provided. Update connect-livereload to ~0.3.0. Update connect to ~2.12.0. Use well-formed ssl certificates. Support all options of open. Make directory browseable when base is a string.\n * 2013-09-05   v0.5.0   Add 'open' option.\n * 2013-09-05   v0.4.2   Un-normalize options.base as it should be a string or an array as the user has set. Fix setting target hostname option.\n * 2013-09-02   v0.4.1   Browse-able directory is the last item supplied to bases. Added directory option to override browse-able directory.\n * 2013-09-01   v0.4.0   Fix logging of which server address. Ability to set multiple bases. Event emitted when server starts listening. Support for HTTPS. debug option added to display debug logging like the --debug flag. livereload option added to inject a livereload snippet into the page.\n * 2013-04-10   v0.3.0   Add ability to listen on system-assigned port.\n * 2013-03-07   v0.2.0   Upgrade connect dependency.\n * 2013-02-17   v0.1.2   Ensure Gruntfile.js is included on npm.\n * 2013-02-15   v0.1.1   First official release for Grunt 0.4.0.\n * 2013-01-18   v0.1.1rc6   Updating grunt/gruntplugin dependencies to rc6. Changing in-development grunt/gruntplugin dependency versions from tilde version ranges to specific versions.\n * 2013-01-09   v0.1.1rc5   Updating to work with grunt v0.4.0rc5.\n * 2012-11-01   v0.1.0   Work in progress, not yet officially released.\n\n---\n\nTask submitted by [\"Cowboy\" Ben Alman](http://benalman.com)\n\n*This file was generated on Mon Jun 09 2014 14:17:55.*\n",
  "readmeFilename": "README.md",
  "_id": "grunt-contrib-connect@0.8.0",
  "_shasum": "1f70043e3a473ae8fb7a8acbf929ce104eaf4323",
  "_from": "grunt-contrib-connect@",
  "_resolved": "https://registry.npmjs.org/grunt-contrib-connect/-/grunt-contrib-connect-0.8.0.tgz"
}
