{"id":23665914,"url":"https://github.com/matter-in-motion/mm-http","last_synced_at":"2026-04-14T18:33:03.033Z","repository":{"id":57299102,"uuid":"98261289","full_name":"matter-in-motion/mm-http","owner":"matter-in-motion","description":"HTTP transport","archived":false,"fork":false,"pushed_at":"2019-05-06T18:30:53.000Z","size":16,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-06T17:16:07.294Z","etag":null,"topics":["api","extension","http","http-transport","matter-in-motion","transport"],"latest_commit_sha":null,"homepage":null,"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/matter-in-motion.png","metadata":{"files":{"readme":"readme.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-07-25T03:42:35.000Z","updated_at":"2019-05-06T18:30:53.000Z","dependencies_parsed_at":"2022-08-26T18:02:31.899Z","dependency_job_id":null,"html_url":"https://github.com/matter-in-motion/mm-http","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"purl":"pkg:github/matter-in-motion/mm-http","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matter-in-motion%2Fmm-http","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matter-in-motion%2Fmm-http/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matter-in-motion%2Fmm-http/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matter-in-motion%2Fmm-http/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/matter-in-motion","download_url":"https://codeload.github.com/matter-in-motion/mm-http/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/matter-in-motion%2Fmm-http/sbom","scorecard":{"id":626240,"data":{"date":"2025-08-11","repo":{"name":"github.com/matter-in-motion/mm-http","commit":"0947bf7f6a5fa794a0d13d97d7162feaae895291"},"scorecard":{"version":"v5.2.1-40-gf6ed084d","commit":"f6ed084d17c9236477efd66e5b258b9d4cc7b389"},"score":3,"checks":[{"name":"Binary-Artifacts","score":10,"reason":"no binaries found in the repo","details":null,"documentation":{"short":"Determines if the project has generated executable (binary) artifacts in the source repository.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#binary-artifacts"}},{"name":"SAST","score":0,"reason":"no SAST tool detected","details":["Warn: no pull requests merged into dev branch"],"documentation":{"short":"Determines if the project uses static code analysis.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#sast"}},{"name":"Token-Permissions","score":-1,"reason":"No tokens found","details":null,"documentation":{"short":"Determines if the project's workflows follow the principle of least privilege.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#token-permissions"}},{"name":"Packaging","score":-1,"reason":"packaging workflow not detected","details":["Warn: no GitHub/GitLab publishing workflow detected."],"documentation":{"short":"Determines if the project is published as a package that others can easily download, install, easily update, and uninstall.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#packaging"}},{"name":"Code-Review","score":0,"reason":"Found 0/23 approved changesets -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project requires human code review before pull requests (aka merge requests) are merged.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#code-review"}},{"name":"Maintained","score":0,"reason":"0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0","details":null,"documentation":{"short":"Determines if the project is \"actively maintained\".","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#maintained"}},{"name":"Pinned-Dependencies","score":-1,"reason":"no dependencies found","details":null,"documentation":{"short":"Determines if the project has declared and pinned the dependencies of its build process.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#pinned-dependencies"}},{"name":"Dangerous-Workflow","score":-1,"reason":"no workflows found","details":null,"documentation":{"short":"Determines if the project's GitHub Action workflows avoid dangerous patterns.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#dangerous-workflow"}},{"name":"CII-Best-Practices","score":0,"reason":"no effort to earn an OpenSSF best practices badge detected","details":null,"documentation":{"short":"Determines if the project has an OpenSSF (formerly CII) Best Practices Badge.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#cii-best-practices"}},{"name":"Security-Policy","score":0,"reason":"security policy file not detected","details":["Warn: no security policy file detected","Warn: no security file to analyze","Warn: no security file to analyze","Warn: no security file to analyze"],"documentation":{"short":"Determines if the project has published a security policy.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#security-policy"}},{"name":"Fuzzing","score":0,"reason":"project is not fuzzed","details":["Warn: no fuzzer integrations found"],"documentation":{"short":"Determines if the project uses fuzzing.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#fuzzing"}},{"name":"Vulnerabilities","score":10,"reason":"0 existing vulnerabilities detected","details":null,"documentation":{"short":"Determines if the project has open, known unfixed vulnerabilities.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#vulnerabilities"}},{"name":"Signed-Releases","score":-1,"reason":"no releases found","details":null,"documentation":{"short":"Determines if the project cryptographically signs release artifacts.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#signed-releases"}},{"name":"License","score":10,"reason":"license file detected","details":["Info: project has a license file: LICENSE:0","Info: FSF or OSI recognized license: MIT License: LICENSE:0"],"documentation":{"short":"Determines if the project has defined a license.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#license"}},{"name":"Branch-Protection","score":0,"reason":"branch protection not enabled on development/release branches","details":["Warn: branch protection not enabled for branch 'master'"],"documentation":{"short":"Determines if the default and release branches are protected with GitHub's branch protection settings.","url":"https://github.com/ossf/scorecard/blob/f6ed084d17c9236477efd66e5b258b9d4cc7b389/docs/checks.md#branch-protection"}}]},"last_synced_at":"2025-08-21T06:33:08.142Z","repository_id":57299102,"created_at":"2025-08-21T06:33:08.142Z","updated_at":"2025-08-21T06:33:08.142Z"},"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31810737,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-14T18:05:02.291Z","status":"ssl_error","status_checked_at":"2026-04-14T18:05:01.765Z","response_time":153,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"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":["api","extension","http","http-transport","matter-in-motion","transport"],"created_at":"2024-12-29T06:19:51.651Z","updated_at":"2026-04-14T18:33:03.016Z","avatar_url":"https://github.com/matter-in-motion.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Matter In Motion. HTTP transport\n\n[![NPM Version](https://img.shields.io/npm/v/mm-http.svg?style=flat-square)](https://www.npmjs.com/package/mm-http)\n[![NPM Downloads](https://img.shields.io/npm/dt/mm-http.svg?style=flat-square)](https://www.npmjs.com/package/mm-http)\n\nHttp transport extension for [matter in motion](https://github.com/matter-in-motion/mm) framework\n\n## Usage\n\n[Transport installation instructions](https://github.com/matter-in-motion/mm/blob/master/docs/transports.md)\n\n_Http transport adds `root` property to the `app`. It is just an `express` instance. Also, you can use `app.use` method to add a contract or any other express-compatible handler_\n\n### Protocol\n\nTo use all advantages of HTTP protocol:\n\n* __GET__\n  1. Add `call` in the URL after API URL\n  2. Add `body` as query string\n* __POST__\n  1. Add special `MM` header with call as JSON string\n  2. Send `body` as string, number, boolean, or JSON string in request body\n\nPut meta field in the standard `Authorization: Bearer` header.\n\n**HTTP request requires `Accept` and `Content-Type` headers to be set to `application/json`**\n\nThe response will come as JSON string.\n\nFrom the browser looks like this:\n\n#### `GET` request:\n\n```js\nconst xhr = new XMLHttpRequest();\nxhr.open('GET', '/api/world.hello?name=John', true);\nxhr.setRequestHeader('Authorization', 'Bearer ' + meta);\nxhr.setRequestHeader('Accept', 'application/json');\nxhr.send();\nxhr.onload = function() {\n  if (xhr.status === 200) {\n    let msg = JSON.parse(xhr.responseText);\n    console.log(msg);\n  } else {\n    console.log(xhr.status);\n  }\n}\n\n```\n\n#### `POST` request:\n\n```js\nconst xhr = new XMLHttpRequest();\nxhr.open('POST', '/api', true);\nxhr.setRequestHeader('MM', JSON.stringify({ call: 'world.hello' }) );\nxhr.setRequestHeader('Authorization', 'Bearer ' + token);\nxhr.setRequestHeader('Accept', 'application/json');\nxhr.setRequestHeader('Content-Type', 'application/json');\nxhr.send(body);\nxhr.onload = function() {\n  if (xhr.status === 200) {\n    let msg = JSON.parse(xhr.responseText);\n    console.log(msg);\n  } else {\n    console.log(xhr.status);\n  }\n}\n\n```\n\nIf you make `POST` request with content type set to `multipart/*` message will be marked as raw and request object will be passed into your API call method, so you can parse it any way you want.\n\n#### `OPTIONS` request\n\nThis is similar to the `POST` but it will transform into **question request** and body will be ignored\n\n## Settings\n\nOnly `port` option is required. Everything else is optional.\n\n* __port__ — number. Accepting connections on the specified port\n* __host__ — string, '0.0.0.0'. Accepting connections on the specified hostname.\n* __limit__ — number, null. Limit content length for the api request\n* __encoding__ — string, 'utf8'. Encoding of the api request\n* __cors__ — defines the cross-origin HTTP request control. Every option adds corresponding http headers for preflight `OPTIONS` request and for actual request\n  - __allowOrigin__ — Recomended for the matter in motion protocol: '*',\n  - __allowMethods__ — Recomended for the matter in motion protocol: 'GET, POST, OPTIONS',\n  - __allowHeaders__ — Recomended for the matter in motion protocol: 'Authorization, Origin, Content-Type, Accept, MM',\n  - __maxAge__ — Recomended for the matter in motion protocol: 1728000\n* __tls__ — instead of http server will create https server, this should be the [https server settings](https://nodejs.org/api/https.html#https_https_createserver_options_requestlistener)\n* __static__ — adds `express.static` static files handler. For more info look into [official documentation](https://expressjs.com/en/4x/api.html#express.static)\n  - __url__ — string, static url path\n  - __root__ — string, root directory from which the static assets are to be served\n  - __dotfiles__ — string, 'ignore'. Option for serving dotfiles. Possible values are “allow”, “deny”, and “ignore”\n  - __etag__ — boolean, true. Enable or disable etag generation\n  - __extensions__ — Sets file extension fallbacks: If a file is not found, search for files with the specified extensions and serve the first one found. Example: ['html', 'htm'].\n  - __index__ — string, 'index.html'. Sends the specified directory index file. Set to false to disable directory indexing.\n  - __lastModified__ — boolean, true. Set the Last-Modified header to the last modified date of the file on the OS.\n  - __maxAge__ — number, 0. Set the max-age property of the Cache-Control header in milliseconds or a string in ms format\n  - __redirect__ — boolean, true. Redirect to trailing “/” when the pathname is a directory.\n  - __setHeaders__ — function for setting HTTP headers to serve with the file.\n\n## Contract\n\nThe contract is a subclass of the express Router class that makes easy to add unit views.\n\nTo use as sub contract define `handle` method as express-like middleware\n\n### addView(path, view)\n\n* __path__ — path to add view to\n* __view__ — name of the view unit\n\n### addViews(obj)\n\nAdds all views from `obj`:\n```js\nthis.addViews({\n  '/?': 'index',\n  '/contacts/?': 'contacts'\n})\n```\n\n### HTTP Methods\n\nAll the standart http methods (check the `require('http').METHODS`), except `OPTIONS` can be used as methods for your resource. To do that, you need to use uppercase method name as an API call declaration. Example:\n\n```js\n  GET: function() {\n    return {\n      title: 'HTTP Test',\n      description: 'returns the get request data',\n      request: {},\n      response: {},\n      call: (auth, data) =\u003e data\n    }\n  }\n```\n\nAnd call it as `GET /api/resource`.\n\n\nLicense: MIT\n\n© velocityzen\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatter-in-motion%2Fmm-http","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmatter-in-motion%2Fmm-http","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmatter-in-motion%2Fmm-http/lists"}