Skip to content

Commit

Permalink
fix(database): custom endpoint handler was not assigned properly
Browse files Browse the repository at this point in the history
  • Loading branch information
sdimitris committed Mar 29, 2022
1 parent d4232ef commit 4622540
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,13 @@ import { MongooseSchema } from '../../adapters/mongoose-adapter/MongooseSchema';
import { SequelizeSchema } from '../../adapters/sequelize-adapter/SequelizeSchema';

export class CustomEndpointController {

private handler: CustomEndpointHandler
constructor(
private readonly grpcSdk: ConduitGrpcSdk,
private readonly database: DatabaseAdapter<MongooseSchema | SequelizeSchema>,
private router: DatabaseRoutes,
) {
this.handler = new CustomEndpointHandler(this.grpcSdk);
this.refreshRoutes()
.catch((err: any) => {
console.log(err);
Expand All @@ -36,7 +37,8 @@ export class CustomEndpointController {
}
let routes: any[] = [];
r.forEach((schema: ICustomEndpoint) => {
routes.push(createCustomEndpointRoute(schema));

routes.push(createCustomEndpointRoute(schema,this.handler.entryPoint.bind(this.handler)));
CustomEndpointHandler.addNewCustomOperationControl(schema);
});

Expand Down
5 changes: 3 additions & 2 deletions modules/database/src/controllers/customEndpoints/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,11 @@ function extractParams(
return resultingObject;
}

export function createCustomEndpointRoute(endpoint: ICustomEndpoint) {
export function createCustomEndpointRoute(endpoint: ICustomEndpoint,handler:any ) {
let route = new RouteBuilder()
.path(`/function/${endpoint.name}`)
.method(getOperation(endpoint.operation));
.method(getOperation(endpoint.operation))
.handler(handler);
if (endpoint.authentication) {
route.middleware('authMiddleware');
}
Expand Down
1 change: 0 additions & 1 deletion modules/database/src/routes/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export class DatabaseRoutes {

constructor(readonly server: GrpcServer, private readonly database: DatabaseAdapter<MongooseSchema | SequelizeSchema>, private readonly grpcSdk: ConduitGrpcSdk) {
this.handlers = new CmsHandlers(grpcSdk, database);
this.customEndpointHandler = new CustomEndpointHandler(grpcSdk);
this._routingManager = new RoutingManager(this.grpcSdk.router, server);
}

Expand Down

0 comments on commit 4622540

Please sign in to comment.