{"id":19613864,"url":"https://github.com/webmatze/micro-middleware","last_synced_at":"2025-04-28T01:31:22.889Z","repository":{"id":57151920,"uuid":"83672390","full_name":"webmatze/micro-middleware","owner":"webmatze","description":"a simple helper to add middleware to your zeit/micro service","archived":false,"fork":false,"pushed_at":"2018-11-26T13:43:02.000Z","size":6,"stargazers_count":5,"open_issues_count":2,"forks_count":2,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-04-17T01:15:16.227Z","etag":null,"topics":["helper","micro","middleware"],"latest_commit_sha":null,"homepage":"","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/webmatze.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":"2017-03-02T11:53:15.000Z","updated_at":"2024-04-02T06:55:09.000Z","dependencies_parsed_at":"2022-09-03T13:12:07.270Z","dependency_job_id":null,"html_url":"https://github.com/webmatze/micro-middleware","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/webmatze%2Fmicro-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webmatze%2Fmicro-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webmatze%2Fmicro-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/webmatze%2Fmicro-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/webmatze","download_url":"https://codeload.github.com/webmatze/micro-middleware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251233531,"owners_count":21556709,"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":["helper","micro","middleware"],"created_at":"2024-11-11T10:49:05.038Z","updated_at":"2025-04-28T01:31:22.649Z","avatar_url":"https://github.com/webmatze.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# micro-middleware\n\n\u003e a simple helper to add middleware to your zeit/micro service\n\nThis will become a set of simple helpers to create and apply middleware to your microsevices using [Zeit](https://zeit.co/)'s [micro](https://github.com/zeit/micro) framework.\n\n## Install\n\nInstall with [npm](https://www.npmjs.com/)\n\n```sh\n$ npm i micro-middleware --save-dev\n```\n\n## Usage\n\n### Create a simple middleware\n\n```js\n// require micro-middleware helper\nvar { applyMiddleware } = require('micro-middleware')\n\n// a simple middleware should look like this\nconst logging = fn =\u003e async function process (...args) {\n  console.log(`log args: ${args}`)\n  let data = await fn.apply(null, args)\n  console.log(`log returned data: ${data}`)\n  return data\n}\n\nconst middleware = [\n  logging\n]\n\n// create your micro service\nconst microService = async (req, res) =\u003e {\n    return \"hello world\"\n}\n\n// apply middleware and export\nmodule.exports = applyMiddleware(microService, middleware)\n\n```\n\n### Apply existing middleware to your microservice\n\n```js\n// require micro-middleware helper\nvar { applyMiddleware } = require('micro-middleware')\n\n// require some middleware for micro\nconst cors = require('micro-cors')()\nconst compress = require('micro-compress')\nconst middleware = [\n  cors, \n  compress\n]\n\n// create your micro service\nconst microService = async (req, res) =\u003e {\n    return \"hello world\"\n}\n\n// apply middleware and export\nmodule.exports = applyMiddleware(microService, middleware)\n```\n\n## Running tests\n\nInstall dev dependencies:\n\n```sh\n$ npm i -d \u0026\u0026 npm test\n```\n\n## Contributing\n\nPull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/webmatze/micro-middleware/issues)\n\n## Author\n\n**Mathias Karstädt**\n\n* [github/webmatze](https://github.com/webmatze)\n* [twitter/webmatze](http://twitter.com/webmatze)\n\n## License\n\nCopyright © 2017 [Mathias Karstädt](http://mathiaskarstaedt.de/)\nLicensed under the MIT license.\n\n***\n\n_This file was generated by [readme-generator](https://github.com/jonschlinkert/readme-generator) on March 03, 2017._\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebmatze%2Fmicro-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fwebmatze%2Fmicro-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fwebmatze%2Fmicro-middleware/lists"}