{"id":13624816,"url":"https://github.com/colin-jack/resourced","last_synced_at":"2025-09-01T01:19:08.772Z","repository":{"id":4900748,"uuid":"6056777","full_name":"colin-jack/resourced","owner":"colin-jack","description":"A resource-oriented DSL for configuring koa.","archived":false,"fork":false,"pushed_at":"2014-11-20T17:55:22.000Z","size":912,"stargazers_count":10,"open_issues_count":1,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-04-24T18:45:44.410Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/colin-jack.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2012-10-03T07:33:20.000Z","updated_at":"2016-06-21T21:45:48.000Z","dependencies_parsed_at":"2022-08-18T00:11:37.844Z","dependency_job_id":null,"html_url":"https://github.com/colin-jack/resourced","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colin-jack%2Fresourced","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colin-jack%2Fresourced/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colin-jack%2Fresourced/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/colin-jack%2Fresourced/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/colin-jack","download_url":"https://codeload.github.com/colin-jack/resourced/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249182451,"owners_count":21226067,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T21:01:46.779Z","updated_at":"2025-04-16T01:32:32.142Z","avatar_url":"https://github.com/colin-jack.png","language":"JavaScript","funding_links":[],"categories":["JavaScript"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.org/colin-jack/resourced.png)](https://travis-ci.org/#!/colin-jack/resourced)\n\nA resource-oriented DSL for configuring koa.\n\n### Configuration\nTo configure resourced you need to tell it which directory to look for resources in:\n\n```js\nvar resourced = require('resourced');\nvar router = require('koa-router');\n\nQ.spawn(function *() {\n    // ...\n\n    app.use(router(app));\n\n    var resourcesDir = __dirname + '/resources';\n\n    yield * resourced.configureResourcesInDirectory(resourcesDir, app);\n\n    // ,,,\n});\n```\nNote that [koa-router]() is also required and that it, and any other middleware, must be installed before resourced.\n\n### Resource Definition\nThe following shows a simple person resource, where the JSON response includes a link to the associated address:\n```js\nvar Resource = require('resourced').Resource;\nvar http = require('resourced').http;\nvar cache = require('resourced').cache;\nvar ensure = require('rules').ensure;\n\nvar addressResource = require('./address');\n\nvar people = [\n    { firstName: \"bob\", lastName: \"smith\", id : 1, \"job\": \"tinker\", addressId: 3 }\n];\n\nmodule.exports = new Resource({\n    url: \"/person/:id\",\n\n    cache: cache.minutes(5).publically(),\n\n    respondsTo: [\n        http.get(function * (id) {\n            ensure(id).populated().numeric({ min : 0 });\n        \n            var person = people[id];\n\n            person.address = this.urlFor(addressResource, { id: person.addressId });\n\n            return person;\n        })\n    ]\n});\n```\n\n## \u003ca name=\"example\"/\u003eRunning Examples\nYou can run the sample application using the following command:\n\n    node --harmony examples\\web.js\n\n##Features\n* [Request Handlers](https://github.com/colin-jack/resourced/blob/master/docs/requestHandling.md) - Features like argument population make handling requests easier.\n* [Caching](https://github.com/colin-jack/resourced/blob/master/docs/caching.md) - HTTP caching of responses to GET requests.\n* [Validation](https://github.com/colin-jack/resourced/blob/master/docs/validation.md) - Allows validation of request bodies and URL's.","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolin-jack%2Fresourced","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcolin-jack%2Fresourced","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcolin-jack%2Fresourced/lists"}