{"id":24862055,"url":"https://github.com/evozonjs/elements","last_synced_at":"2025-09-08T04:38:38.556Z","repository":{"id":149828758,"uuid":"82375355","full_name":"evozonjs/elements","owner":"evozonjs","description":null,"archived":false,"fork":false,"pushed_at":"2017-02-18T16:00:14.000Z","size":9,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-03-08T17:01:50.908Z","etag":null,"topics":["message-format"],"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/evozonjs.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-02-18T09:15:41.000Z","updated_at":"2017-02-18T13:41:59.000Z","dependencies_parsed_at":null,"dependency_job_id":"39c48ac6-dec1-4acc-84cf-57c4c1b82650","html_url":"https://github.com/evozonjs/elements","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evozonjs%2Felements","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evozonjs%2Felements/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evozonjs%2Felements/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/evozonjs%2Felements/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/evozonjs","download_url":"https://codeload.github.com/evozonjs/elements/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245699263,"owners_count":20657987,"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":["message-format"],"created_at":"2025-01-31T22:21:43.270Z","updated_at":"2025-03-26T17:16:16.091Z","avatar_url":"https://github.com/evozonjs.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Standard - JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](http://standardjs.com/)\n# Evozonjs Elements\nEvozonjs Elements is a suite of basic building blocks used in the JavaScript department of [Evozon](https://evozon.com).\n\n## Setup\n```\nnpm install git://github.com/evozonjs/elements.git --save\n```\n\n## elements/response\n\nelements/response proposes a standard format for json messages. We use the following attributes:\n\nName       | Type         | Required | Default | Description\n---------- | ------       | -------- | ------- | -------\n`uid`      |`string`      | NO       | auto    | a unique timebased message identifier (based on node-uuid v1)\n`ok`       |`boolean`     | YES      |         | status of the message\n`code`     |`number`      | NO       | `0`     | a numeric code\n`data`     |`array|object`| NO       | `{}`    | main data container\n`metadata` |`object`      | NO       | `{}`    | secondary data container\n`err`      |`string`      | NO       | `''`    | will contain an error message in case of an error\n`msg`      |`string`      | NO       | `''`    | an extra message\n\nThe constructor accepts the following instantiation scenarios:\n\n```javascript\n// load an element\nconst response = require('elements/response');\n\n// 1 object parameter holding some or all the attributes.\n// remember that 'ok' attribute is required\nconsole.log(new response({ ok: false, err: 'some error'}));\n\n/**\n-- will return --\n{ uid: '76a16e00-f5dc-11e6-af8e-cf6322a4a5f7',\n  ok: true,\n  code: 0,\n  data: {},\n  metadata: {},\n  err: '',\n  msg: '' }\n*/\n\n// or 1 boolean parameter considered as being the 'ok' attribute\nconsole.log(response(true));\n/**\n-- will return --\n{ uid: '76a16e00-f5dc-11e6-af8e-cf6322a4a5f7',\n  ok: true,\n  code: 0,\n  data: {},\n  metadata: {},\n  err: '',\n  msg: '' }\n*/\n\n// or 2 parameters considered as being the 'ok' attribute and the 'data' attribute\nconsole.log(new response(true, [1,2,3]));\n/**\n-- will return --\n{ uid: 'f66328d0-f5dd-11e6-9ba8-61642a559e2e',\n  ok: true,\n  code: 0,\n  data: [ 1, 2, 3 ],\n  metadata: { count: 3 },\n  err: '',\n  msg: '' }\n*/\n\n// or 3 parameters considered as being the 'ok' attribute, the 'data' attribute, and the 'metadata' attribute\nconsole.log(response(true, [1,2,3], { extra: 'some data' }));\n/**\n-- will return --\n{ uid: 'd6f81960-f5dd-11e6-94ca-35a81f2588d0',\n  ok: true,\n  code: 0,\n  data: [ 1, 2, 3 ],\n  metadata: { extra: 'some data', count: 3 },\n  err: '',\n  msg: '' }\n*/\n\n```\n\nAs a bonus, if the `data` attribute is an array, and if `metadata.count` is not defined by the user the constructor will\nautomatically put the array length into `metadata.count`.\n\nIf the format of an attribute is not accepted and error will be thrown.\n\n## Licence\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevozonjs%2Felements","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fevozonjs%2Felements","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fevozonjs%2Felements/lists"}