Skip to content

Commit

Permalink
Merge pull request #179 from Infisical/new-routing
Browse files Browse the repository at this point in the history
Migrated `POST /v1/secret/:workspaceId` to `POST /v2/workspace/:workspaceId/secrets`
  • Loading branch information
dangtony98 authored Dec 27, 2022
2 parents f3e3a9e + f93594b commit f550e4b
Show file tree
Hide file tree
Showing 12 changed files with 1,056 additions and 98 deletions.
12 changes: 10 additions & 2 deletions backend/src/app.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {
workspace as eeWorkspaceRouter,
secret as eeSecretRouter
} from './ee/routes/v1';

import {
signup as v1SignupRouter,
auth as v1AuthRouter,
Expand All @@ -35,6 +34,10 @@ import {
integration as v1IntegrationRouter,
integrationAuth as v1IntegrationAuthRouter
} from './routes/v1';
import {
secret as v2SecretRouter,
workspace as v2WorkspaceRouter
} from './routes/v2';

import { getLogger } from './utils/logger';
import { RouteNotFoundError } from './utils/errors';
Expand Down Expand Up @@ -63,7 +66,7 @@ if (NODE_ENV === 'production') {
app.use(helmet());
}

// (EE) routers
// (EE) routes
app.use('/api/v1/secret', eeSecretRouter);
app.use('/api/v1/workspace', eeWorkspaceRouter);

Expand All @@ -86,6 +89,11 @@ app.use('/api/v1/stripe', v1StripeRouter);
app.use('/api/v1/integration', v1IntegrationRouter);
app.use('/api/v1/integration-auth', v1IntegrationAuthRouter);

// v2 routes
app.use('/api/v2/workspace', v2WorkspaceRouter);
app.use('/api/v2/secret', v2SecretRouter);


//* Handle unrouted requests and respond with proper error message as well as status code
app.use((req, res, next)=>{
if(res.headersSent) return next();
Expand Down
2 changes: 1 addition & 1 deletion backend/src/controllers/v1/secretController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Request, Response } from 'express';
import * as Sentry from '@sentry/node';
import { Key, Secret } from '../../models';
import {
pushSecrets as push,
v1PushSecrets as push,
pullSecrets as pull,
reformatPullSecrets
} from '../../helpers/secret';
Expand Down
5 changes: 5 additions & 0 deletions backend/src/controllers/v2/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import * as workspaceController from './workspaceController';

export {
workspaceController
}
Empty file.
Loading

1 comment on commit f550e4b

@github-actions
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage report for backend

St.
Category Percentage Covered / Total
🟡 Statements 70.15% 47/67
🔴 Branches 0% 0/5
🔴 Functions 50% 1/2
🟡 Lines 71.21% 47/66

Test suite run success

1 tests passing in 1 suite.

Report generated by 🧪jest coverage report action from f550e4b

Please sign in to comment.