{"_id":"@arvind_054/flagship-sdk","_rev":"2-0aad782b00cf1c82b711dec39b5d24eb","name":"@arvind_054/flagship-sdk","dist-tags":{"latest":"1.0.1"},"versions":{"1.0.0":{"name":"@arvind_054/flagship-sdk","version":"1.0.0","keywords":["feature-flags","sdk","backend"],"author":{"name":"Arvind Choudhary"},"license":"N/A","_id":"@arvind_054/flagship-sdk@1.0.0","maintainers":[{"name":"arvind_choudhary_054","email":"arvindchoudhary054@gmail.com"}],"dist":{"shasum":"e1cbe27279165c348ca8c87169093c90e864c836","tarball":"https://registry.npmjs.org/@arvind_054/flagship-sdk/-/flagship-sdk-1.0.0.tgz","fileCount":5,"integrity":"sha512-/EXDRro8xqTk2jSg8+cJsZ3CqDHdTqX9jehd2Nm4K1/sephblzrOgWrSQeVAg3HNucT52IDrad+LUG3vjY9HNA==","signatures":[{"sig":"MEUCIQCMW03zcgIX35ov+Fn1j94R2Z8DgNo+sHBnVaxFhlY2CAIgUkFqa0jJtv85Kh3b6xLXqu858uuSbvBKEaQgXEWMzus=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":3401},"main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc"},"_npmUser":{"name":"arvind_choudhary_054","email":"arvindchoudhary054@gmail.com"},"_npmVersion":"10.9.3","description":"Feature flag SDK with TTL caching","directories":{},"_nodeVersion":"22.20.0","_hasShrinkwrap":false,"_npmOperationalInternal":{"tmp":"tmp/flagship-sdk_1.0.0_1772039753772_0.24371438504182819","host":"s3://npm-registry-packages-npm-production"}},"1.0.1":{"name":"@arvind_054/flagship-sdk","version":"1.0.1","description":"Feature flag SDK with TTL caching","main":"dist/index.js","types":"dist/index.d.ts","scripts":{"build":"tsc"},"keywords":["feature-flags","sdk","backend"],"author":{"name":"Arvind Choudhary"},"license":"N/A","_id":"@arvind_054/flagship-sdk@1.0.1","_nodeVersion":"22.20.0","_npmVersion":"10.9.3","dist":{"integrity":"sha512-N3rZAJqj5Rz5QqCA5DoEOKlfQcXcs4fiSSS3aMjIBbz3gBGymwivaxhOlpPQn7MhlRph+yeHku9zcTVjc59ANQ==","shasum":"42f1fd0032f8b17d5ac9a5fd9314132453c28af5","tarball":"https://registry.npmjs.org/@arvind_054/flagship-sdk/-/flagship-sdk-1.0.1.tgz","fileCount":6,"unpackedSize":5587,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQDl1RI+bKsw+nVrXKPk1K4DoT0ibKmgvuTc+P5eafuLbQIhAKHN6X5Ke9aLt4Vs5Jl1FBp4gQ6SNLbVkolRtxN+fbz5"}]},"_npmUser":{"name":"arvind_choudhary_054","email":"arvindchoudhary054@gmail.com"},"directories":{},"maintainers":[{"name":"arvind_choudhary_054","email":"arvindchoudhary054@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/flagship-sdk_1.0.1_1772039854859_0.9045032975899989"},"_hasShrinkwrap":false}},"time":{"created":"2026-02-25T17:15:53.660Z","modified":"2026-02-25T17:17:35.129Z","1.0.0":"2026-02-25T17:15:53.981Z","1.0.1":"2026-02-25T17:17:35.013Z"},"author":{"name":"Arvind Choudhary"},"license":"N/A","keywords":["feature-flags","sdk","backend"],"description":"Feature flag SDK with TTL caching","maintainers":[{"name":"arvind_choudhary_054","email":"arvindchoudhary054@gmail.com"}],"readme":"# npm version patch\r\nnpm publish --access publicflagship-sdk\r\n\r\nA lightweight feature flag SDK for Node.js with built-in TTL caching.\r\n\r\n## Installation\r\n\r\n```bash\r\nnpm install @arvind_054/flagship-sdk\r\n```\r\n\r\n## Usage\r\n\r\n```typescript\r\nimport { Flagship } from \"@arvind_054/flagship-sdk\";\r\n\r\nconst flagship = new Flagship({\r\n  apiKey: \"your-api-key\",\r\n  environment: \"production\",\r\n  baseUrl: \"https://your-flagship-server.com\", // optional, defaults to http://localhost:3000\r\n  ttl: 30000, // optional, cache TTL in ms (default: 30000)\r\n});\r\n\r\nconst user = {\r\n  id: \"user-123\",\r\n  email: \"user@example.com\",\r\n  plan: \"premium\",\r\n};\r\n\r\nconst isFeatureEnabled = await flagship.isEnabled(\"new-checkout-flow\", user);\r\n\r\nif (isFeatureEnabled) {\r\n  // Show new feature\r\n} else {\r\n  // Show default experience\r\n}\r\n```\r\n\r\n## API\r\n\r\n### `new Flagship(config)`\r\n\r\nCreates a new Flagship client.\r\n\r\n| Option | Type | Required | Default | Description |\r\n|--------|------|----------|---------|-------------|\r\n| `apiKey` | `string` | Yes | - | Your Flagship API key |\r\n| `environment` | `string` | Yes | - | Environment name (e.g., \"production\", \"staging\") |\r\n| `baseUrl` | `string` | No | `http://localhost:3000` | Flagship server URL |\r\n| `ttl` | `number` | No | `30000` | Cache TTL in milliseconds |\r\n\r\n### `flagship.isEnabled(featureKey, user)`\r\n\r\nEvaluates whether a feature flag is enabled for a given user.\r\n\r\n| Parameter | Type | Description |\r\n|-----------|------|-------------|\r\n| `featureKey` | `string` | The feature flag key |\r\n| `user` | `object` | User object with `id` (required) and any additional attributes |\r\n\r\n**Returns:** `Promise<boolean>` - `true` if enabled, `false` otherwise (including on errors)\r\n\r\n## Caching\r\n\r\nResults are cached per user and feature key combination. Cached values expire after the configured TTL (default 30 seconds). On cache miss or expiration, a fresh evaluation is fetched from the server.\r\n\r\n## Error Handling\r\n\r\nThe SDK gracefully handles errors by returning `false` and logging the error to the console. This ensures your application continues to work even if the Flagship server is unavailable.\r\n\r\n## License\r\n\r\nN/A\r\n","readmeFilename":"README.md"}