{"id":13524044,"url":"https://github.com/simonecorsi/fine","last_synced_at":"2025-04-22T15:46:04.269Z","repository":{"id":37095066,"uuid":"272901265","full_name":"simonecorsi/fine","owner":"simonecorsi","description":"🧹 Gracefully shutdown Node.js application: help you handle exit signals and cleanup","archived":false,"fork":false,"pushed_at":"2025-04-21T11:34:17.000Z","size":3171,"stargazers_count":32,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-21T12:38:27.022Z","etag":null,"topics":["event","exit","fine","graceful","handler","hook","javascript","nodejs","npm","process","quit","shutdown","sigint","signal","sigterm","stop","terminate"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/@scdev/fine","language":"Shell","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/simonecorsi.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","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,"zenodo":null}},"created_at":"2020-06-17T06:58:56.000Z","updated_at":"2025-04-21T11:34:14.000Z","dependencies_parsed_at":"2023-09-23T10:30:35.458Z","dependency_job_id":"df05c91d-dd40-4a71-b112-123670f1817f","html_url":"https://github.com/simonecorsi/fine","commit_stats":{"total_commits":442,"total_committers":5,"mean_commits":88.4,"dds":"0.17873303167420818","last_synced_commit":"88987d7fab0b6b70c8065162cf722885568f3ceb"},"previous_names":[],"tags_count":22,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonecorsi%2Ffine","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonecorsi%2Ffine/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonecorsi%2Ffine/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/simonecorsi%2Ffine/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/simonecorsi","download_url":"https://codeload.github.com/simonecorsi/fine/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250060730,"owners_count":21368381,"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":["event","exit","fine","graceful","handler","hook","javascript","nodejs","npm","process","quit","shutdown","sigint","signal","sigterm","stop","terminate"],"created_at":"2024-08-01T06:01:06.447Z","updated_at":"2025-04-22T15:46:04.246Z","avatar_url":"https://github.com/simonecorsi.png","language":"Shell","funding_links":[],"categories":["Shell"],"sub_categories":[],"readme":"# fine\n\n\u003c!-- PROJECT SHIELDS --\u003e\n\n\u003c!-- ![tests](https://github.com/simonecorsi/fine/workflows/test/badge.svg) --\u003e\n\n\u003e \"Fine\" [fì-ne] - means \"End\" in Italian.  \n\u003e The point in time when an action, event, or phenomenon ceases or is completed; the conclusion.\n\n## About\n\nZero dependency and opinionated package that gracefully shutdown Node.js applications.\n\nIt provides extendability by taking an array of callbacks that will be executed serially to allow closing user-defined resources, eg: a database connection, drain streams, etc; before timeout exits the main process.\n\n## ESM\n\nThis package now exports both `ESM` and `CommonJS`. If, for some reason, you really really need only the CommonJS version refer to `v1.4.0`.\n\n## Table of contents\n\n\u003c!-- toc --\u003e\n\n- [Installation](#installation)\n- [Usage](#usage)\n  - [Arguments](#arguments)\n- [Contributing](#contributing)\n- [License](#license)\n- [Contact](#contact)\n\n\u003c!-- tocstop --\u003e\n\n## Installation\n\nYou can install locally\n\n```sh\nnpm i @scdev/fine\n```\n\n\u003c!-- USAGE EXAMPLES --\u003e\n\n## Usage\n\n```js\n// Example\nconst http = require(\"http\");\nconst { promisify } = require(\"util\");\nconst fine = require(\"@scdev/fine\");\n\nconst server = http.createServer(/* your handler */);\n\nfine(\n  [\n    // Tip: you can wait that all connection are closed\n    promisify(server.close),\n    // or you can just sto accepting new one and continue closing other callbacks\n    server.close,\n\n    async () =\u003e {\n      // Throws will be NOOP-ed\n      await db.disconnect();\n    },\n  ],\n  {\n    timeout: 2000,\n    events: [\"SIGINT\", \"SIGTERM\", \"uncaughtException\", \"unhandledRejection\"],\n  }\n);\n\n// ...\n```\n\n### Arguments\n\n```js\nfine(callbacks, options);\n```\n\n| parameter         | type       | description                                                           | default                                                            |\n| ----------------- | ---------- | --------------------------------------------------------------------- | ------------------------------------------------------------------ |\n| `callbacks`       | function[] | Collection of callback for custom closing events, eg: db.disconnect() | `[]`                                                               |\n| `options.timeout` | Number     | The time before exiting the process                                   | `2000`                                                             |\n| `options.events`  | string[]   | The events the process will listen on                                 | `[\"SIGINT\", \"SIGTERM\", \"uncaughtException\", \"unhandledRejection\"]` |\n| `options.unref`   | boolean    | Should the timeout keep the process alive or not                      | `false`                                                            |\n\n\u003c!-- CONTRIBUTING --\u003e\n\n## Contributing\n\nProject is pretty simple and straight forward for what is my needs, but if you have any idea you're welcome!\n\nThis projects uses [commitlint](https://commitlint.js.org/) with Angular configuration so be sure to use standard commit format or PR won't be accepted\n\n1. Fork the Project\n2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)\n3. Commit your Changes (`git commit -m 'feat(scope): some AmazingFeature'`)\n4. Push to the Branch (`git push origin feature/AmazingFeature`)\n5. Open a Pull Request\n\n\u003c!-- LICENSE --\u003e\n\n## License\n\nDistributed under the MIT License. See [LICENSE](./LICENSE) for more information.\n\n\u003c!-- CONTACT --\u003e\n\n## Contact\n\nSimone Corsi - [@im_simonecorsi](https://twitter.com/im_simonecorsi)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonecorsi%2Ffine","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsimonecorsi%2Ffine","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsimonecorsi%2Ffine/lists"}