Skip to content

Commit

Permalink
♻️ remove duplicate onConnected route
Browse files Browse the repository at this point in the history
  • Loading branch information
vogelskamp committed Oct 18, 2023
1 parent a4c9d1c commit e8d4ef1
Show file tree
Hide file tree
Showing 3 changed files with 0 additions and 39 deletions.
5 changes: 0 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { TokenCacheStorage } from './cache';
import { errorHandlerMiddleware, extractHeaderMiddleware } from './middlewares';
import {
Adapter,
BridgeRequest,
BridgeRequestWithTimestamp,
ContactCache,
Controller,
Expand Down Expand Up @@ -138,10 +137,6 @@ export function start(
controller.handleWebhook(req, res, next),
);

app.post('/on-connected', (req: BridgeRequest<unknown>, res, next) =>
controller.handleConnectedEvent(req, res, next),
);

app.use(errorHandlerMiddleware);

customRouters.forEach(({ path, router }) => app.use(path, router));
Expand Down
1 change: 0 additions & 1 deletion src/models/adapter.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ export interface Adapter {
req: Request,
res?: Response,
) => Promise<{ apiKey: string; apiUrl: string }>;
onConnected?: (config: Config) => Promise<void>;
handleWebhook?: (req: Request) => Promise<IntegrationsEvent[]>;
verifyWebhookRequest?: (req: Request) => Promise<boolean>;
}
33 changes: 0 additions & 33 deletions src/models/controller.model.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1462,37 +1462,4 @@ export class Controller {
next(error);
}
}

public async onConnected(
req: BridgeRequest<unknown>,
res: Response,
next: NextFunction,
) {
const { providerConfig } = req;

try {
if (!providerConfig) {
throw new ServerError(400, 'Missing parameters');
}

if (!this.adapter.onConnected) {
infoLogger(
'onConnected',
'No onConnected handler defined',
providerConfig.apiKey,
);
return;
}

await this.adapter.onConnected(providerConfig);
} catch (error) {
errorLogger(
'onConnected',
'Could not handle onConnected event',
'',
error || 'Unknown',
);
next(error);
}
}
}

0 comments on commit e8d4ef1

Please sign in to comment.