{"id":14975651,"url":"https://github.com/amalfra/mongoose-webhooks","last_synced_at":"2025-07-07T01:05:23.289Z","repository":{"id":44763477,"uuid":"61181595","full_name":"amalfra/mongoose-webhooks","owner":"amalfra","description":"Sends webhook on mongoose model events :mega:","archived":false,"fork":false,"pushed_at":"2025-01-18T14:03:26.000Z","size":253,"stargazers_count":2,"open_issues_count":1,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-05-23T17:41:19.614Z","etag":null,"topics":["mongoose","mongoose-plugin","mongoose-webhooks","webhook"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/amalfra.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"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}},"created_at":"2016-06-15T06:02:49.000Z","updated_at":"2025-01-18T14:01:41.000Z","dependencies_parsed_at":"2025-02-12T16:34:50.226Z","dependency_job_id":"0f66f684-6828-498d-8e61-ce0a37150274","html_url":"https://github.com/amalfra/mongoose-webhooks","commit_stats":{"total_commits":37,"total_committers":3,"mean_commits":"12.333333333333334","dds":"0.18918918918918914","last_synced_commit":"6d5a55cf0e2ba68f836075110f4a32cf4adde109"},"previous_names":[],"tags_count":11,"template":false,"template_full_name":null,"purl":"pkg:github/amalfra/mongoose-webhooks","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amalfra%2Fmongoose-webhooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amalfra%2Fmongoose-webhooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amalfra%2Fmongoose-webhooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amalfra%2Fmongoose-webhooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/amalfra","download_url":"https://codeload.github.com/amalfra/mongoose-webhooks/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/amalfra%2Fmongoose-webhooks/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261556390,"owners_count":23176670,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["mongoose","mongoose-plugin","mongoose-webhooks","webhook"],"created_at":"2024-09-24T13:52:20.338Z","updated_at":"2025-07-07T01:05:23.262Z","avatar_url":"https://github.com/amalfra.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mongoose Webhooks\n========\n\n[![npm version](https://badge.fury.io/js/mongoose-webhooks.svg)](https://badge.fury.io/js/mongoose-webhooks)\n![Build Status](https://github.com/amalfra/mongoose-webhooks/actions/workflows/test.yml/badge.svg?branch=main)\n\nSends webhook on mongoose model events.\n\n## Installation\nIn your project root, run the following:\n\n```sh\nnpm install mongoose-webhooks\n```\n\n## Usage\nTo use `mongoose-webhooks` plugin in your model you will have to first require the plugin as\n\n```javascript\nconst mongooseWebhooks = require('mongoose-webhooks');\n```\n\nThe following schema definition defines a \"User\" schema, and uses mongoose-webhooks plugin\n\n```javascript\nconst mongoose = require('mongoose');\nconst Schema = mongoose.Schema;\n// Require the plugin\nconst mongooseWebhooks = require('mongoose-webhooks');\n\nconst User = new Schema({\n  username : { type : String, required : true},\n  password : { type : String, required : true },\n  email : { type : String, required : true},\n  lastModified : Date,\n  created : Date\n});\n\n// Apply the plugin to schema. Note that the urls option is required.\nUser.plugin(mongooseWebhooks, {'urls': 'http://site.com/mongoose-webhook'});\n// urls options also supports multiple values. You can pass array of values if webhook needs to be delivered to multiple destinations\nUser.plugin(mongooseWebhooks, {'urls': ['http://site1.com/mongoose-webhook', 'http://site2.com/mongoose-webhook']});\n```\n\nNow you will be getting a webhook POST request to configured url. The webhook payload will be\n\n```javascript\n{\n  \"event\": \"save\",\n  \"data\": {\n    \"__v\": 0,\n    \"username\": \"test\",\n    \"password\": \"test\",\n    \"email\": \"test@test.com\"\n    \"_id\": \"576cf0eacdefabd20a52ac89\"\n  }\n}\n```\n\nThe event key can have following values\n  * **save** : When the mongoose document is inserted\n  * **update** : When the mongoose document is updated\n  * **remove** : When the mongoose document is removed\n\nThe data key will have the JSON seralized document from mongoose.\n\n## Options\n\nThe two options supported by plugin are\n  * **urls** : You can specify the URL(s) to send webhook with this option. This accepts multiple values as arrays too. *This is a required option*\n  * **useragent** : Lets you specify the `User-Agent` header for the webhook request. This is optional.\n\n## Development\n\nQuestions, problems or suggestions? Please post them on the [issue tracker](https://github.com/amalfra/mongoose-webhooks/issues).\n\nYou can contribute changes by forking the project and submitting a pull request. Feel free to contribute :heart_eyes:\n\nUNDER MIT LICENSE\n=================\n\nThe MIT License (MIT)\n\nCopyright (c) 2016 Amal Francis\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famalfra%2Fmongoose-webhooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famalfra%2Fmongoose-webhooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famalfra%2Fmongoose-webhooks/lists"}