🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

rlse

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rlse - npm Package Compare versions

Comparing version
0.1.4
to
0.2.0
+8
-1
dist/index.d.ts

@@ -9,3 +9,10 @@ // Generated by dts-bundle-generator v9.5.1

}
export declare function initConfig(config: string): void;
/**
* Parses a TOML string into a Config object.
* @param {string} config The TOML configuration string.
* @returns {Config} The parsed configuration object.
*/
export declare function parseConfig(config: string): Config;
/**
* The properties for the `isFeatureEnabled` function.

@@ -25,4 +32,4 @@ * @property {string} feature - The feature to check.

*/
export declare function isFeatureEnabled(options: IsFeatureEnabledProps): boolean;
export declare function isFeatureEnabled(options: IsFeatureEnabledProps): Promise<boolean>;
export {};
+1
-1
{
"name": "rlse",
"version": "0.1.4",
"version": "0.2.0",
"description": "Code first feature flags",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/dlredden/rlse",

@@ -73,2 +73,36 @@ # rlse

**Next.js Example**
Next.js has some special ways of working. There's a little hackery required to get rlse working since it tends to loath node.js modules. (I'm sure there's better ways that someone smarter than me could do. I'm open to learning new things.)
Put this in a server action or API route that can be reused throughout your app.
```typescript
import { promises as fs } from "fs";
import { isFeatureEnabled, parseConfig, type Config } from "rlse";
let rlseConfig: Config;
export async function isEnabled(feature: string): Promise<boolean> {
if (!rlseConfig) {
rlseConfig = parseConfig(await fs.readFile("rlse.toml", "utf-8"));
}
return await isFeatureEnabled({
feature,
env: process.env.VERCEL_ENV,
config: rlseConfig,
});
}
```
Then you can call it like so from pages
```typescript
import { isEnabled } from "./actions";
export default async function Page() {
const featureEnabled = await isEnabled("myCustomFeature");
...
}
```
🛑 Important:

@@ -75,0 +109,0 @@

Sorry, the diff of this file is too big to display