{"_id":"choreographer","_rev":"5-46bda23c3a042efec995990ed704329b","name":"choreographer","description":"Your server is my stage -- dirt simple URL routing for Node.js. Easy to use, easy to understand. Sinatra-style API.","dist-tags":{"latest":"0.3.0"},"versions":{"0.3.0":{"name":"choreographer","version":"0.3.0","description":"Your server is my stage -- dirt simple URL routing for Node.js. Easy to use, easy to understand. Sinatra-style API.","homepage":"http://github.com/laughinghan/choreographer#readme","author":{"name":"Han","email":"laughinghan@gmail.com","url":"http://github.com/laughinghan"},"main":"./choreographer","engines":["node"],"repository":{"type":"git","url":"https://github.com/laughinghan/choreographer.git"},"scripts":{"start":"node server.js"},"readme":"Choreographer\n=============\n\nYour server is my stage -- dirt simple URL routing for Node.js. Easy to use,\neasy to understand. Sinatra-style API.\n\n(This has been tested with Node.js v0.2.0-v0.4.8. Should work with all\nsubsequent versions too.)\n\nInstall\n-------\n\nGet [npm](http://github.com/isaacs/npm#readme) if you don't already have it,\nand then just run `npm install choreographer`.\n\nUsage\n-----\n\nDirt simple:\n\n    var http = require('http'),\n      router = require('choreographer').router();\n    \n    router.get('/chatroom/*/messages', function(req, res, room) {\n      res.writeHead(200, {'Content-Type': 'text/plain'});\n      res.end('No messages in ' + room + '.\\n');\n    })\n    .post('/chatroom/*/message', function(req, res, room) {\n      res.writeHead(200, {'Content-Type': 'text/plain'});\n      res.end('Posted message to ' + room + '.\\n');\n    })\n    .notFound(function(req, res) {\n      res.writeHead(404, {'Content-Type': 'text/plain'});\n      res.end('404: This server is just a skeleton for a chat server.\\n' +\n        'I\\'m afraid ' + req.url + ' cannot be found here.\\n');\n    });\n    \n    http.createServer(router).listen(80);\n\nRoutes are easily made case-insensitive with the optional `ignoreCase` flag:\n\n    router.get('/HelloWorld', true, function(req, res) {\n      res.writeHead(200, {'Content-Type': 'text/plain'});\n      res.end('Hello, World!\\n');\n    });\n\nRoutes default to case-sensitive without the flag, but you can change that:\n\n    //routes defined up 'til now defaulted to case-sensitive if flag omitted\n    router.ignoreCase = true;\n    //routes defined following default to case-insensitive if flag omitted\n\nA star `*` in a route matches anything up to a slash `/`, but if you want to\nmatch slashes too you can simply use two stars `**`:\n\n    router.get('/static/**', function(req, res, path) {\n      serveStaticFiles(path); //path could be 'file.ext' or 'folders/file.ext'\n    });\n\nMost flexibly, regular expressions may also be used as routes:\n\n    router.get(/^\\/hw(\\d+)$/i, function(req, res, hwNum) {\n      res.writeHead(200, {'Content-Type': 'text/plain'});\n      res.end('Homework '+hwNum+' isn\\'t available yet.\\n');\n    });\n\nThere's also `put`, `delete`, `head`, `trace`, `options`, and `connect`, and\nthat's it! That's the entire API, short and sweet.\n\nAs in Sinatra, routes are first-come, first-serve (only the callback for the\nfirst route to be matched by a request is invoked, and routes are matched in\nthe order they are defined). Also as in Sinatra, creating `get` routes\nautomatically creates `head` routes.\n\nChoreographer has to [parse][] the URL to match the routes (obviously). For\nconvenience, the `.parsedUrl` property on the [http.ServerRequest][req] object\nis set to the [parsed URL object][parsedURL] so you needn't re-parse the URL\n(unless that property is already set to a parsed URL object, in which case,\nChoreographer will just use that object).\n\n[parse]: http://nodejs.org/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost\n[req]: http://nodejs.org/api/http.html#http_class_http_serverrequest\n[parsedURL]: http://nodejs.org/api/url.html#url_url\n\nNotice that `router` is just an event listener for the `request` event on\n`http.createServer`, so if you want a listener that does more than routing:\n\n    http.createServer(function(req, res) {\n      //do middleware stuff before routing\n      router.apply(this, arguments);\n      //do more stuff\n    }).listen(80);\n\nUnderstanding The Code\n----------------------\n\nThe code is just as simple: first half is the router, second half is the\nroutes. Lightweight and easy to understand.\n\nThe entire architecture is designed around the philosophy of being so simple\nit obviously has no bugs, rather than so complicated it has no obvious bugs.\n\nOpen-Source License\n-------------------\n\n[GNU Lesser General Public License](http://www.gnu.org/licenses/lgpl.html)\n","_id":"choreographer@0.3.0","dist":{"shasum":"e881283aca5569c77e048973ce0e21da9772c9be","tarball":"https://registry.npmjs.org/choreographer/-/choreographer-0.3.0.tgz","integrity":"sha512-yiuSHVks9u5JLqTqMQ0tCeweRps/SlGQ976STWU2T4s4OUlrYW+cmrbsjmz6NoUQUCPjNw4PQzcinzuLuhziWg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCziW7BIDOihu3pTmaw7NJ5dU9WJnixDHdqaw5fnhhLoQIhAMLNQJZck1/f5KRLL2Y/tkslo6wWT0W788mKeafaWFLr"}]},"_npmVersion":"1.1.59","_npmUser":{"name":"laughinghan","email":"laughinghan@gmail.com"},"maintainers":[{"name":"laughinghan","email":"laughinghan@gmail.com"}]}},"readme":"Choreographer\n=============\n\nYour server is my stage -- dirt simple URL routing for Node.js. Easy to use,\neasy to understand. Sinatra-style API.\n\n(This has been tested with Node.js v0.2.0-v0.4.8. Should work with all\nsubsequent versions too.)\n\nInstall\n-------\n\nGet [npm](http://github.com/isaacs/npm#readme) if you don't already have it,\nand then just run `npm install choreographer`.\n\nUsage\n-----\n\nDirt simple:\n\n    var http = require('http'),\n      router = require('choreographer').router();\n    \n    router.get('/chatroom/*/messages', function(req, res, room) {\n      res.writeHead(200, {'Content-Type': 'text/plain'});\n      res.end('No messages in ' + room + '.\\n');\n    })\n    .post('/chatroom/*/message', function(req, res, room) {\n      res.writeHead(200, {'Content-Type': 'text/plain'});\n      res.end('Posted message to ' + room + '.\\n');\n    })\n    .notFound(function(req, res) {\n      res.writeHead(404, {'Content-Type': 'text/plain'});\n      res.end('404: This server is just a skeleton for a chat server.\\n' +\n        'I\\'m afraid ' + req.url + ' cannot be found here.\\n');\n    });\n    \n    http.createServer(router).listen(80);\n\nRoutes are easily made case-insensitive with the optional `ignoreCase` flag:\n\n    router.get('/HelloWorld', true, function(req, res) {\n      res.writeHead(200, {'Content-Type': 'text/plain'});\n      res.end('Hello, World!\\n');\n    });\n\nRoutes default to case-sensitive without the flag, but you can change that:\n\n    //routes defined up 'til now defaulted to case-sensitive if flag omitted\n    router.ignoreCase = true;\n    //routes defined following default to case-insensitive if flag omitted\n\nA star `*` in a route matches anything up to a slash `/`, but if you want to\nmatch slashes too you can simply use two stars `**`:\n\n    router.get('/static/**', function(req, res, path) {\n      serveStaticFiles(path); //path could be 'file.ext' or 'folders/file.ext'\n    });\n\nMost flexibly, regular expressions may also be used as routes:\n\n    router.get(/^\\/hw(\\d+)$/i, function(req, res, hwNum) {\n      res.writeHead(200, {'Content-Type': 'text/plain'});\n      res.end('Homework '+hwNum+' isn\\'t available yet.\\n');\n    });\n\nThere's also `put`, `delete`, `head`, `trace`, `options`, and `connect`, and\nthat's it! That's the entire API, short and sweet.\n\nAs in Sinatra, routes are first-come, first-serve (only the callback for the\nfirst route to be matched by a request is invoked, and routes are matched in\nthe order they are defined). Also as in Sinatra, creating `get` routes\nautomatically creates `head` routes.\n\nChoreographer has to [parse][] the URL to match the routes (obviously). For\nconvenience, the `.parsedUrl` property on the [http.ServerRequest][req] object\nis set to the [parsed URL object][parsedURL] so you needn't re-parse the URL\n(unless that property is already set to a parsed URL object, in which case,\nChoreographer will just use that object).\n\n[parse]: http://nodejs.org/api/url.html#url_url_parse_urlstr_parsequerystring_slashesdenotehost\n[req]: http://nodejs.org/api/http.html#http_class_http_serverrequest\n[parsedURL]: http://nodejs.org/api/url.html#url_url\n\nNotice that `router` is just an event listener for the `request` event on\n`http.createServer`, so if you want a listener that does more than routing:\n\n    http.createServer(function(req, res) {\n      //do middleware stuff before routing\n      router.apply(this, arguments);\n      //do more stuff\n    }).listen(80);\n\nUnderstanding The Code\n----------------------\n\nThe code is just as simple: first half is the router, second half is the\nroutes. Lightweight and easy to understand.\n\nThe entire architecture is designed around the philosophy of being so simple\nit obviously has no bugs, rather than so complicated it has no obvious bugs.\n\nOpen-Source License\n-------------------\n\n[GNU Lesser General Public License](http://www.gnu.org/licenses/lgpl.html)\n","maintainers":[{"name":"laughinghan","email":"laughinghan@gmail.com"}],"time":{"modified":"2022-06-13T05:59:42.621Z","created":"2012-08-26T00:50:44.977Z","0.3.0":"2012-08-26T00:50:46.468Z"},"author":{"name":"Han","email":"laughinghan@gmail.com","url":"http://github.com/laughinghan"},"repository":{"type":"git","url":"https://github.com/laughinghan/choreographer.git"}}