{"id":28970045,"url":"https://github.com/netcentric/cm-notify-core","last_synced_at":"2026-03-01T04:07:50.434Z","repository":{"id":289160774,"uuid":"967293886","full_name":"Netcentric/cm-notify-core","owner":"Netcentric","description":null,"archived":false,"fork":false,"pushed_at":"2025-04-26T23:11:07.000Z","size":61,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":16,"default_branch":"main","last_synced_at":"2025-11-23T11:09:21.601Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Netcentric.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"docs/CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":"docs/CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-04-16T08:27:07.000Z","updated_at":"2025-04-26T23:11:10.000Z","dependencies_parsed_at":null,"dependency_job_id":"7b7bd9ac-3600-4ee7-87fa-57ece3c040e5","html_url":"https://github.com/Netcentric/cm-notify-core","commit_stats":null,"previous_names":["netcentric/cm-notify-core"],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/Netcentric/cm-notify-core","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcentric%2Fcm-notify-core","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcentric%2Fcm-notify-core/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcentric%2Fcm-notify-core/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcentric%2Fcm-notify-core/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Netcentric","download_url":"https://codeload.github.com/Netcentric/cm-notify-core/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Netcentric%2Fcm-notify-core/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":29960235,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-03-01T01:47:18.291Z","status":"online","status_checked_at":"2026-03-01T02:00:07.437Z","response_time":124,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-24T10:14:51.422Z","updated_at":"2026-03-01T04:07:50.403Z","avatar_url":"https://github.com/Netcentric.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# cm-notify-core\n[![Version](https://img.shields.io/npm/v/@netcentric/cm-notify-core.svg)](https://npmjs.org/package/@netcentric/cm-notify-core)\n[![Release Status](https://github.com/Netcentric/cm-notify-core/actions/workflows/release.yml/badge.svg)](https://github.com/Netcentric/cm-notify-core/actions/workflows/release.yml)\n[![CodeQL Analysis](https://github.com/netcentric/cm-notify-core/workflows/CodeQL/badge.svg?branch=main)](https://github.com/netcentric/cm-notify-core/actions)\n[![semver: semantic-release](https://img.shields.io/badge/semver-semantic--release-blue.svg)](https://github.com/semantic-release/semantic-release)\n[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)\n\nCloud Manager Notify Core is a Node.js application that process Cloud Manager events and sends notifications to Slack, Microsoft Teams or Email.\n\n# Installation\n```\nnpm install --omit=dev --omit=peer @netcentric/cm-notify-core\n```\n\n# Usage\n\n```javascript\nconst { CMNotify } = require('@netcentric/cm-notify-core');\n\nconst cmNotify = new CMNotify();\n\nrouter.post('/cm-webhook', async (req, res, next) =\u003e {\n  const isValidEvent = await cmNotify.post(req);\n\n  if (!isValidEvent) {\n    return res.status(400).send('Invalid event');\n  }\n  // Message is sent to Slack/Teams\n  res.send('Valid event');\n})\n```\n\n - If you need to wait for the message to be sent, you can use the `waitResponse` param in `post` method.\n - If you need to verify the request, you can use the `verify` param in `post` method. For verification you need to set the `secret` in the config. The secret can be a string, path to PublicKey or content of Public Key.\n\n```javascript\n  /**\n * Sends notifications to the configured channels.\n * @param {Object} req - The request object containing the event data.\n * @param {Object} config - Configuration options for the method.\n * @param {boolean} [config.verify=false] - If true, verifies the request signature before processing.\n * @param {boolean} [config.waitResponse=false] - If true, waits for all notifications to be settled before returning.\n * @returns {Promise\u003cArray\u003cPromiseSettledResult\u003cAwaited\u003c*\u003e\u003e\u003e|boolean\u003e} - Returns a promise that resolves to the notification results or a boolean.\n */\n  async post(req, {\n    verify = false,\n    waitResponse = false\n  }) {}\n```\n\n## Example:\n\n```javascript\nconst { CMNotify } = require('@netcentric/cm-notify-core');\n\nconst cmNotify = new CMNotify();\n\nrouter.post('/cm-webhook', async (req, res, next) =\u003e {\n  try {\n    const allMessages = await cmNotify.post(req, { waitResponse: true });\n    allMessages.forEach((result, index) =\u003e {\n      if (result.status === 'fulfilled') {\n        console.log(`Posting Message ${index + 1} responded with value:`, result.value);\n      } else if (result.status === 'rejected') {\n        console.log(`Posting Message ${index + 1} rejected with reason:`, result.reason);\n      }\n    });\n    // Message is sent to Slack/Teams/Email\n    res.send('Valid event');\n  } catch (error) {\n    console.error(error);\n    res.status(400).send('Error sending messages');\n  }\n});\n```\n\n## Configuration\n\n```javascript\n/**\n * @typedef {Object} CmNotifyConfig\n * @property {string} [slackWebhook] - The Slack webhook URL (default: from environment variable SLACK_WEBHOOK).\n * @property {string} [teamsEmail] - The Teams channel email address (default: from environment variable TEAMS_EMAIL).\n * @property {string} [teamsWebhook] - The Teams webhook URL (default: from environment variable TEAMS_WEBHOOK).\n * @property {string} [orgName] - The name of the organization (default: from environment variable ORGANIZATION_NAME).\n * @property {string} [clientId] - The client ID (default: from environment variable CLIENT_ID).\n * @property {string} [title] - The title of the notification (default: 'Cloud Manager Pipeline Notification').\n * @property {string} [fromEmail] - The sender's email address (default: from environment variable EMAIL_FROM).\n * @property {string} [dataPath] - The path to the directory containing data JSON files (default: from environment variable DATA_PATH or '.data').\n * @property {string} [secret] - The secret used for verification, can be client_secret string, path to PublicKey or content of Public Key (default: from environment variable SECRET).\n */\nclass CMNotify {\n  /**\n   * @constructor\n   * @param {CmNotifyConfig} config - Configuration object for CMNotify.\n   */\n  constructor(config = {}) {}\n}\n```\n\n# Messages\n- Slack\n```\nCloud Manager Pipeline Notification:\nSTATUS: ended\nDATE: 10.04.2025, 22:06:36 CET\nNAME: piepeline-name\nTARGET: STAGE_PROD\nTYPE: WEB_TIER\nURL: program/12345/pipeline/12345/execution/12345\n```\n\n# Setup\n\n## Cloud Manager pipelines data (optional)\n\n- The application needs a list of Cloud Manager pipelines to create message details.\n- The list of pipelines can be generated using the `@netcentric/cm-notify` CLI.\n- Or you can create the file manually. File name needs to be `pipelines-data.json` located in `.data` directory.\n```json\n[\n  {\n    \"name\": \"pipeline-name\",\n    \"id\": \"1234567\",\n    \"buildTarget\": \"DEV\",\n    \"type\": \"FRONT_END\"\n  },\n  {\n    \"name\": \"pipeline-name-dev\",\n    \"id\": \"1233217\",\n    \"buildTarget\": \"DEV\",\n    \"type\": \"CI_CD\"\n  }\n]\n```\n- More info in the [@netcentric/cm-notify](https://github.com/netcentric/cm-notify/docs/setup/ADOBE.md) repo.\n- This data is optional, but it is used to create a more detailed message.\n- If the data is not provided, the message will contain the pipeline Status, Date and URL.\n- The message will not contain the pipeline name, target and type.\n\n## Google Auth Token (optional, only if Email notification is used)\n\n- The application uses Google Auth to send emails.\n- You can use the `@netcentric/cm-notify` CLI to generate the token.\n- Or you can create the token manually. \n- The token is stored in the `.data` directory in the `gmail-token.json` file.\n- For GMAIL API you also need `google-credentials.json` in the `.data` directory.\n- More info in the [@netcentric/cm-notify](https://github.com/netcentric/cm-notify/docs/setup/GMAIL.md) repo.\n\n## Environment Variables\n\n- Environment variables are used as a fallback if configuration is not provided in the constructor.\n- Recommended to use `.env` file for sensitive data.\n- Create a `.env` file in the root folder with the following variables:\n\nMinimal required envs:\n```\n# Cloud Manager envs\nORGANIZATION_NAME=orgname# used to build the URL for the Pipeline\n# Messanger apps env\nSLACK_WEBHOOK=slack_webhook_url\n```\nAll envs:\n```\n# Cloud Manager envs\nORGANIZATION_NAME=orgname# used to build the URL for the Pipeline\nCLIENT_ID=e231#used to validate CM event\n# Messanger apps env\nSLACK_WEBHOOK=https://hooks.slack.com/services/123\n# Teams webhook URL\nTEAMS_WEBHOOK=https://prod-123.westus.logic.azure.com:443/workflows/123\n# Teams email, alternative approach, if Webhook is disabled\nTEAMS_EMAIL=email.onmicrosoft.com@amer.teams.ms\n# Email sender env\n# Only needed if Teams email approach is used\nEMAIL_FROM=gmailuser@googleworkspacedomain.com\n# App env (optional)\nDATA_PATH=.data# path to the data folder wher tokens are stored, default is .data\n```\n\n## Cloud Manager Webhook\n\n1. Go to https://developer.adobe.com/console\n2. Create a new project\n3. Add Events to the project\n4. Select `Cloud Manager Events`\n5. Configure Webhook URL.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetcentric%2Fcm-notify-core","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnetcentric%2Fcm-notify-core","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnetcentric%2Fcm-notify-core/lists"}