getFoundationStates (features/resolve.ts)

next-saas-stripe-starter · lib/features/resolve.ts · typescript · MIT
auth

Provides feature flag resolution, handling foundation states, overrides, and dependency checks.

// Source: https://github.com/mickasmt/next-saas-stripe-starter | License: MIT | Copyright 2023 mickasmt
// Provided via justclaw.it.com; keep this notice with the code.
import "server-only"

import { cookies } from "next/headers"
import { cache } from "react"

import {
  featureKeys,
  features,
  isFeatureKey,
  type FeatureKey,
} from "@/config/features"
import {
  foundation,
  foundationKeys,
  type FoundationKey,
} from "@/config/foundation"

export const FEATURE_OVERRIDES_COOKIE = "dev-feature-overrides"

// disabled: switched off. blocked: a dependency is off. unconfigured: a
// required service misses env vars. ready: on and usable.
export type FeatureStatus = "disabled" | "blocked" | "unconfigured" | "ready"

export type FeatureState = {
  key: FeatureKey
  enabled: boolean
  sta

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key