Skip to content

Commit

Permalink
fix(api): Added query argument includeDisabled to /zones API endpoi…
Browse files Browse the repository at this point in the history
…nt. If `true` returns all zones
  • Loading branch information
andris9 committed Mar 27, 2024
1 parent a4d2258 commit fb826d6
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/api-server.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,9 +277,12 @@ class APIServer {
});
});

// `/zones` – list enabled zones
// `/zones?includeDisabled=true` – list all zones, including disabled zones
this.server.get('/zones', (req, res, next) => {
let includeDisabledZones = /^(true|yes|1)/i.test(req.query.includeDisabled);
let zones = Object.keys(config.zones)
.filter(zone => config.zones[zone] && !config.zones[zone].disabled)
.filter(zone => config.zones[zone] && (includeDisabledZones || !config.zones[zone].disabled))
.map(zone => ({
name: zone
}))
Expand Down

0 comments on commit fb826d6

Please sign in to comment.