(INTERNAL_API_KEY: string)
| 5 | } |
| 6 | |
| 7 | export function integrationMiddleware(INTERNAL_API_KEY: string) { |
| 8 | return async (req: any, _: any, next: any) => { |
| 9 | try { |
| 10 | const apiKeyRaw = getInternalApiKey(req); |
| 11 | if (!apiKeyRaw) { |
| 12 | return next(new Error('missing api key')); |
| 13 | } |
| 14 | if (INTERNAL_API_KEY !== apiKeyRaw) { |
| 15 | return next(new Error('api key does not match')); |
| 16 | } |
| 17 | return next(); |
| 18 | } catch (error) { |
| 19 | console.error(error); |
| 20 | return next(new Error('internal server error')); |
| 21 | } |
| 22 | }; |
| 23 | } |
nothing calls this directly
no test coverage detected