{"id":16557652,"url":"https://github.com/twlite/localkv","last_synced_at":"2025-03-23T13:32:38.827Z","repository":{"id":220822598,"uuid":"752713319","full_name":"twlite/localkv","owner":"twlite","description":"Asynchronous KV store utility to easily pass data/context in JavaScript applications.","archived":false,"fork":false,"pushed_at":"2025-03-01T18:57:05.000Z","size":59,"stargazers_count":1,"open_issues_count":5,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-14T22:06:36.781Z","etag":null,"topics":["api","async","bun","context","deno","kv","local","node","workers"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/twlite.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,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-02-04T15:52:27.000Z","updated_at":"2024-02-04T17:05:03.000Z","dependencies_parsed_at":"2024-02-04T16:23:16.816Z","dependency_job_id":"5b4fa594-b67a-4701-b95d-15409766d89a","html_url":"https://github.com/twlite/localkv","commit_stats":null,"previous_names":["twlite/localkv"],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twlite%2Flocalkv","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twlite%2Flocalkv/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twlite%2Flocalkv/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/twlite%2Flocalkv/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/twlite","download_url":"https://codeload.github.com/twlite/localkv/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245108319,"owners_count":20562021,"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":["api","async","bun","context","deno","kv","local","node","workers"],"created_at":"2024-10-11T20:08:09.509Z","updated_at":"2025-03-23T13:32:38.314Z","avatar_url":"https://github.com/twlite.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# LocalKV\n\nLocalKV is a simple, type-safe key-value data store to pass data or context between different parts of your application without propagating it through the whole application.\n\n## Installation\n\n```bash\n$ npm install localkv\n```\n\n## Usage\n\n### Example with Express web server\n\n```javascript\nimport { randomUUID } from 'node:crypto';\nimport express from 'express';\nimport { KV } from 'localkv';\n\nconst app = express();\n\n// create a new instance of KV\nconst kv = new KV();\n\n// middleware to generate a new request id\napp.use((req, res, next) =\u003e {\n  // generate new id for each request\n  const id = randomUUID();\n\n  console.log(`Request ID Generated: ${id}`);\n  // ^ \"Request ID Generated: e4ce829d-7f67-453a-bc5a-a9db8e4edeef\"\n\n  // create a new context for this request\n  kv.with(() =\u003e {\n    // set the request-id key to the generated id in this context\n    kv.set('request-id', id);\n\n    // execute the next middleware.\n    next();\n  });\n});\n\napp.get('/', (req, res) =\u003e {\n  // get the request-id from the context. Correct data will be automatically available without passing it through the whole application or mutating the request object.\n  const id = kv.get('request-id');\n\n  // send the id as response\n  res.json({ id });\n});\n\napp.listen(3000, () =\u003e {\n  console.log('Server is running on port 3000');\n});\n```\n\n#### Testing\n\n```bash\n$ curl http://localhost:3000\n# {\"id\":\"e4ce829d-7f67-453a-bc5a-a9db8e4edeef\"}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwlite%2Flocalkv","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftwlite%2Flocalkv","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftwlite%2Flocalkv/lists"}