Skip to content

Commit

Permalink
🛠 set up credentials router (#2882)
Browse files Browse the repository at this point in the history
* ⚡ Refactor creds endpoints into router

* 🧪 Refactor creds tests to use router

* 🚚 Rename arg for consistency

* 🚚 Move `credentials.api.ts` outside /public

* 🚚 Rename constant for consistency

* 📘 Simplify types

* 🔥 Remove unneeded arg

* 🚚 Rename router to controller

* ⚡ Shorten endpoint

* ⚡ Update `initTestServer()` arg

* ⚡ Mutate response body in GET /credentials

* 🏎 improve performance of type cast for FE

Co-authored-by: Ben Hesseldieck <b.hesseldieck@gmail.com>
  • Loading branch information
ivov and BHesseldieck authored Feb 28, 2022
1 parent 2dbf7bb commit 6c8f776
Show file tree
Hide file tree
Showing 13 changed files with 435 additions and 411 deletions.
14 changes: 6 additions & 8 deletions packages/cli/src/Server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,12 @@ import { DEFAULT_EXECUTIONS_GET_ALL_LIMIT, validateEntity } from './GenericHelpe
import { ExecutionEntity } from './databases/entities/ExecutionEntity';
import { SharedWorkflow } from './databases/entities/SharedWorkflow';
import { AUTH_COOKIE_NAME, RESPONSE_ERROR_MESSAGES } from './constants';
import { credentialsEndpoints } from './api/namespaces/credentials';
import { credentialsController } from './api/credentials.api';

require('body-parser-xml')(bodyParser);

export const externalHooks: IExternalHooksClass = ExternalHooks();

class App {
app: express.Application;

Expand Down Expand Up @@ -263,7 +265,7 @@ class App {
this.sslKey = config.get('ssl_key');
this.sslCert = config.get('ssl_cert');

this.externalHooks = ExternalHooks();
this.externalHooks = externalHooks;

this.presetCredentialsLoaded = false;
this.endpointPresetCredentials = config.get('credentials.overwrite.endpoint') as string;
Expand Down Expand Up @@ -659,6 +661,8 @@ class App {
// ----------------------------------------
await userManagementRouter.addRoutes.apply(this, [ignoredEndpoints, this.restEndpoint]);

this.app.use(`/${this.restEndpoint}/credentials`, credentialsController);

// ----------------------------------------
// Healthcheck
// ----------------------------------------
Expand Down Expand Up @@ -1559,12 +1563,6 @@ class App {
}),
);

// ----------------------------------------
// Credentials
// ----------------------------------------

credentialsEndpoints.apply(this);

// ----------------------------------------
// Credential-Types
// ----------------------------------------
Expand Down
Loading

0 comments on commit 6c8f776

Please sign in to comment.