Skip to content

Commit

Permalink
PR Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
mvpoyatt authored and mvpoyatt committed Nov 1, 2024
1 parent a71bb30 commit 3f63e0c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/api/packets/request-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,8 @@ export async function searchChannels(
src?: string,
dest?: string
): Promise<PacketRes> {
let packetRes: PacketRes = { type: 'channel' };

const channelFilter = `srcChannelId_eq: ${searchValue}`;
const filterProps: FiltersProps = { start, end, states, src, dest };
const filters = generateSendPacketFilters(filterProps);
Expand All @@ -69,7 +71,6 @@ export async function searchChannels(
offset
});

let packetRes: PacketRes = { type: 'channel' };
try {
const packets = await processRequest(generateSendPacketQuery(queryParams));
if (packets.length) {
Expand Down
6 changes: 6 additions & 0 deletions app/api/packets/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ export async function GET(request: NextRequest) {

// Search packets by channel id
if (searchValue.slice(1, 8) === 'channel') {
// Validate channel ID format
searchValue = searchValue.trim();
if (!/^["']?channel-\d+["']?$/.test(searchValue)) {
return NextResponse.json({ error: 'Invalid channel ID format' }, { status: 400 });
}

let packetRes: PacketRes = await searchChannels(searchValue, start, end, limit, offset, states, src, dest);
if (packetRes.error) {
return NextResponse.json({ error: 'Internal Server Error' }, { status: 500 });
Expand Down

0 comments on commit 3f63e0c

Please sign in to comment.