Skip to content

Commit

Permalink
fix(web): check if source exists before destructuring (#6465)
Browse files Browse the repository at this point in the history
  • Loading branch information
ainouzgali authored Sep 10, 2024
1 parent b5ff5fa commit b90e531
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions apps/web/src/utils/codeSnippets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,15 @@ export type CodeSnippetProps = {
const SECRET_KEY_ENV_KEY = 'NOVU_SECRET_KEY';

const normalizePayload = (originalPayload: Record<string, unknown>) => {
// Remove internal params
// eslint-disable-next-line @typescript-eslint/naming-convention
const { __source, ...payload } = originalPayload;
if (originalPayload?.__source) {
// Remove internal params
// eslint-disable-next-line @typescript-eslint/naming-convention
const { __source, ...payload } = originalPayload;

return payload;
return payload;
}

return originalPayload;
};
export const createNodeSnippet = ({ identifier, to, payload, overrides, snippet, secretKey }: CodeSnippetProps) => {
const renderedSecretKey = secretKey ? `'${secretKey}'` : `process.env['${SECRET_KEY_ENV_KEY}']`;
Expand Down

0 comments on commit b90e531

Please sign in to comment.