{"id":17625128,"url":"https://github.com/derrickpelletier/res-async","last_synced_at":"2025-03-30T01:43:20.051Z","repository":{"id":12646120,"uuid":"15317689","full_name":"derrickpelletier/res-async","owner":"derrickpelletier","description":"Express async middleware helpers to reduce endpoint complexity","archived":false,"fork":false,"pushed_at":"2013-12-19T17:07:39.000Z","size":104,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-05T08:33:36.132Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/derrickpelletier.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-12-19T17:05:37.000Z","updated_at":"2013-12-19T17:07:40.000Z","dependencies_parsed_at":"2022-08-28T10:23:46.379Z","dependency_job_id":null,"html_url":"https://github.com/derrickpelletier/res-async","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/derrickpelletier%2Fres-async","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derrickpelletier%2Fres-async/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derrickpelletier%2Fres-async/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/derrickpelletier%2Fres-async/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/derrickpelletier","download_url":"https://codeload.github.com/derrickpelletier/res-async/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246266252,"owners_count":20749754,"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-10-22T22:08:12.499Z","updated_at":"2025-03-30T01:43:20.027Z","avatar_url":"https://github.com/derrickpelletier.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Express async helpers to reduce some endpoint complexity. Injected into res via middleware. \n\n-------\n\nAvailable methods:\n+ `res.renderWhenDone(view, functionHash)`\n+ `res.jsonWhenDone(functionHash)`\n+ `res.asyncProcess(functionHash, callback)`\n\nThe function hash is a number of properties whose values are functions with a callback pattern of (err, result). Upon completion the hash is transformed into the results of each function, and handled according to the helper called:\n+ `renderWhenDone` provides the hash to the view.\n+ `jsonWhenDone` returns the hash to the client as json.\n+ `asyncProcess` returns the hash to the callback given.\n\nThe function hash can contain non-function entities which will be merged into the final result after the functions themselves have been processed. If your function requires arguments, pass them in as an array wherein the first item is the function. See below (or test.js) for an example.\n\n\n-----\n\n## Using\n\n```\nnpm install res-async\n```\n\nSetup:\n```javascript\n//... app config\n\napp.use(express.methodOverride());\napp.use(require('res-async'));\napp.use(app.router);\n\n//... more app config\n```\n\nUse (see test.js):\n```javascript\napp.get('/cool', function (req, res) {\n  \n  res.renderWhenDone('somecoolview', {\n    propOne: someAsyncMethod,\n    justAString: \"I'm not a function\",\n    faveFood: someAsyncQuery,\n    argsExample: [delaySquare, 5]\n  });\n\n});\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderrickpelletier%2Fres-async","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fderrickpelletier%2Fres-async","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fderrickpelletier%2Fres-async/lists"}