{"id":17540557,"url":"https://github.com/inadarei/kokua","last_synced_at":"2025-04-23T22:53:40.517Z","repository":{"id":52973990,"uuid":"115231971","full_name":"inadarei/kokua","owner":"inadarei","description":"Hypermedia Representor implemented with Hyper+json ","archived":false,"fork":false,"pushed_at":"2022-08-25T18:49:31.000Z","size":86,"stargazers_count":4,"open_issues_count":1,"forks_count":1,"subscribers_count":6,"default_branch":"main","last_synced_at":"2025-04-23T22:53:34.643Z","etag":null,"topics":["collection-json","hal","hyper","hypermedia","siren","uber"],"latest_commit_sha":null,"homepage":"http://hyperjson.io/","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/inadarei.png","metadata":{"files":{"readme":"README-PLUGINDEV.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":"2017-12-24T01:18:10.000Z","updated_at":"2023-10-15T23:36:23.000Z","dependencies_parsed_at":"2022-09-04T06:22:35.739Z","dependency_job_id":null,"html_url":"https://github.com/inadarei/kokua","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/inadarei%2Fkokua","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inadarei%2Fkokua/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inadarei%2Fkokua/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/inadarei%2Fkokua/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/inadarei","download_url":"https://codeload.github.com/inadarei/kokua/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250528698,"owners_count":21445511,"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":["collection-json","hal","hyper","hypermedia","siren","uber"],"created_at":"2024-10-20T22:24:17.471Z","updated_at":"2025-04-23T22:53:40.492Z","avatar_url":"https://github.com/inadarei.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Kōkua - Plugin Developer's Guide\n\nTypical structure of a plugin looks like the following:\n\n```javascript\nconst log      = require(\"metalogger\")();\nconst _        = require(\"lodash\");\nconst traverse = require(\"traverse\");\nconst hutil    = require(\"./hutil\");\n\nclass YourNewPlugin {\n  constructor(message) {\n    if (typeof message !== 'object') {\n      this.doc = JSON.parse(message);\n    } else {\n      this.doc = message;\n    }\n    this.newDoc = {};\n  }\n\n  translate() {\n    this.handleSomeTransformation();\n    this.hanldeAnotherTransformation();\n    this.hanldeYetAnotherTransformation();\n\n    return this.newDoc;\n  }\n}\n\nmodule.exports = (doc) =\u003e {\n  const representor = new YourNewPlugin(doc);\n  return representor;\n};\n```\n\nTo add a new implementation to Kokua, a corresponding setting should be\nadded to the list of supported plugins in lib/kokua.js:\n\n```javascript\nconst formats = {\n  \"hal\" : \"application/hal+json\",\n  \"siren\" : \"application/vnd.siren+json\",\n  \"coljson\" : \"application/vnd.collection+json\",\n  \"uber\" : \"application/vnd.uber+json\",\n\n  \"shortname\" : \"official/media+type\"\n\n};\n```\n\n### Plugin Implementation File Naming\n\nIf you are implementing Hyper -\u003e HAL conversion, and the entry in the formats\narray is `\"hal\" : \"application/hal+json\"` then:\n\n1. lib/plugins/hal.js - implements conversion from Hyper to HAL\n1. lib/plugins/hal-reverse.js - implements conversion from HAL to Hyper\n\nIn either case the structure of the file is as shown above.\n\n### Tests!\n\nLast but not least: obviously a plugin should be fully covered with tests.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finadarei%2Fkokua","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finadarei%2Fkokua","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finadarei%2Fkokua/lists"}