{"id":18084735,"url":"https://github.com/coderofsalvation/ohmygraph","last_synced_at":"2025-04-06T00:12:52.013Z","repository":{"id":57313874,"uuid":"45568926","full_name":"coderofsalvation/ohmygraph","owner":"coderofsalvation","description":"Easily generate a REST (graph)client from a json api-modelspecification. Like restangular/traverse/backbone/restful but more atheist-style.","archived":false,"fork":false,"pushed_at":"2020-09-10T17:56:39.000Z","size":410,"stargazers_count":2,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-31T09:16:39.196Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"http://coderofsalvation.github.io/ohmygraph/index.html","language":"Shell","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/coderofsalvation.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null},"funding":{"custom":"https://gumroad.com/l/hGYGh"}},"created_at":"2015-11-04T21:34:12.000Z","updated_at":"2020-05-28T19:20:39.000Z","dependencies_parsed_at":"2022-09-20T23:21:36.410Z","dependency_job_id":null,"html_url":"https://github.com/coderofsalvation/ohmygraph","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/coderofsalvation%2Fohmygraph","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fohmygraph/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fohmygraph/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderofsalvation%2Fohmygraph/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderofsalvation","download_url":"https://codeload.github.com/coderofsalvation/ohmygraph/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247415976,"owners_count":20935387,"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-31T15:07:57.608Z","updated_at":"2025-04-06T00:12:51.986Z","avatar_url":"https://github.com/coderofsalvation.png","language":"Shell","funding_links":["https://gumroad.com/l/hGYGh"],"categories":[],"sub_categories":[],"readme":"\u003ccenter\u003e\u003cimg src=\"https://raw.githubusercontent.com/coderofsalvation/ohmygraph/master/.npm/logo.png\" width=\"40%\"/\u003e\u003c/center\u003e\n\n# Usage:\n\n    npm install ohmygraph\n\nor in the browser (6k when gzipped):\n\n    \u003cscript type=\"text/javascript\" src=\"ohmygraph.min.js\"\u003e\u003c/script\u003e \n\nTry the [online editor](http://coderofsalvation.github.io/ohmygraph/index.html)\n\n# Video\n\n[![VIDEO](http://img.youtube.com/vi/XrE-KVrLSaI/0.jpg)](http://www.youtube.com/watch?v=XrE-KVrLSaI)\n    \n# Example: github api\n\n    ohmygraph = require 'ohmygraph'\n\n    graph =\n      repositories:\n        type: \"array\"\n        items: [{\"$ref\":\"#/repository\"}]\n        data: { sort:'stars',q:'ohmy',order:'desc' }\n        request:\n          get:\n            config:\n              method: 'get'\n              url: '/search/repositories'\n              payload:\n                q: '{repositories.data.q}'\n                sort: '{repositories.data.sort}'\n                order: '{repositories.data.order}'\n            data: \"{response.items}\"\n      repository:\n        type: \"object\"\n        properties: { ..... }\n        data: {}\n        request:\n          get:\n            config:\n              method: 'get'\n              url: '/repos/{repository.data.full_name}'\n              payload: {}\n            data: \"{response}\"\n          post:\n            type: \"request\"\n            config:\n              method: \"post\"\n              url: '/repos/{repository.data.full_name}'\n              payload:\n                'full_name': '{repository.data.full_name}'\n\n\n    omg = ohmygraph.create graph, {baseurl: \"https://api.github.com\",verbose:2}\n    omg.init.client()\n    client = omg.graph\n\n    client.repositories.on 'data', (repositories) -\u003e\n      console.log \"on repositories\"\n      repositories[0].get()\n\n    client.repository.on 'data', (repository) -\u003e\n      console.log \"on repository\"\n      console.dir repository\n\n    # lets request data!\n    client.repositories.get()\n    client.repositories.get {q:\"foo\"}\n# Features\n\n* modular multi-api REST client\n* resource linking (using a graph)\n* easy to use with API's generated from json-model (just convert the model)\n* only deal with dataobjects in javascript, not with REST code\n* datamodel does not dictate api model (like backbone)\n* fully customizable webcalls using fetch, [docs here](see https://www.npmjs.com/package/whatwg-fetch)\n\n# Example: combining API's\n\n    api_one = {..}\n    api_two = {..}\n\n    omg = ohmygraph.create();\n    omg.graph = api_one;\n    for (k in api_two) omg.graph[k] = api_two[k];\n\n    omg.init.client();\n\n# Example: patching/extending api-calls\n\nSometimes an jsonmodel needs to be patched.\nLuckily, [json-ref-lite](https://www.npmjs.com/package/json-ref-lite#example-json-inheritance-extensions)'s \"$extend\" keys are automatically parsed.\n\n# Api \n\ngraph = graph\n\u003e access your resolved graph here\n\ncreate(graph = {},opts = {})\n\u003e create graph\n\ninit.client()\n\u003e generate client functions from graph(after create())\n\nextend()\n\u003e extend \"$extend\" keys in graph\n\nresolve()\n\u003e resolve \"$ref\" references in graph\n\nexport_functions(return_array_boolean)\n\u003e dump client functions as string or array\n\nyournode.bindrequests(node)\n\u003e autobind client requesthandlers on node\n\nyournode.trigger(event,data)\n\u003e trigger an event on your nodeyournode.trigger('foo',{data:'bar'})\nyournode.on(event,cb)\n\u003e register an event on your nodeyournode.on( 'foo', function(){} )\n\nyournode.clone()\n\u003e call clone() on a node to keep the original intact \n\nget(node)\n\u003e get node with name x\n\nclone(obj)\n\u003e deep clone object utility function\n\nonWarning(err)\n\u003e customizable warning function\n\nonError()\n\u003e customizable error/catch function\n\n# Inspired by\n\nThis work was inspired by the thought that linking of resources could happen on a json model-level, instead of only on a RESTful level (interpreting links from responses).\nOhmygraph is pretty much jsonbased and framework- and API-agnostic, but it was inspired by:\n\n[backbone/exoskeleton](http://backbonejs.org)\n\u003e requires particular api design\n\n[restangular](https://github.com/mgonto/restangular)\n\u003e angular based router which requires angular + a particular api design.\n\n[restful.js](https://github.com/marmelab/restful.js)\n\u003e restangular without angular but with particular api design\n\n[traverson](https://github.com/basti1302/traverson)\n\u003e no restmapping, only linking\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderofsalvation%2Fohmygraph","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderofsalvation%2Fohmygraph","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderofsalvation%2Fohmygraph/lists"}