{"_id":"headrest","_rev":"27-98efd8f61e54231736da511855cd7849","name":"headrest","description":"A restful, CORS enabled development server - for clicking around front end Javascript projects.","dist-tags":{"latest":"0.1.2"},"versions":{"0.0.1":{"name":"headrest","author":{"name":"Nat Lownes","email":"nat.lownes@gmail.com"},"description":"A restful, CORS enabled development server - for clicking around front end Javascript projects.","main":"./index.coffee","version":"0.0.1","dependencies":{"coffee-script":"~1.6.0","express":"~3.1.0","whoadb":"~0.1.x"},"devDependencies":{"honk-cake":"git://github.com/natlownes/honk-cake.git#dependencies","grunt":"~0.4.0","mocha":"~1.8.1","superagent":"~0.14.x","chai":"~1.4.2","q":"~0.9.x"},"directories":{"test":"test","lib":"lib"},"scripts":{"test":"cake test"},"repository":{"type":"git","url":"git://github.com/natlownes/headrest.git"},"keywords":["rest","webserver","server","http","test","testing","js","frontend","clicking"],"license":"BSD","optionalDependencies":{},"engines":{"node":"*"},"_id":"headrest@0.0.1","dist":{"shasum":"d2530b776285c4f82e10fba93ba7e480a9e09839","tarball":"https://registry.npmjs.org/headrest/-/headrest-0.0.1.tgz","integrity":"sha512-FnrQAJPxoSsxDcSj2VMlRH/kXWKb2hB+qhcEjVfst1RgnihxdmyXgJwmQpqEDr9UKSWOduKFg7Rot4iFhqjBkA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIHhGwOkXJNc1WjQQ+lwn+yDxLCPduUzuf6XnvLJk5SAkAiEAnC5OQwhy+9xAyAeS+vW2IlRYX4Ty+AL7b63JLPZWnYU="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"narf","email":"nat.lownes@gmail.com"},"maintainers":[{"name":"narf","email":"nat.lownes@gmail.com"}]},"0.0.2":{"name":"headrest","author":{"name":"Nat Lownes","email":"nat.lownes@gmail.com"},"description":"A restful, CORS enabled development server - for clicking around front end Javascript projects.","main":"./index.coffee","version":"0.0.2","dependencies":{"coffee-script":"~1.6.0","express":"~3.1.0","whoadb":"~0.1.x","headrest-middleware":"~0.0.x"},"devDependencies":{"honk-cake":"git://github.com/natlownes/honk-cake.git#dependencies","grunt":"~0.4.0","mocha":"~1.8.1","superagent":"~0.14.x","chai":"~1.4.2","q":"~0.9.x"},"directories":{"test":"test","lib":"lib"},"scripts":{"test":"cake test"},"repository":{"type":"git","url":"git://github.com/natlownes/headrest.git"},"keywords":["rest","webserver","server","http","test","testing","js","frontend","clicking"],"license":"BSD","optionalDependencies":{},"engines":{"node":"*"},"_id":"headrest@0.0.2","dist":{"shasum":"d7afed851629a2e0c97be9840916eeabae63a09f","tarball":"https://registry.npmjs.org/headrest/-/headrest-0.0.2.tgz","integrity":"sha512-o4TrXAYwqZy46XWPPFcSEgAOC1Skbqmo6WZ/oo+6HhIrtia+QjTt62BO4TZz6XPX5owqm+Oub3hz5OVmaXy9tQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCm58ZxxArwlj1zdOxWGC23uCuDKBLtTXrAdEii4ItHlQIgAZ578oq9ZLFkszdHmEdaIxHVi1IrHIJozNYPU4cW9QE="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"narf","email":"nat.lownes@gmail.com"},"maintainers":[{"name":"narf","email":"nat.lownes@gmail.com"}]},"0.0.3":{"name":"headrest","author":{"name":"Nat Lownes","email":"nat.lownes@gmail.com"},"description":"A restful, CORS enabled development server - for clicking around front end Javascript projects.","main":"./index.coffee","version":"0.0.3","dependencies":{"coffee-script":"~1.6.0","express":"~3.1.0","whoadb":"~0.1.x","headrest-middleware":"~0.0.x","moment":"~2.0.x"},"devDependencies":{"honk-cake":"git://github.com/natlownes/honk-cake.git#dependencies","grunt":"~0.4.0","mocha":"~1.8.1","superagent":"~0.14.x","chai":"~1.4.2","q":"~0.9.x"},"directories":{"test":"test","lib":"lib"},"scripts":{"test":"cake test"},"repository":{"type":"git","url":"git://github.com/natlownes/headrest.git"},"keywords":["rest","webserver","server","http","test","testing","js","frontend","clicking"],"license":"BSD","optionalDependencies":{},"engines":{"node":"*"},"_id":"headrest@0.0.3","dist":{"shasum":"9cc683cb3e035c7a7982304a4112e308b4c40dac","tarball":"https://registry.npmjs.org/headrest/-/headrest-0.0.3.tgz","integrity":"sha512-mJwg7BnR7OHLFwoH0h4NpLDw+4DWVcQg9ulCywHLB3DuTbEtDTxlGI7UbgMbArpksTudTbKkG9Go1T5gEXZBsQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCz3LT+DEd5seVK1v5J6RuPNDt4uL1mA9HWcB8T0WPuFAIhANUw0BugnnH9/oO5k3xNlSV4iFsDFXXF2M89ALvTDR/K"}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"narf","email":"nat.lownes@gmail.com"},"maintainers":[{"name":"narf","email":"nat.lownes@gmail.com"}]},"0.1.1":{"name":"headrest","author":{"name":"Nat Lownes","email":"nat.lownes@gmail.com"},"description":"A restful, CORS enabled development server - for clicking around front end Javascript projects.","main":"./lib/index.js","version":"0.1.1","dependencies":{"express":"~3.1.0","whoadb":"~0.1.x","headrest-middleware":"~0.0.x","moment":"~2.0.x"},"devDependencies":{"coffee-script":"~1.6.0","honk-cake":">=0.0.5","grunt":"~0.4.0","mocha":"~1.8.1","superagent":"~0.14.x","chai":"~1.4.2","q":"~0.9.x"},"directories":{"test":"test","src":"src","lib":"lib"},"scripts":{"test":"cake test","test:watch":"cake test:watch","build":"find ./src -iname '*.coffee' | xargs coffee -c -o lib"},"repository":{"type":"git","url":"git://github.com/natlownes/headrest.git"},"keywords":["REST","api","webserver","server","http","test","testing","js","frontend","ui","clicking"],"license":"BSD","optionalDependencies":{},"engines":{"node":">= 0.8"},"_id":"headrest@0.1.1","dist":{"shasum":"8dac5587590a5f5968bf5f2bb1079b72d100b6ad","tarball":"https://registry.npmjs.org/headrest/-/headrest-0.1.1.tgz","integrity":"sha512-PkBQja8uPMnxuft1zoKBJKu7FvHGR2egaD3CWlyRPyCw+04pHjGVqJdkdelGBIixVS/iAKsV4WJgg41vtd5zzQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICdtEQriwjthTEXjOJmMZ70rHOBKJVeT+kq45biryesuAiEAv++Gfp2dEjCooKiBw5m4dGg+gm26H2Msnh8hN19EL/E="}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"narf","email":"nat.lownes@gmail.com"},"maintainers":[{"name":"narf","email":"nat.lownes@gmail.com"}]},"0.1.2":{"name":"headrest","author":{"name":"Nat Lownes","email":"nat.lownes@gmail.com"},"description":"A restful, CORS enabled development server - for clicking around front end Javascript projects.","main":"./lib/index.js","version":"0.1.2","dependencies":{"express":"~3.1.0","whoadb":"~0.1.x","headrest-middleware":">=0.0.5","moment":"~2.0.x"},"devDependencies":{"coffee-script":"~1.6.0","honk-cake":">=0.0.5","grunt":"~0.4.0","mocha":"~1.8.1","superagent":"~0.14.x","chai":"~1.4.2","q":"~0.9.x","coffeelint":"~1.1.0"},"directories":{"test":"test","src":"src","lib":"lib"},"scripts":{"test":"npm run lint && cake test","test:watch":"cake test:watch","build":"find ./src -iname '*.coffee' | xargs coffee -c -o lib","lint":"find ./src ./test -iname '*.coffee' | xargs coffeelint","push":"git push origin master && git push origin --tags","prepublish":"npm run build"},"repository":{"type":"git","url":"git://github.com/natlownes/headrest.git"},"keywords":["REST","api","webserver","server","http","test","testing","js","frontend","ui","clicking"],"license":"BSD","optionalDependencies":{},"engines":{"node":">= 0.8"},"_id":"headrest@0.1.2","dist":{"shasum":"991fb1b4ef17a5a36cfb641e8b0460952b36a00c","tarball":"https://registry.npmjs.org/headrest/-/headrest-0.1.2.tgz","integrity":"sha512-pa70awfxjOaDwmL8+aw7X0zOKAjd5pXksEmo5PeuzrQsED+frUSRyPl0x7Q4owyDVnrdcVkdrCkW0Gu48djMmQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCkk1glc9cvF/rqlkjBER5srCtdc8Nl2UcnDw0Ebyww+gIhAJnHyVTRDrHz/Kcj46jJmuIYM/EGLpyDseCmwbBrvotr"}]},"_from":".","_npmVersion":"1.2.18","_npmUser":{"name":"narf","email":"nat.lownes@gmail.com"},"maintainers":[{"name":"narf","email":"nat.lownes@gmail.com"}]}},"readme":"# headrest\n\n[![Build Status](https://travis-ci.org/natlownes/headrest.png?branch=master)](https://travis-ci.org/natlownes/headrest)\n\n```npm install headrest```\n\nProvides a RESTful,\n[CORS](http://en.wikipedia.org/wiki/Cross-origin_resource_sharing) enabled\nwebserver intended for use when developing rest-backed Javascript apps for the\nbrowser.  If you want to click around in your app, create/read/update/delete\nobjects, but not fire up an entire backend, that is what this is for.\n\nAssumes you init your JS app with or otherwise set an api root URL from which your\nmodels build the correct URL for their resource.\n\nYou can set the apiRoot like:\n\n```coffeescript\nheadrest = require('headrest')(apiRoot: '/apis/', dbPath: '/tmp/gruntest.json')\n# headrest is an express app\nheadrest.listen(5001)\n```\n\n#### Resources\n\nIt assumes your resources have paths like:\n\n* for a list of resources (index), ```/api/rocks``` or nested as deep as you\n  like -  ```/api/rocks/ffeedc/sedimentaries``` and so on.\n* for a single resource, ```/api/rocks/ffeedc```, also nested as far as you\n  want.\n\n#### Sessions\n\nImplements sessions at ```/api/session```.\n\n* POST whatever you want to ```/api/session```, you'll get a Cookie.\n\n* GET ```/api/session``` - HTTP 200 means you're logged in, 404 if not.\n\n* DELETE ```/api/session``` - removes your session record and sets your cookie\n  to expire.\n\n### Example Gruntfile.coffee\n\n```coffeescript\n\nheadrest = require('headrest')(apiRoot: '/apis/', dbPath: '/tmp/gruntest.json')\n\n\nmodule.exports = (grunt) ->\n  grunt.loadNpmTasks('grunt-contrib-connect')\n\n  grunt.registerTask('headrest',\n    [\n      'connect'\n    ]\n  )\n\n  grunt.initConfig\n    connect:\n      headrest:\n        options:\n          port: 5001\n          hostname: \"0.0.0.0\"\n          keepalive: true\n          middleware: (connect, options) ->\n            [headrest]\n\n\n```\n\n```bash\ngrunt headrest\n```\n\nThis will start the server on ```http://0.0.0.0:5001/```.  From a browser, you\ncan create an object with:\n\n```javascript\n\nvar request = $.ajax({\n  url: \"http://localhost:5001/apis/rocks\",\n  dataType: \"json\",\n  crossDomain: true,\n  type: 'POST',\n  data: {name: \"sedimentary\"}\n})\n\nrequest.done(function(d) {\n  var rock = JSON.parse(d)\n  console.log( rock.id )\n})\n\n// console output:\n// > 7cf28fd544be1b7f55296c45d40538f\n\nvar request = $.ajax({\n  url: \"http://localhost:5001/apis/rocks/7cf28fd544be1b7f55296c45d40538f\",\n  dataType: \"json\",\n  crossDomain: true,\n  type: 'PUT',\n  data: {name: \"Igneous\"}\n})\n\nrequest.done(function(d) {\n  console.log('updated')\n})\n\nvar request = $.ajax({\n  url: \"http://localhost:5001/apis/rocks/7cf28fd544be1b7f55296c45d40538f\",\n  dataType: \"json\",\n  crossDomain: true,\n  type: 'DELETE'\n})\n\nrequest.done(function(d) {\n  console.log('removed')\n})\n\n```\n\n### TODO:\n\n* allow setting of session path.\n* keep each record in a separate file (next major ver, whoadb)\n\n### Contributing\n\nFork and\n\n```npm install```\n\n```npm test```\n\nor\n\n```cake test:watch```\n\nOr if any of this code is wack and you think there's a better way to do it, I\ndefinitely want to hear about it, no joke.\n\n### That's it!\n\nI yanked this idea from my homie Mark's footrest.py\n\n","maintainers":[{"name":"narf","email":"nat.lownes@gmail.com"}],"time":{"modified":"2022-06-18T19:44:42.262Z","created":"2013-05-15T23:37:59.466Z","0.0.1":"2013-05-15T23:41:53.317Z","0.0.2":"2013-05-18T17:34:56.629Z","0.0.3":"2013-05-29T16:08:02.620Z","0.1.0":"2013-11-27T04:25:04.880Z","0.1.1":"2013-11-27T04:31:19.942Z","0.1.2":"2014-09-01T17:35:42.685Z"},"author":{"name":"Nat Lownes","email":"nat.lownes@gmail.com"},"repository":{"type":"git","url":"git://github.com/natlownes/headrest.git"},"keywords":["REST","api","webserver","server","http","test","testing","js","frontend","ui","clicking"],"license":"BSD","readmeFilename":"README.md"}