{"id":24738719,"url":"https://github.com/zweifisch/invoker","last_synced_at":"2025-10-10T08:30:21.505Z","repository":{"id":5516883,"uuid":"6718100","full_name":"zweifisch/invoker","owner":"zweifisch","description":"A CoffeeScript library for Client/Server interaction","archived":false,"fork":false,"pushed_at":"2012-11-24T11:58:08.000Z","size":192,"stargazers_count":4,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-03T18:08:41.036Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zweifisch.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-11-16T07:46:21.000Z","updated_at":"2018-09-25T02:30:14.000Z","dependencies_parsed_at":"2022-07-06T22:33:04.421Z","dependency_job_id":null,"html_url":"https://github.com/zweifisch/invoker","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/zweifisch/invoker","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Finvoker","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Finvoker/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Finvoker/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Finvoker/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zweifisch","download_url":"https://codeload.github.com/zweifisch/invoker/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zweifisch%2Finvoker/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279003299,"owners_count":26083555,"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","status":"online","status_checked_at":"2025-10-10T02:00:06.843Z","response_time":62,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":"2025-01-27T22:55:28.609Z","updated_at":"2025-10-10T08:30:21.173Z","avatar_url":"https://github.com/zweifisch.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Invoker\n\nA CoffeeScript library for Client/Server interaction, inspired by [fetch](https://github.com/ibdknox/fetch)\n\n## Usage\n\n### client side\n\n```html\n\u003cscript type=\"text/javascript\" src=\"scripts\"\u003e\u003c/script\u003e\n```\n\n```coffeescript\n{batch} = invoker\n{Utils,User} = invoker.classes\n# Utils and User are classes generated in the included 'scripts'\n# mapped to server side classes\n\n# calling server side static method\nUtils.add(1,2) (result)-\u003e # result.should.equal 3\n\n# calling multiple methods in one request\nbatch (done)-\u003e\n\tUser.listUsers() (users)-\u003e\n\t\t# users.should.have.length 0\n\tuser = new User 'foo'\n\tuser.save()\n\tUser.listUsers() (users)-\u003e\n\t\t# users.should.have.length 1\n```\n\njavascript version:\n```javascript\nvar batch = invoker.batch;\n\tUtils = invoker.classes.Utils,\n\tUser = invoker.classes.User,\nUtils.add(1,2)(function(result){\n\t// result.should.equla(3)\n});\nbatch(function(done){\n\tUser.listUser()(function(users){\n\t\t// user.should.have.length(0)\n\t});\n\tuser = new User('foo');\n\tuser.save();\n\tUser.listUsers()(function(users){\n\t\t// user.should.have.length(1)\n\t});\n});\n```\n\n### server side\n\nmore details see [test/index.php](https://github.com/zweifisch/invoker/blob/master/test/index.php) and [the php backend](https://github.com/zweifisch/Invoker-php)\nthe php classes can be found [here](https://github.com/zweifisch/invoker/tree/master/test/php)\n\n```php\nrequire 'vendor/autoload.php';\n\nallowedMethods = array(\n\t'Utils'=\u003e'*',\n\t'User'=\u003e'*',\n\t'Path'=\u003earray('pwd'),\n);\n# Utils,User,Path must be available\n\n$server = new Invoker\\Server(allowedMethods);\n$server-\u003elisten();\n```\n\n## more on client side\n\none line version\n\n```coffeescript\ninvoker.invoke ['Utils','add',[1,2]], (result)-\u003e console.log result is 3\n```\n\ncall multiple methods in one ajax request\n\n```coffeescript\ninvoker.batch (done)-\u003e\n\tutils.add(1,2) (sum)-\u003e\n\t\tconsole.log sum is 3\n\tutils.add(2,3) (sum)-\u003e\n\t\tconsole.log sum is 5\n\tpath.pwd() (pwd)-\u003e\n\t\tconsole.log pwd\n\tdone -\u003e\n\t\tconsole.log 'done'\n```\n\nabort an invocation\n\n```coffeescript\ninvocation = batch -\u003e\n\tutils.add (1,2) (sum)-\u003e\ninvocation.abort()\n```\n\nhandle errors\n\n```coffeescript\nUtils.add(1,2)\n\tsuccess:(result)-\u003e\n\terror:(result,code)-\u003e\n\t\nbatch (done,onError)-\u003e\n\tPath.scanDir() -\u003e\n\t\t# won't be reached\n\tUtils.add(1,1) -\u003e\n\t\t# won't be reached\n\tdone -\u003e\n\t\t# won't be reached\n\tonError (response,code)-\u003e\n\t\tconsole.log code \u003e 200\n```\n\t\t\n\t\n### intergration with other framework\n\nTBD\n\n## test\n\n```sh\ncd test\ncomposer install\nphp -S localhost:1212 index.php\n```\n\nvisit [http://localhost:1212](http://localhost:1212)\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweifisch%2Finvoker","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzweifisch%2Finvoker","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzweifisch%2Finvoker/lists"}