Skip to content

Commit

Permalink
feat: feature flags
Browse files Browse the repository at this point in the history
  • Loading branch information
vladimirvolek committed Dec 5, 2023
1 parent f598da1 commit 8bcf08d
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 5 deletions.
2 changes: 2 additions & 0 deletions config/development.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ server:
listenAddress: "localhost"
port: 3000
debug: true
features:
- CIP-1694
dbSync:
host: "cdbsync-dev.mydomain.com"
port: 5432
Expand Down
15 changes: 10 additions & 5 deletions src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ const esmRequire = createRequire(import.meta.url);
const packageJson = esmRequire('../package.json');

const config = getConfig();
const isCIP1694Active = config.server.features.some(
feature => feature.toLowerCase() === 'CIP-1694'.toLowerCase(),
);

const start = (options = {}): FastifyInstance => {
const app = fastify(options);

Expand Down Expand Up @@ -111,11 +115,12 @@ const start = (options = {}): FastifyInstance => {
registerRoute(app, import('./routes/epochs/number/stakes/index.js'));
registerRoute(app, import('./routes/epochs/number/stakes/pool-id.js'));

// governance
registerRoute(app, import('./routes/governance/dreps/index.js'));
registerRoute(app, import('./routes/governance/dreps/hash/index.js'));
registerRoute(app, import('./routes/governance/dreps/hash/distribution.js'));

if (isCIP1694Active) {
// governance
registerRoute(app, import('./routes/governance/dreps/index.js'));
registerRoute(app, import('./routes/governance/dreps/hash/index.js'));
registerRoute(app, import('./routes/governance/dreps/hash/distribution.js'));
}
// health
registerRoute(app, import('./routes/health/index.js'));
registerRoute(app, import('./routes/health/clock.js'));
Expand Down
2 changes: 2 additions & 0 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const loadConfig = () => {
!config.has('server.prometheusMetrics')
? process.env.BLOCKFROST_CONFIG_SERVER_PROMETHEUS_METRICS === 'true'
: config.get<boolean>('server.prometheusMetrics');
const features = config.get<string[]>('server.features');

// dbSync
const databaseSyncHost =
Expand Down Expand Up @@ -53,6 +54,7 @@ export const loadConfig = () => {
port,
debug,
prometheusMetrics,
features,
},
dbSync: {
host: databaseSyncHost,
Expand Down

0 comments on commit 8bcf08d

Please sign in to comment.