Skip to content
This repository has been archived by the owner on Oct 18, 2021. It is now read-only.
/ tegel Public archive

A simple feature toggle service for Node.js

Notifications You must be signed in to change notification settings

frontsideair/tegel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tegel

tegel is a simple feature toggle service for Node.js. It's local to the project and comes with a simple UI.

Usage

You need to initialize tegel with a list of existing toggles and a store that has an async Map interface, like Keyv.

const express = require("express");
const Keyv = require("keyv");
const { Tegel, middleware } = require("tegel");
const router = require("tegel-router");

const toggles = [
  {
    name: "universal",
    description: "Do we address the world, or the whole universe?",
    defaultValue: true
  },
  {
    name: "lasers",
    description: "Enable lasers!!!",
    defaultValue: true
  }
];
const storage = new Keyv();
const tegel = new Tegel({ toggles, storage });

const app = express();

app.use(middleware(tegel));

app.get("/", (req, res) => {
  const universal = req.tegel.get("universal");
  res.send(universal ? "Hello, universe!" : "Hello, world!");
});

app.use("/tegel", router(tegel));

app.listen(3000, () => console.log("Example app listening on port 3000!"));