summaryrefslogtreecommitdiff
path: root/api/_getFirstQueryParam.ts
blob: 2073e7a6db68c6fc19493447f7e26332db26619b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
import type { VercelRequest } from '@vercel/node';

export function getFirstQueryParam(key: string, query: VercelRequest['query']): string | null {
  const value = query[key];
  if (!value) {
    return null;
  }
  if (typeof(value) === 'string') {
    return value;
  }
  return value[0] as string;
}