{"id":15906196,"url":"https://github.com/softchris/angular_restify","last_synced_at":"2025-08-26T00:17:33.318Z","repository":{"id":32156509,"uuid":"35729593","full_name":"softchris/angular_restify","owner":"softchris","description":"lightweb lib for doing REST calls in angular","archived":false,"fork":false,"pushed_at":"2015-05-17T16:56:10.000Z","size":140,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-08T13:36:32.780Z","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/softchris.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":"2015-05-16T15:45:43.000Z","updated_at":"2019-06-27T06:26:12.000Z","dependencies_parsed_at":"2022-09-11T01:51:37.022Z","dependency_job_id":null,"html_url":"https://github.com/softchris/angular_restify","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/softchris%2Fangular_restify","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softchris%2Fangular_restify/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softchris%2Fangular_restify/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/softchris%2Fangular_restify/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/softchris","download_url":"https://codeload.github.com/softchris/angular_restify/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246905830,"owners_count":20852818,"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-06T13:21:40.608Z","updated_at":"2025-04-02T22:43:24.180Z","avatar_url":"https://github.com/softchris.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Angular Restify\n## Background \u0026 Motivation for Angular Restify\nRestify is meant to be that short library that helps you get going with the backend in your angular project.\n\nIt is similar to Angular Resource but with a big difference. Namely how transformRequest works. The idea with angular resource is to always have an active record both that you interact with and also get back from a CRUD operation. \n\n### Example - with angular resource\n\n\t$resource(url,params,actions).save(entity,function(savedEntity){\n\t\t\n\t});\n\nHere the **entity** and **savedEntity** is a Resource object with CRUD operations on it like save, update, remove, query etc..\n\nOf course you can intercept how a response is parsed by specifying your own action and specifying transformRequest, like so:\n\n\tvar actions = {\n\t\tget : {\n\t\t\turl : getUrl,\n\t\t\tmethod : 'GET',\n\t\t\ttransformRequest : function(response){\n\t\t\t\treturn new DomainObject(response);\n\t\t\t}\n\t\t}\n\t}\n\nYou think you will get back a DomainObject with all its methods when doing this right?\n\n\t$resource(url,params,actions).save(entity,function(savedEntity){\n\t\t\n\t});\nWRONG, savedEntity copies all properties from DomainObject but is still a Resource object but without the prototype methods of DomainObject. \n\n\n### Example - with angular_restify\n\n\tvar rest = new $rest(url,actions);\n\trest.save(entity).then(function(savedEntity){\n\t\t\n\t})\nHere **entity** is an object literal and **savedEntity** is an object literal. Like angular resource you can also specify your own actions, like so:\n\n\tvar actions = {\n\t\tget : {\n\t\t\turl : getUrl,\n\t\t\tmethod : 'GET',\n\t\t\ttransformRequest : function(response){\n\t\t\t\treturn new DomainObject(response);\n\t\t\t}\n\t\t}\n\t}\nBUT with a big difference. What comes back is a DomainObject, not a Resource object with DomainObject properties.\n\n## How to use\n\n### Installation\n\n\tbower install angular_restify\n### Usage\nAdd a script reference to rest.js\n\n\t\u003cscript arc=\"bower_components/angular_restify/rest.js\" /\u003e\n\nAdd a module reference to *restify*, like so\n\n\tangular.module('myApp',[ 'restify' ]);\nUse it by injecting and instantiating $rest, like so:\n\n\trest = new $rest(baseUrl + '/Books',actions);\n#### CRUD example\n\napp.js\n\n\tangular.module('myApp',[ 'restify' ])\n\t\t.controller('appCtrl',function($scope, $rest){\n\t\t\tvar rest = $rest(baseUrl + '/Books');\n\t\t\trest.save({ title : 'Farewell to arms', author : 'Hemingway'  }).then(function(savedBook){\n\n\t\t\t});\n\n\t\t\trest.update({ id : 11, title : 'Farewell to arms - updated title', author : 'Hemingway'  }).then(function(updatedBook){\n\n\t\t\t});\n\n\t\t\trest.get().then(function(allBooks){\n\n\t\t\t});\n\n\t\t\trest.get({ id : 11 }).then(function(bookWithId){\n\n\t\t\t});\n\n\t\t\trest.remove({ id : 13 }).then(function(removedEntity){\n\n\t\t\t});\n\t\t})\n\n#### Custom method - example\n\n\t\tvar actions = {\n\t\t\tbooksByAuthorAndYear : {\n\t\t\t\tmethod : 'GET',\n\t\t\t\turl : baseUrl + '/Books/:author/:year',\n\t\t\t\treplaceParams : [ 'author','year' ]\n\t\t\t\ttransformResponse : function(response){\n\t\t\t\t\tvar books = [];\n\t\t\t\t\tresponse.forEach(function(book){\n\t\t\t\t\t\tbooks.push(new Book(book));\n\t\t\t\t\t})\n\t\n\t\t\t\t\treturn books;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\n\t\tvar rest = $rest(baseUrl + '/Books', actions);\n\t\trest.booksByAuthorAndYear({ author : 11, year : 1890 }).then(function(books){\n\n\t\t});\n\nFor a complete code example, please refer to /example directory. It is a complete frontend and backend in nodejs with express.\n\n\n\n\n\n  \n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftchris%2Fangular_restify","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsoftchris%2Fangular_restify","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsoftchris%2Fangular_restify/lists"}