@strav/flag 0.1.0 → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -7
- package/package.json +1 -1
- package/src/commands/flag_commands.ts +1 -1
- package/src/errors.ts +1 -1
- package/src/flag_manager.ts +2 -2
- package/src/flag_provider.ts +2 -2
- package/src/helpers.ts +1 -1
- package/src/middleware/ensure_feature.ts +1 -1
- package/stubs/config/flag.ts +1 -1
package/README.md
CHANGED
|
@@ -1,20 +1,20 @@
|
|
|
1
|
-
# @
|
|
1
|
+
# @strav/flag
|
|
2
2
|
|
|
3
|
-
Feature flags for the [Strav](https://www.npmjs.com/package/@
|
|
3
|
+
Feature flags for the [Strav](https://www.npmjs.com/package/@strav/core) framework. Define, scope, and toggle features with database persistence, in-memory drivers, and per-user/team targeting.
|
|
4
4
|
|
|
5
5
|
## Install
|
|
6
6
|
|
|
7
7
|
```bash
|
|
8
|
-
bun add @
|
|
8
|
+
bun add @strav/flag
|
|
9
9
|
bun strav install flag
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
Requires `@
|
|
12
|
+
Requires `@strav/core` as a peer dependency.
|
|
13
13
|
|
|
14
14
|
## Setup
|
|
15
15
|
|
|
16
16
|
```ts
|
|
17
|
-
import { FlagProvider } from '@
|
|
17
|
+
import { FlagProvider } from '@strav/flag'
|
|
18
18
|
|
|
19
19
|
app.use(new FlagProvider())
|
|
20
20
|
```
|
|
@@ -22,7 +22,7 @@ app.use(new FlagProvider())
|
|
|
22
22
|
## Usage
|
|
23
23
|
|
|
24
24
|
```ts
|
|
25
|
-
import { flag } from '@
|
|
25
|
+
import { flag } from '@strav/flag'
|
|
26
26
|
|
|
27
27
|
// Check if a feature is active
|
|
28
28
|
if (await flag.active('dark-mode')) {
|
|
@@ -41,7 +41,7 @@ const limit = await flag.value('upload-limit', 10)
|
|
|
41
41
|
## Middleware
|
|
42
42
|
|
|
43
43
|
```ts
|
|
44
|
-
import { ensureFeature } from '@
|
|
44
|
+
import { ensureFeature } from '@strav/flag'
|
|
45
45
|
|
|
46
46
|
router.get('/beta', ensureFeature('beta-dashboard'), betaHandler)
|
|
47
47
|
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { Command } from 'commander'
|
|
2
2
|
import chalk from 'chalk'
|
|
3
|
-
import { bootstrap, shutdown } from '@
|
|
3
|
+
import { bootstrap, shutdown } from '@strav/cli'
|
|
4
4
|
import FlagManager from '../flag_manager.ts'
|
|
5
5
|
|
|
6
6
|
export function register(program: Command): void {
|
package/src/errors.ts
CHANGED
package/src/flag_manager.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { inject, Configuration, Emitter, ConfigurationError } from '@
|
|
2
|
-
import { Database } from '@
|
|
1
|
+
import { inject, Configuration, Emitter, ConfigurationError } from '@strav/kernel'
|
|
2
|
+
import { Database } from '@strav/database'
|
|
3
3
|
import type {
|
|
4
4
|
FlagConfig,
|
|
5
5
|
DriverConfig,
|
package/src/flag_provider.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ServiceProvider } from '@
|
|
2
|
-
import type { Application } from '@
|
|
1
|
+
import { ServiceProvider } from '@strav/kernel'
|
|
2
|
+
import type { Application } from '@strav/kernel'
|
|
3
3
|
import FlagManager from './flag_manager.ts'
|
|
4
4
|
|
|
5
5
|
export interface FlagProviderOptions {
|
package/src/helpers.ts
CHANGED
|
@@ -7,7 +7,7 @@ import type { Scopeable, FeatureResolver, FeatureClassConstructor, DriverConfig
|
|
|
7
7
|
* Flag helper — the primary convenience API.
|
|
8
8
|
*
|
|
9
9
|
* @example
|
|
10
|
-
* import { flag } from '@
|
|
10
|
+
* import { flag } from '@strav/flag'
|
|
11
11
|
*
|
|
12
12
|
* flag.define('new-checkout', (scope) => scope.startsWith('User:'))
|
|
13
13
|
*
|
package/stubs/config/flag.ts
CHANGED