Skip to content

Commit bf74706

Browse files
committed
🐛 validate input before forwarding to adapter
1 parent 9552be6 commit bf74706

File tree

9 files changed

+570
-1189
lines changed

9 files changed

+570
-1189
lines changed

package-lock.json

Lines changed: 24 additions & 54 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
"@opentelemetry/sdk-node": "^0.45.1",
7979
"@opentelemetry/sdk-trace-base": "^1.18.1",
8080
"@slack/webhook": "^6.1.0",
81-
"ajv": "^8.11.0",
8281
"awesome-phonenumber": "^3.2.0",
8382
"axios": "^1.0.0",
8483
"body-parser": "^1.20.0",
@@ -91,6 +90,7 @@
9190
"lru-cache": "^7.13.1",
9291
"moment": "^2.29.4",
9392
"rate-limiter-flexible": "^2.3.11",
94-
"redis": "^4.2.0"
93+
"redis": "^4.2.0",
94+
"zod": "^3.23.8"
9595
}
9696
}

src/index.ts

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import { TaskController } from './controllers/task.controller';
1818
import { errorHandlerMiddleware, extractHeaderMiddleware } from './middlewares';
1919
import {
2020
Adapter,
21-
BridgeRequestWithTimestamp,
2221
ContactCache,
2322
Controller,
2423
IntegrationEntityBridgeRequest,
@@ -82,32 +81,12 @@ export function start(
8281
controller.streamContacts(req, res, next),
8382
);
8483

85-
app.get('/contacts-delta', (req: BridgeRequestWithTimestamp, res, next) =>
86-
controller.getContactsDelta(req, res, next),
87-
);
88-
8984
app.get(
9085
'/entity/:type/:id',
9186
(req: IntegrationEntityBridgeRequest, res, next) =>
9287
controller.getEntity(req, res, next),
9388
);
9489

95-
app.get('/calendar', (req, res, next) =>
96-
controller.getCalendarEvents(req, res, next),
97-
);
98-
99-
app.post('/calendar', (req, res, next) =>
100-
controller.createCalendarEvent(req, res, next),
101-
);
102-
103-
app.put('/calendar/:id', (req, res, next) =>
104-
controller.updateCalendarEvent(req, res, next),
105-
);
106-
107-
app.delete('/calendar/:id', (req, res, next) =>
108-
controller.deleteCalendarEvent(req, res, next),
109-
);
110-
11190
app.post('/events/calls', (req, res, next) =>
11291
controller.handleCallEvent(req, res, next),
11392
);

src/models/adapter.model.ts

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import { Request, Response } from 'express';
22
import {
3-
CalendarEvent,
4-
CalendarEventTemplate,
5-
CalendarFilterOptions,
63
CallEvent,
74
CallEventWithIntegrationEntities,
85
Config,
96
Contact,
10-
ContactDelta,
117
ContactTemplate,
128
ContactUpdate,
139
FollowUpWithIntegrationEntities,
@@ -29,10 +25,6 @@ export interface Adapter {
2925
type: IntegrationEntityType,
3026
) => Promise<Contact>;
3127
getContacts?: (config: Config) => Promise<Contact[]>;
32-
getContactsDelta?: (
33-
config: Config,
34-
timestamp: number,
35-
) => Promise<ContactDelta>;
3628
streamContacts?: (config: Config) => AsyncGenerator<Contact[], void, unknown>;
3729
createContact?: (
3830
config: Config,
@@ -44,21 +36,6 @@ export interface Adapter {
4436
contact: ContactUpdate,
4537
) => Promise<Contact>;
4638
deleteContact?: (config: Config, id: string) => Promise<void>;
47-
getCalendarEvents?: (
48-
config: Config,
49-
options?: CalendarFilterOptions | null,
50-
) => Promise<CalendarEvent[]>;
51-
createCalendarEvent?: (
52-
config: Config,
53-
event: CalendarEventTemplate,
54-
) => Promise<CalendarEvent>;
55-
updateCalendarEvent?: (
56-
config: Config,
57-
id: string,
58-
event: CalendarEventTemplate,
59-
) => Promise<CalendarEvent>;
60-
61-
deleteCalendarEvent?: (config: Config, id: string) => Promise<void>;
6239
/**
6340
* @deprecated handleCallEvent should be replaced by createOrUpdateCallLogForEntities
6441
*/

src/models/contact.model.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,3 @@ export type ContactUpdate = ContactTemplate & {
5656
};
5757

5858
export type Contact = ContactTemplate & ContactResult;
59-
60-
export type ContactDelta = {
61-
contacts: Contact[];
62-
deleted: string[];
63-
};

0 commit comments

Comments
 (0)