| 179 | const ALLOWED_RUNTIMES: string[] = [...Object.values(EdgeRuntimes), 'nodejs']; |
| 180 | |
| 181 | export function validateConfiguredRuntime( |
| 182 | runtime: string | undefined, |
| 183 | entrypoint: string |
| 184 | ) { |
| 185 | if (runtime) { |
| 186 | if (!ALLOWED_RUNTIMES.includes(runtime)) { |
| 187 | throw new Error( |
| 188 | `${entrypoint}: unsupported "runtime" value in \`config\`: ${JSON.stringify( |
| 189 | runtime |
| 190 | )} (must be one of: ${JSON.stringify( |
| 191 | ALLOWED_RUNTIMES |
| 192 | )}). Learn more: https://vercel.link/creating-edge-functions` |
| 193 | ); |
| 194 | } |
| 195 | } |
| 196 | } |
| 197 | |
| 198 | export async function serializeBody( |
| 199 | request: IncomingMessage |