{"id":23752770,"url":"https://github.com/ziv/local-storage-nest","last_synced_at":"2025-10-27T03:04:08.832Z","repository":{"id":36960037,"uuid":"384134429","full_name":"ziv/local-storage-nest","owner":"ziv","description":"AsyncLocalStorage middleware for Nest","archived":false,"fork":false,"pushed_at":"2022-12-19T08:02:33.000Z","size":590,"stargazers_count":2,"open_issues_count":7,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-02-03T05:34:58.688Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/ziv.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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":"2021-07-08T13:30:57.000Z","updated_at":"2023-03-07T12:53:12.000Z","dependencies_parsed_at":"2022-08-24T21:01:20.059Z","dependency_job_id":null,"html_url":"https://github.com/ziv/local-storage-nest","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":"ziv/node-js-typescript-library-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziv%2Flocal-storage-nest","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziv%2Flocal-storage-nest/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziv%2Flocal-storage-nest/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ziv%2Flocal-storage-nest/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ziv","download_url":"https://codeload.github.com/ziv/local-storage-nest/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239921843,"owners_count":19718844,"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-12-31T17:55:40.341Z","updated_at":"2025-10-27T03:04:08.739Z","avatar_url":"https://github.com/ziv.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# local-storage-nest\n\n[![CI](https://github.com/ziv/local-storage-nest/actions/workflows/main.yml/badge.svg)](https://github.com/ziv/local-storage-nest/actions/workflows/main.yml)\n[![CodeQL](https://github.com/ziv/local-storage-nest/actions/workflows/codeql-analysis.yml/badge.svg)](https://github.com/ziv/local-storage-nest/actions/workflows/codeql-analysis.yml)\n[![codecov](https://codecov.io/gh/ziv/local-storage-nest/branch/main/graph/badge.svg?token=4CXU2IUIL8)](https://codecov.io/gh/ziv/local-storage-nest)\n\n[AsyncLocalStorage](https://nodejs.org/api/async_context.html#async_context_class_asynclocalstorage) Module for NestJs\nwrap [local-storage](https://github.com/ziv/local-storage) middleware.\n\n## Install\n\n```shell\nnpm i @xpr/local-storage-nest\n```\n\n## Usage\n\n### Configure Routes\n\nRegister routes in your `root` module:\n\n```typescript\nimport { LocalStorageModule } from '@xpr/local-storage-nest';\nimport { RequestMethod } from '@nestjs/common';\n\n@Module({\n  imports: [\n    // assign localStorage middleware\n    // on all routes\n    LocalStorageModule.forRoutes({\n      path: '*',\n      method: RequestMethod.ALL\n    })\n  ]\n})\n```\n\n### Injectable\n\nThe provided `AsyncStorage` works with injectable classes.\n\n```typescript\nimport { Injectable } from '@nestjs/common';\nimport { AsyncStorage } from '@xpr/local-storage-nest';\n\n@Injectable()\nclass Service {\n  constructor(storage: AsyncStorage) {\n  }\n}\n```\n\n### Independent\n\nSince `AsyncStorage` have no constructor, you can initiate it without injecting it.\n\n```typescript\nimport { AsyncStorage } from '@xpr/local-storage-nest';\n\n// ready to go\nconst asyncStorage = new AsyncStorage();\n```\n\n### Async Context\n\nAccessing `AsyncStorage` outside of the async context created by the `AsyncStorage` will throw an exception.\n\n---\n\n![xpr-local-storage-nest](https://badgen.net/github/license/ziv/local-storage-nest)\n![Open Source Love](https://badges.frapsoft.com/os/v2/open-source.svg)\n![@xpr](https://badgen.net/badge/powered%20by/@xpr/pink)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziv%2Flocal-storage-nest","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fziv%2Flocal-storage-nest","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fziv%2Flocal-storage-nest/lists"}