{"id":16944697,"url":"https://github.com/rustworthy/storedge","last_synced_at":"2025-04-05T14:43:46.854Z","repository":{"id":203233710,"uuid":"709130966","full_name":"rustworthy/storedge","owner":"rustworthy","description":"KV \u0026 Durable objects for serverless environments with Redis (Upstash HTTP API) and BSON serialization","archived":false,"fork":false,"pushed_at":"2024-04-22T02:10:00.000Z","size":53,"stargazers_count":0,"open_issues_count":2,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-03-15T04:37:05.779Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rustworthy.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","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":"2023-10-24T04:35:42.000Z","updated_at":"2023-10-24T04:49:15.000Z","dependencies_parsed_at":null,"dependency_job_id":"3f5f7b84-8038-4caa-92e0-0e07d97707a6","html_url":"https://github.com/rustworthy/storedge","commit_stats":null,"previous_names":["rustworthy/storedge"],"tags_count":1,"template":false,"template_full_name":"rustworthy/npm-javascript-starter-template","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustworthy%2Fstoredge","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustworthy%2Fstoredge/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustworthy%2Fstoredge/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rustworthy%2Fstoredge/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rustworthy","download_url":"https://codeload.github.com/rustworthy/storedge/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353676,"owners_count":20925325,"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-13T21:18:55.735Z","updated_at":"2025-04-05T14:43:46.839Z","avatar_url":"https://github.com/rustworthy.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# StorEdge\n\n## KV \u0026 Durable objects for serverless environments with Redis (Upstash HTTP API) and BSON serialization\n\n![example workflow](https://github.com/rustworthy/storedge/actions/workflows/general.yml/badge.svg)\n\n### Usage\n\nAfter installation (e.g.L with `npm i storedge`), import the library:\n\n```js\n// commonjs\nconst storedge = require('storedge');\n// esm\nimport * as storedge from 'storedge';\n```\n\nNow, assuming environment variables ('UPSTASH_REDIS_REST_URL' and 'UPSTASH_REDIS_REST_TOKEN') are alread loaded,\nyou can simply do:\n\n```js\nconst storedge = require('storedge');\n\nconst [error, store] = storedge.build();\nif (error) return console.error(error);\n\n// or in many cases:\n// if (error) {\n//  logger.error(error.message);\n//  return new Response('It's embarassing, but something went wrong :(', { status: 500 });\n// }\n\nconst myObject = {\n  id: '11251225122512',\n  name: 'Paul Michelle',\n  patterns: [/^Miche/g, /^Pa/i, /^Mi/g],\n  born: new Date(1979, 3, 21),\n  likes: ['food', 'movies', 'sports'],\n  contact: {\n    email: 'email@address.io',\n    phone: '555-555-5555',\n  },\n};\n\nconst key = await store.Durables.put(myObject, { key: '11251225122512' });\nconst restored = await store.Durables.get(key);\n\n// or if you want the libary to issue an objectId for your object,\n// you can omit the opts parameter:\nconst objectId = await store.Durables.put(myObject);\nconst restored = await store.Durables.get(objectId);\n```\n\nIf you want the library to load the variables from a dotenv file:\n\n```js\nconst storedge = require('storedge');\nconst [error, store] = storedge.with({ envFile: '.env.local' }).build();\n```\n\nIf you want the library to check that the Redis deployment is responsive and\nyour creds are just fine, you can go with:\n\n```js\nconst storedge = require('storedge');\nconst [error, store] = await storedge.with({ envFile: '.env.local' }).buildWithPing();\n```\n\nFinally, if you want to pass redis deployment url and token directly, you can do so with:\n\n```js\nconst storedge = require('storedge');\n\n// with literals...\nconst [error, store] = await storedge.with({ config: { url: 'https://***.io', token: 'AX95***NGY=' } }).build();\n\n// ...or with refs to env vars:\nconst [error, store] = await storedge\n  .with({\n    config: {\n      url: process.env.UPSTASH_REDIS_REST_URL,\n      token: process.env.UPSTASH_REDIS_REST_TOKEN,\n    },\n  })\n  .build();\n```\n\nAll the Upstash HTTP Api methods are available in the store.KV namespace,\nand are documented in the [Upstash HTTP API docs](https://upstash.com/docs/redis/features/restapi).\n\n```js\nconst storedge = require('storedge');\n\nconst [error, store] = storedge.with({ envFile: '.env' }).build();\nif (error) return console.error(error);\n\nconst myPrimitive = 101;\nconst result = await store.KV.set('key001', myPrimitive);\nif (result !== 'OK') return console.error('Failed to store myPrimitive');\nconst restored = await store.KV.get('key001');\n```\n\n### Contributing\n\nPlease see [CONTRIBUTING](./CONTRIBUTING.md) and [CODE_OF_CONDUCT](./CODE_OF_CONDUCT.md).\n\n1. Fork this repo and clone to your workstation\n2. Run `npm i`\n3. Run `npm run prepare` to setup husky git hooks\n4. Run `npm run check` to run linter and tests\n5. Commit your changes, push to your fork and open a PR\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustworthy%2Fstoredge","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frustworthy%2Fstoredge","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frustworthy%2Fstoredge/lists"}