{"id":17766609,"url":"https://github.com/floatdrop/memorize-middleware","last_synced_at":"2025-03-15T13:30:51.583Z","repository":{"id":21022873,"uuid":"24316288","full_name":"floatdrop/memorize-middleware","owner":"floatdrop","description":"Cache middleware request changes ","archived":false,"fork":false,"pushed_at":"2018-08-25T12:15:18.000Z","size":43,"stargazers_count":7,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-14T01:31:42.599Z","etag":null,"topics":[],"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/floatdrop.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":"2014-09-22T06:04:15.000Z","updated_at":"2019-02-08T08:58:36.000Z","dependencies_parsed_at":"2022-07-26T15:02:05.260Z","dependency_job_id":null,"html_url":"https://github.com/floatdrop/memorize-middleware","commit_stats":null,"previous_names":[],"tags_count":17,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fmemorize-middleware","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fmemorize-middleware/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fmemorize-middleware/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/floatdrop%2Fmemorize-middleware/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/floatdrop","download_url":"https://codeload.github.com/floatdrop/memorize-middleware/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243507758,"owners_count":20301888,"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-26T20:33:08.429Z","updated_at":"2025-03-15T13:30:51.578Z","avatar_url":"https://github.com/floatdrop.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# memorize-middleware [![Build Status][travis-image]][travis-url]\n\n\u003e Save changes, that middleware did on req and apply them after\n\n## Usage\n\n```js\nvar express = require('express');\nvar app = express();\nvar memorize = require('memorize-middleware');\n\nvar middleware = function (req, res, next) {\n    console.log('Called once');\n    req.message = 'Boop!';\n    next();\n};\n\napp.use(memorize(middleware));\napp.get('/', function (req, res, next) {\n    res.send(req.message);\n});\n\napp.listen(8080);\n```\n\n### States\n\nThere are couple states in which `memorize` works:\n\n1. __No cache__ - all requests will be halted, while result is pending.\n2. __Middleware failed and there is no cached value__ - Error will be passed to next middleware.\n3. __Result recieved__ - It will be stored, all pending clients will get result, all next clients will get this result instantly. If `updateInterval` set - it will be scheduled.\n\nIf `updateInterval` is set:\n\n1. __Middleware failed in update time__ - Nothing will happen, all clients will recieve previous version, new update will be scheduled.\n2. __Result recieved in update time__ - Previous result will be swapped with new one.\n\n## API\n\n### memorize(middleware, [options])\n\nCreates middleware, that will call `middleware` and cache changes, that it did to req object.\n\n#### middleware\nType: `Function`\n\nMiddleware, which changes should be cached.\n\n#### options\n\n##### updateInterval\nType: `Number`  \nDefault: `0` — never\n\nHow often (in milliseconds) should `memorize` request new data for middleware. Don't make it too low.\n\n## License\n\nThe MIT License (MIT) © [Vsevolod Strukchinsky](floatdrop@gmail.com)\n\n[travis-url]: https://travis-ci.org/floatdrop/memorize-middleware\n[travis-image]: http://img.shields.io/travis/floatdrop/memorize-middleware.svg?style=flat\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatdrop%2Fmemorize-middleware","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ffloatdrop%2Fmemorize-middleware","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ffloatdrop%2Fmemorize-middleware/lists"}