@@ -17,15 +17,15 @@ export async function getFeaturesPublic(req: Request, res: Response) {
1717 const { key } = req . params ;
1818
1919 try {
20- const organization = await lookupOrganizationByApiKey ( key ) ;
20+ const { organization, environment } = await lookupOrganizationByApiKey ( key ) ;
2121 if ( ! organization ) {
2222 return res . status ( 400 ) . json ( {
2323 status : 400 ,
2424 error : "Invalid API key" ,
2525 } ) ;
2626 }
2727
28- const features = await getFeatureDefinitions ( organization ) ;
28+ const features = await getFeatureDefinitions ( organization , environment ) ;
2929
3030 // Cache for 30 seconds, serve stale up to 1 hour (10 hours if origin is down)
3131 res . set (
@@ -69,6 +69,7 @@ export async function postFeatures(
6969 description : "" ,
7070 project : "" ,
7171 rules : [ ] ,
72+ environments : [ "dev" ] ,
7273 ...otherProps ,
7374 dateCreated : new Date ( ) ,
7475 dateUpdated : new Date ( ) ,
@@ -135,7 +136,8 @@ export async function putFeature(
135136 updates . defaultValue !== feature . defaultValue
136137 ) {
137138 requiresWebhook = true ;
138- } else if ( "rules" in updates ) {
139+ }
140+ if ( "rules" in updates ) {
139141 if ( updates . rules ?. length !== feature . rules ?. length ) {
140142 requiresWebhook = true ;
141143 } else {
@@ -153,6 +155,11 @@ export async function putFeature(
153155 } ) ;
154156 }
155157 }
158+ if ( "environments" in updates ) {
159+ if ( updates . environments ?. length !== feature . environments ?. length ) {
160+ requiresWebhook = true ;
161+ }
162+ }
156163
157164 await updateFeature ( feature . organization , id , {
158165 ...updates ,
0 commit comments