express-feature-flags
A tool for constructing complex feature-flags with Express
Example
// app/features-schema.jsconst administrator = type: 'contains' key: 'user.role' comparison: 'admin' 'root' 'sysadmin' const features = 'administrator': administrator 'regular-user': Object 'hidden-page': type: 'eq' key: 'user.authenticated' comparison: true type: 'contains' key: 'locales' { return userlocale; } type: 'gt' key: 'timestamp' comparison: 1449297410423 ; ;
// app/server.js;;; const app = ;const feature = featureFlags; // optional: add a custom predicate// supported of the box: eq, neq, contains, gt, gte, lt, ltefeaturebuilder; applocalslocales = 'en-US' 'en-CA'; app; /** * Responsible for constructing the enabled feature list on per-request basis. * Ordering the middleware after your request context is finish being * built BUT BEFORE any logic that checks if a feature is enabled * is very important! */app; // example of a utility function used to guard routes/middleware { return { if res return middlewareFunc; ; }} app; app; app;
Templating Engine Integration
Handlebars
Template Helper
Handlebars;
Exposing Feature Flags
Handlebars;
windowFEATURES = json @rootenabled