{"_id":"mini-lr","_rev":"4087213","name":"mini-lr","description":"Mini LiveReload server, background-friendly","dist-tags":{"latest":"0.1.9"},"maintainers":[{"name":"elwayman02","email":"hawker.jordan@gmail.com"}],"time":{"modified":"2025-12-02T22:11:49.000Z","created":"2015-09-25T06:57:39.402Z","0.1.9":"2016-01-26T22:53:02.337Z","0.1.8":"2015-09-25T07:40:25.734Z","0.1.7":"2015-09-25T06:57:39.402Z"},"users":{},"author":{"name":"mklabs"},"repository":{"type":"git","url":"git://github.com/elwayman02/mini-lr.git"},"versions":{"0.1.9":{"author":{"name":"mklabs"},"name":"mini-lr","description":"Mini LiveReload server, background-friendly","version":"0.1.9","homepage":"https://github.com/elwayman02/mini-lr","bugs":{"url":"https://github.com/elwayman02/mini-lr/issues"},"repository":{"type":"git","url":"git://github.com/elwayman02/mini-lr.git"},"contributors":[{"name":"Jordan Hawker","email":"hawker.jordan@gmail.com","url":"http://www.JordanHawker.com"}],"main":"./lib","scripts":{"prepublish:":"npm test","test":"mocha --reporter spec test/wd test","test-debug":"DEBUG=minilr:* mocha --reporter list","test-debug-all":"DEBUG=* mocha --reporter list","pretest":"npm run phantom-start","posttest":"npm run phantom-stop","phantom-start":"sh scripts/phantom-start","phantom-stop":"sh scripts/phantom-stop","serve":"node examples/express/server.js","post-change":"sh scripts/post-change","get-change":"curl http://localhost:35729/changed?files=site.css"},"dependencies":{"body-parser":"~1.14.0","debug":"^2.2.0","faye-websocket":"~0.7.2","livereload-js":"^2.2.0","parseurl":"~1.3.0","qs":"~2.2.3"},"devDependencies":{"connect":"^2.14.5","express":"^4.1.1","mocha":"^1.18.2","phantomjs":"^1.9.7-5","request":"^2.34.0","supertest":"^0.12.0","wd":"^0.2.21"},"config":{"test_port":"9001"},"license":"MIT","gitHead":"8b7248023844c1a915392d3e9dea6131fcb0671a","_id":"mini-lr@0.1.9","_shasum":"02199d27347953d1fd1d6dbded4261f187b2d0f6","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.3","_npmUser":{"name":"elwayman02","email":"hawker.jordan@gmail.com"},"dist":{"shasum":"02199d27347953d1fd1d6dbded4261f187b2d0f6","size":14027,"noattachment":false,"key":"/mini-lr/-/mini-lr-0.1.9.tgz","tarball":"http://registry.cnpm.dingdandao.com/mini-lr/download/mini-lr-0.1.9.tgz"},"maintainers":[{"name":"elwayman02","email":"hawker.jordan@gmail.com"}],"directories":{},"publish_time":1453848782337,"_hasShrinkwrap":false,"_cnpm_publish_time":1453848782337,"_cnpmcore_publish_time":"2021-12-16T19:19:04.566Z"},"0.1.8":{"author":{"name":"mklabs"},"name":"mini-lr","description":"Mini LiveReload server, background-friendly","version":"0.1.8","homepage":"https://github.com/elwayman02/mini-lr","bugs":{"url":"https://github.com/elwayman02/mini-lr/issues"},"repository":{"type":"git","url":"git://github.com/elwayman02/mini-lr.git"},"contributors":[{"name":"Jordan Hawker","email":"hawker.jordan@gmail.com","url":"http://www.JordanHawker.com"}],"main":"./lib","scripts":{"prepublish:":"npm test","test":"mocha --reporter spec test/wd test","test-debug":"DEBUG=minilr:* mocha --reporter list","test-debug-all":"DEBUG=* mocha --reporter list","pretest":"npm run phantom-start","posttest":"npm run phantom-stop","phantom-start":"sh scripts/phantom-start","phantom-stop":"sh scripts/phantom-stop","serve":"node examples/express/server.js","post-change":"sh scripts/post-change","get-change":"curl http://localhost:35729/changed?files=site.css"},"dependencies":{"body-parser":"~1.14.0","debug":"~2.0.0","faye-websocket":"~0.7.2","livereload-js":"^2.2.0","parseurl":"~1.3.0","qs":"~2.2.3"},"devDependencies":{"connect":"^2.14.5","express":"^4.1.1","mocha":"^1.18.2","phantomjs":"^1.9.7-5","request":"^2.34.0","supertest":"^0.12.0","wd":"^0.2.21"},"config":{"test_port":"9001"},"license":"MIT","gitHead":"2b54536cac17359afa075c2cbdca21c28c22ee82","_id":"mini-lr@0.1.8","_shasum":"95e71a823272722b00064c2543b0c3d9d254474e","_from":".","_npmVersion":"3.3.3","_nodeVersion":"0.12.7","_npmUser":{"name":"elwayman02","email":"hawker.jordan@gmail.com"},"dist":{"shasum":"95e71a823272722b00064c2543b0c3d9d254474e","size":17643,"noattachment":false,"key":"/mini-lr/-/mini-lr-0.1.8.tgz","tarball":"http://registry.cnpm.dingdandao.com/mini-lr/download/mini-lr-0.1.8.tgz"},"maintainers":[{"name":"elwayman02","email":"hawker.jordan@gmail.com"}],"directories":{},"publish_time":1443166825734,"_hasShrinkwrap":false,"_cnpm_publish_time":1443166825734,"_cnpmcore_publish_time":"2021-12-16T19:19:04.808Z"},"0.1.7":{"author":{"name":"mklabs"},"name":"mini-lr","description":"Mini LiveReload server, background-friendly","version":"0.1.7","homepage":"https://github.com/elwayman02/mini-lr","bugs":{"url":"https://github.com/elwayman02/mini-lr/issues"},"repository":{"type":"git","url":"git://github.com/elwayman02/mini-lr.git"},"contributors":[{"name":"Jordan Hawker","email":"hawker.jordan@gmail.com","url":"http://www.JordanHawker.com"}],"main":"./lib","scripts":{"prepublish:":"npm test","test":"mocha --reporter spec test/wd test","test-debug":"DEBUG=minilr:* mocha --reporter list","test-debug-all":"DEBUG=* mocha --reporter list","pretest":"npm run phantom-start","posttest":"npm run phantom-stop","phantom-start":"sh scripts/phantom-start","phantom-stop":"sh scripts/phantom-stop","serve":"node examples/express/server.js","post-change":"sh scripts/post-change","get-change":"curl http://localhost:35729/changed?files=site.css"},"dependencies":{"body-parser":"~1.8.0","debug":"~2.0.0","faye-websocket":"~0.7.2","livereload-js":"^2.2.0","parseurl":"~1.3.0","qs":"~2.2.3"},"devDependencies":{"connect":"^2.14.5","express":"^4.1.1","mocha":"^1.18.2","phantomjs":"^1.9.7-5","request":"^2.34.0","supertest":"^0.12.0","wd":"^0.2.21"},"config":{"test_port":"9001"},"license":"MIT","gitHead":"8f7ed80f38b2e4843cc0a9075c95647577f33586","_id":"mini-lr@0.1.7","_shasum":"aa983311314ca024fd335ef48710cb2516ed162e","_from":".","_npmVersion":"3.3.3","_nodeVersion":"0.12.7","_npmUser":{"name":"elwayman02","email":"hawker.jordan@gmail.com"},"dist":{"shasum":"aa983311314ca024fd335ef48710cb2516ed162e","size":16501,"noattachment":false,"key":"/mini-lr/-/mini-lr-0.1.7.tgz","tarball":"http://registry.cnpm.dingdandao.com/mini-lr/download/mini-lr-0.1.7.tgz"},"maintainers":[{"name":"elwayman02","email":"hawker.jordan@gmail.com"}],"directories":{},"publish_time":1443164259402,"_hasShrinkwrap":false,"_cnpm_publish_time":1443164259402,"_cnpmcore_publish_time":"2021-12-16T19:19:05.481Z"}},"readme":"# Deprecated\n\nWith Tiny-lr being updated again and [adding more contributors](https://github.com/mklabs/tiny-lr/issues/96), I'm putting mini-lr back on the shelf for now, with the hope that we can keep the main project alive instead. Please move back to Tiny-lr if you've switched to mini-lr. Sorry for the inconvenience!\n\n# mini-lr [![Build Status](https://travis-ci.org/elwayman02/mini-lr.svg?branch=master)](https://travis-ci.org/elwayman02/mini-lr)\n\nThis script manages a tiny [LiveReload](http://livereload.com/) server\nimplementation.\n\nFork of the seemingly abandoned [tiny-lr](https://github.com/mklabs/tiny-lr) project, providing support for `npm v3`.\nThe quickest way to begin using this fork in your project is to simply refactor `require('tiny-lr')` to `require('mini-lr')`.\n\n[![NPM](https://nodei.co/npm/mini-lr.png?downloads=true&stars=true)](https://nodei.co/npm/mini-lr/)\n\n[![NPM](https://nodei.co/npm/tiny-lr.png?downloads=true&stars=true)](https://nodei.co/npm/tiny-lr/)\n\nIt exposes an HTTP server and express middleware, with a very basic REST\nApi to notify the server of a particular change.\n\nIt doesn't have any watch ability, it must be done at the build process or\napplication level.\n\nInstead, it exposes a very simple API to notify the server that some\nchanges have been made, then broadcasted to every livereload client\nconnected.\n\n    # notify a single change\n    curl http://localhost:35729/changed?files=style.css\n\n    # notify using a longer path\n    curl http://localhost:35729/changed?files=js/app.js\n\n    # notify multiple changes, comma or space delimited\n    curl http://localhost:35729/changed?files=index.html,style.css,docs/docco.css\n\nOr you can bulk the information into a POST request, with body as a JSON array of files.\n\n    curl -X POST http://localhost:35729/changed -d '{ \"files\": [\"style.css\", \"app.js\"] }'\n\n    # from a JSON file\n    node -pe 'JSON.stringify({ files: [\"some.css\", \"files.css\"] })' > files.json\n    curl -X POST -d @files.json http://localhost:35729\n\nAs for the livereload client, you need to install the browser extension:\nhttp://feedback.livereload.com/knowledgebase/articles/86242-how-do-i-install-and-use-the-browser-extensions-\n(**note**: you need to listen on port 35729 to be able to use with your\nbrower extension)\n\nor add the livereload script tag manually:\nhttp://feedback.livereload.com/knowledgebase/articles/86180-how-do-i-add-the-script-tag-manually-\n(and here you can choose whatever port you want)\n\n## Integration\n\nThe best way to integrate the runner in your workflow is to add it as a `reload`\nstep within your build tool.\n\n```js\nvar minilr = require('mini-lr');\n\n// standard LiveReload port\nvar port = 35729;\n\n// minilr(opts) => new minilr.Server(opts);\nminilr().listen(port, function() {\n  console.log('... Listening on %s ...', port);\n})\n```\n\nYou can define your own route and listen for specific request:\n\n```js\nvar server = minilr();\n\nserver.on('GET /myplace', function(req, res) {\n  res.write('Mine');\n  res.end();\n})\n```\n\nAnd stop the server manually:\n\n```js\nserver.close();\n```\n\nThis will close any websocket connection established and emit a close event.\n\n### Middleware\n\nTo use as a connect / express middleware, mini-lr needs query /\nbodyParser middlewares prior in the stack (to handle POST requests)\n\nAny handled requests ends at the minilr level, not found and errors are\nnexted to the rest of the stack.\n\n```js\nvar port = process.env.LR_PORT || process.env.PORT || 35729;\n\nvar path    = require('path');\nvar express = require('express');\nvar minilr  = require('mini-lr');\nvar body    = require('body-parser');\n\nvar app = express();\n\n// This binds both express app and minilr on the same port\n\n\napp\n  .use(body())\n  .use(minilr.middleware({ app: app }))\n  .use(express.static(path.resolve('./')))\n  .listen(port, function() {\n    console.log('listening on %d', port);\n  });\n```\n\nThe port you listen on is important, and minilr should **always** listen on\nthe LiveReload standard one: `35729`. Otherwise, you won't be able to rely\non the browser extensions, though you can still use the manual snippet\napproach.\n\nYou can also start two different servers, one on your app port, the\nother listening on the LiveReload port.\n\n### Using grunt\n\nHead over to [https://github.com/gruntjs/grunt-contrib-watch](https://github.com/gruntjs/grunt-contrib-watch#live-reloading)\n\n### Using make\n\nSee [make-livereload](https://github.com/mklabs/make-livereload) repo.\nThis repository defines a bin wrapper you can use and install with:\n\n    npm install make-livereload -g\n\nIt bundles the same bin wrapper previously used in mini-lr repo.\n\n    Usage: mini-lr [options]\n\n    Options:\n\n      -h, --help     output usage information\n      -V, --version  output the version number\n      port           -p\n      pid            Path to the generated PID file (default: ./mini-lr.pid)\n\n### Using gulp\n\nSee [gulp-livereload](https://github.com/vohof/gulp-livereload) repo.\n\n## Options\n\n- `livereload`    - Path to the client side lib (defaults to `path.join(__dirname, '../node_modules/livereload-js/dist/livereload.js')`)\n- `port`          - Livereload port (defaults to `35729`)\n- `errorListener` - A callback to invoke when an error occurs (otherwise, fallbacks to standard error output)\n- `app`           - An express or other middleware based HTTP server\n- `key`           - Option to pass in to create an https server\n- `cert`          - Option to pass in to create an https server\n- `pfx`           - Can also be used to create an https server instead of `key` & `cert`\n- `liveCSS`       - LiveReload option to enable live CSS reloading (defaults to true)\n- `liveJs`        - LiveReload option to enable live JS reloading (defaults to true)\n- `liveImg`       - LiveReload option to enable live images reloading (defaults to true)\n\n## Tests\n\n    npm test\n\n---\n\n\n# TOC\n   - [mini-lr](#mini-lr)\n     - [GET /](#mini-lr-get-)\n     - [GET /changed](#mini-lr-get-changed)\n     - [POST /changed](#mini-lr-post-changed)\n     - [GET /livereload.js](#mini-lr-get-livereloadjs)\n     - [GET /kill](#mini-lr-get-kill)\n<a name=\"\" />\n\n<a name=\"mini-lr\" />\n# mini-lr\naccepts ws clients.\n\n```js\nvar url = parse(this.request.url);\nvar server = this.app;\n\nvar ws = this.ws = new WebSocket('ws://' + url.host + '/livereload');\n\nws.onopen = function(event) {\n  var hello = {\n    command: 'hello',\n    protocols: ['http://livereload.com/protocols/official-7']\n  };\n\n  ws.send(JSON.stringify(hello));\n};\n\nws.onmessage = function(event) {\n  assert.deepEqual(event.data, JSON.stringify({\n    command: 'hello',\n    protocols: ['http://livereload.com/protocols/official-7'],\n    serverName: 'mini-lr'\n  }));\n\n  assert.ok(Object.keys(server.clients).length);\n  done();\n};\n```\n\nproperly cleans up established connection on exit.\n\n```js\nvar ws = this.ws;\n\nws.onclose = done.bind(null, null);\n\nrequest(this.server)\n  .get('/kill')\n  .expect(200, function() {\n    console.log('server shutdown');\n  });\n```\n\n<a name=\"mini-lr\" />\n# mini-lr\n<a name=\"mini-lr-get-\" />\n## GET /\nrespond with nothing, but respond.\n\n```js\nrequest(this.server)\n  .get('/')\n  .expect('Content-Type', /json/)\n  .expect('{\"minilr\":\"Welcome\",\"version\":\"0.0.1\"}')\n  .expect(200, done);\n```\n\nunknown route respond with proper 404 and error message.\n\n```js\nrequest(this.server)\n  .get('/whatev')\n  .expect('Content-Type', /json/)\n  .expect('{\"error\":\"not_found\",\"reason\":\"no such route\"}')\n  .expect(404, done);\n```\n\n<a name=\"mini-lr-get-changed\" />\n## GET /changed\nwith no clients, no files.\n\n```js\nrequest(this.server)\n  .get('/changed')\n  .expect('Content-Type', /json/)\n  .expect(/\"clients\":\\[\\]/)\n  .expect(/\"files\":\\[\\]/)\n  .expect(200, done);\n```\n\nwith no clients, some files.\n\n```js\nrequest(this.server)\n  .get('/changed?files=gonna.css,test.css,it.css')\n  .expect('Content-Type', /json/)\n  .expect('{\"clients\":[],\"files\":[\"gonna.css\",\"test.css\",\"it.css\"]}')\n  .expect(200, done);\n```\n\n<a name=\"mini-lr-post-changed\" />\n## POST /changed\nwith no clients, no files.\n\n```js\nrequest(this.server)\n  .post('/changed')\n  .expect('Content-Type', /json/)\n  .expect(/\"clients\":\\[\\]/)\n  .expect(/\"files\":\\[\\]/)\n  .expect(200, done);\n```\n\nwith no clients, some files.\n\n```js\nvar data = { clients: [], files: ['cat.css', 'sed.css', 'ack.js'] };\n\nrequest(this.server)\n  .post('/changed')\n  .send({ files: data.files })\n  .expect('Content-Type', /json/)\n  .expect(JSON.stringify(data))\n  .expect(200, done);\n```\n\n<a name=\"mini-lr-get-livereloadjs\" />\n## GET /livereload.js\nrespond with livereload script.\n\n```js\nrequest(this.server)\n  .get('/livereload.js')\n  .expect(/LiveReload/)\n  .expect(200, done);\n```\n\n<a name=\"mini-lr-get-kill\" />\n## GET /kill\nshutdown the server.\n\n```js\nvar server = this.server;\nrequest(server)\n  .get('/kill')\n  .expect(200, function(err) {\n    if(err) return done(err);\n    assert.ok(!server._handle);\n    done();\n  });\n```\n\n## Thanks!\n\n- mini-lr is a [LiveReload](http://livereload.com/) implementation. They\n  really made frontend editing better for a lot of us. They have a\n  [LiveReload App on the Mac App Store](https://itunes.apple.com/us/app/livereload/id482898991)\n  you might want to check out.\n  \n- To [tiny-lr](https://github.com/mklabs/tiny-lr), the original project this was forked from\n\n- To all [contributors](https://github.com/elwayman02/mini-lr/graphs/contributors)\n\n- [@FGRibreau](https://github.com/FGRibreau) / [pid.js\n  gist](https://gist.github.com/1846952)) for the background friendly\nbin wrapper, used in [make-livereload](https://github.com/mklabs/make-livereload)\n","_attachments":{},"homepage":"https://github.com/elwayman02/mini-lr","bugs":{"url":"https://github.com/elwayman02/mini-lr/issues"},"license":"MIT"}