Skip to content

Commit

Permalink
task: removes deprecated feature api (#3609)
Browse files Browse the repository at this point in the history
### What
We've had this marked as deprecated through our v4, this PR removes it.

### Worth noting
This updates the deprecation notices with removal notices in the
documentation as well.

### Considerations
The tags API is still located under
/api/admin/features/{featureName}/tags. It should be moved to
/api/admin/projects/{project}/features/{featureName}/tags. I vote we do
that in a separate PR, we'd probably also need to deprecate the existing
tags endpoints for v5 and remove in v6. We could use 308s to signify
that they are moved.

---------

Co-authored-by: Thomas Heartman <thomas@getunleash.ai>
  • Loading branch information
Christopher Kolstad and thomasheartman committed Apr 26, 2023
1 parent 7eda493 commit 1fdf68e
Show file tree
Hide file tree
Showing 15 changed files with 48 additions and 993 deletions.
1 change: 0 additions & 1 deletion src/lib/__snapshots__/create-config.test.ts.snap
Expand Up @@ -44,7 +44,6 @@ exports[`should create default config 1`] = `
"user": "unleash",
"version": undefined,
},
"disableLegacyFeaturesApi": false,
"email": {
"host": undefined,
"port": 587,
Expand Down
5 changes: 0 additions & 5 deletions src/lib/create-config.ts
Expand Up @@ -438,10 +438,6 @@ export function createConfig(options: IUnleashOptions): IUnleashConfig {
const enableOAS =
options.enableOAS || parseEnvVarBoolean(process.env.ENABLE_OAS, false);

const disableLegacyFeaturesApi =
options.disableLegacyFeaturesApi ||
parseEnvVarBoolean(process.env.DISABLE_LEGACY_FEATURES_API, false);

const additionalCspAllowedDomains: ICspDomainConfig =
parseCspConfig(options.additionalCspAllowedDomains) ||
parseCspEnvironmentVariables();
Expand Down Expand Up @@ -484,7 +480,6 @@ export function createConfig(options: IUnleashOptions): IUnleashConfig {
email,
secureHeaders,
enableOAS,
disableLegacyFeaturesApi,
preHook: options.preHook,
preRouterHook: options.preRouterHook,
enterpriseVersion: options.enterpriseVersion,
Expand Down
Expand Up @@ -559,7 +559,9 @@ const defaultImportPayload: ImportTogglesSchema = {
};

const getFeature = async (feature: string) =>
app.request.get(`/api/admin/features/${feature}`).expect(200);
app.request
.get(`/api/admin/projects/${DEFAULT_PROJECT}/features/${feature}`)
.expect(200);

const getFeatureEnvironment = (feature: string) =>
app.request
Expand Down
24 changes: 1 addition & 23 deletions src/lib/routes/admin-api/feature.ts
Expand Up @@ -2,12 +2,7 @@
import { Request, Response } from 'express';
import Controller from '../controller';
import { extractUsername } from '../../util/extract-user';
import {
CREATE_FEATURE,
DELETE_FEATURE,
NONE,
UPDATE_FEATURE,
} from '../../types/permissions';
import { NONE, UPDATE_FEATURE } from '../../types/permissions';
import { IUnleashConfig } from '../../types/option';
import { IUnleashServices } from '../../types';
import FeatureToggleService from '../../services/feature-toggle-service';
Expand Down Expand Up @@ -60,23 +55,6 @@ class FeatureController extends Controller {
this.openApiService = openApiService;
this.service = featureToggleServiceV2;

if (!config.disableLegacyFeaturesApi) {
this.post('/', this.createToggle, CREATE_FEATURE);
this.get('/:featureName', this.getToggle);
this.put('/:featureName', this.updateToggle, UPDATE_FEATURE);
this.delete('/:featureName', this.archiveToggle, DELETE_FEATURE);
this.post('/:featureName/toggle', this.toggle, UPDATE_FEATURE);
this.post('/:featureName/toggle/on', this.toggleOn, UPDATE_FEATURE);
this.post(
'/:featureName/toggle/off',
this.toggleOff,
UPDATE_FEATURE,
);

this.post('/:featureName/stale/on', this.staleOn, UPDATE_FEATURE);
this.post('/:featureName/stale/off', this.staleOff, UPDATE_FEATURE);
}

this.route({
method: 'get',
path: '',
Expand Down
2 changes: 0 additions & 2 deletions src/lib/types/option.ts
Expand Up @@ -111,7 +111,6 @@ export interface IUnleashOptions {
preHook?: Function;
preRouterHook?: Function;
enterpriseVersion?: string;
disableLegacyFeaturesApi?: boolean;
inlineSegmentConstraints?: boolean;
clientFeatureCaching?: Partial<IClientCachingOption>;
flagResolver?: IFlagResolver;
Expand Down Expand Up @@ -196,7 +195,6 @@ export interface IUnleashConfig {
preRouterHook?: Function;
enterpriseVersion?: string;
eventBus: EventEmitter;
disableLegacyFeaturesApi?: boolean;
environmentEnableOverrides?: string[];
frontendApi: IFrontendApi;
inlineSegmentConstraints: boolean;
Expand Down
12 changes: 6 additions & 6 deletions src/test/e2e/api/admin/feature-archive.e2e.test.ts
Expand Up @@ -108,7 +108,7 @@ test('must set name when reviving toggle', async () => {
test('should be allowed to reuse deleted toggle name', async () => {
expect.assertions(2);
await app.request
.post('/api/admin/features')
.post('/api/admin/projects/default/features')
.send({
name: 'really.delete.feature',
enabled: false,
Expand All @@ -121,8 +121,8 @@ test('should be allowed to reuse deleted toggle name', async () => {
expect(res.body.createdAt).toBeTruthy();
});
await app.request
.delete('/api/admin/features/really.delete.feature')
.expect(200);
.delete('/api/admin/projects/default/features/really.delete.feature')
.expect(202);
await app.request
.delete('/api/admin/archive/really.delete.feature')
.expect(200);
Expand All @@ -135,7 +135,7 @@ test('should be allowed to reuse deleted toggle name', async () => {
test('Deleting an unarchived toggle should not take effect', async () => {
expect.assertions(2);
await app.request
.post('/api/admin/features')
.post('/api/admin/projects/default/features')
.send({
name: 'really.delete.feature',
enabled: false,
Expand All @@ -161,7 +161,7 @@ test('can bulk delete features and recreate after', async () => {
const features = ['first.bulk.issue', 'second.bulk.issue'];
for (const feature of features) {
await app.request
.post('/api/admin/features')
.post('/api/admin/projects/default/features')
.send({
name: feature,
enabled: false,
Expand Down Expand Up @@ -193,7 +193,7 @@ test('can bulk revive features', async () => {
const features = ['first.revive.issue', 'second.revive.issue'];
for (const feature of features) {
await app.request
.post('/api/admin/features')
.post('/api/admin/projects/default/features')
.send({
name: feature,
enabled: false,
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/api/admin/feature.auth.e2e.test.ts
Expand Up @@ -24,7 +24,7 @@ test('creates new feature toggle with createdBy', async () => {

// create toggle
await request
.post('/api/admin/features')
.post('/api/admin/projects/default/features')
.send({
name: 'com.test.Username',
enabled: false,
Expand Down
2 changes: 1 addition & 1 deletion src/test/e2e/api/admin/feature.custom-auth.e2e.test.ts
Expand Up @@ -53,7 +53,7 @@ test('creates new feature toggle with createdBy', async () => {

// create toggle
await request
.post('/api/admin/features')
.post('/api/admin/projects/default/features')
.send({
name: 'com.test.Username',
enabled: false,
Expand Down

0 comments on commit 1fdf68e

Please sign in to comment.