({ publicApiKey, apiUrl, children }: TriggerProviderProps)
| 32 | }; |
| 33 | |
| 34 | export function TriggerProvider({ publicApiKey, apiUrl, children }: TriggerProviderProps) { |
| 35 | const [queryClient] = useState(() => new QueryClient()); |
| 36 | |
| 37 | if (!publicApiKey) { |
| 38 | throw new Error("TriggerProvider requires `publicApiKey` to be set with a value."); |
| 39 | } |
| 40 | |
| 41 | verifyApiKey(publicApiKey); |
| 42 | |
| 43 | return ( |
| 44 | <ProviderContext.Provider |
| 45 | value={{ |
| 46 | publicApiKey, |
| 47 | apiUrl: apiUrl ?? "https://api.trigger.dev", |
| 48 | queryClient, |
| 49 | }} |
| 50 | > |
| 51 | {children} |
| 52 | </ProviderContext.Provider> |
| 53 | ); |
| 54 | } |
| 55 | |
| 56 | function verifyApiKey(apiKey: string) { |
| 57 | if (apiKey.startsWith(privateApiKeyStartsWith)) { |
nothing calls this directly
no test coverage detected
searching dependent graphs…