{"id":23500258,"url":"https://github.com/samialdury/gracy","last_synced_at":"2025-08-28T00:31:52.441Z","repository":{"id":149993315,"uuid":"622547874","full_name":"samialdury/gracy","owner":"samialdury","description":"Execute custom cleanup function before Node.js exits. DEPRECATED - use https://github.com/mcollina/close-with-grace","archived":true,"fork":false,"pushed_at":"2025-01-27T16:52:21.000Z","size":453,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-08-23T22:31:34.580Z","etag":null,"topics":["cleanup","close","exit","graceful","gracy","node","nodejs","process","shutdown","signal","terminate"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/gracy","language":"TypeScript","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/samialdury.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}},"created_at":"2023-04-02T12:52:09.000Z","updated_at":"2025-01-27T16:53:29.000Z","dependencies_parsed_at":null,"dependency_job_id":"ced9ac30-e508-414e-94c1-04c37564b199","html_url":"https://github.com/samialdury/gracy","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"purl":"pkg:github/samialdury/gracy","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samialdury%2Fgracy","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samialdury%2Fgracy/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samialdury%2Fgracy/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samialdury%2Fgracy/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/samialdury","download_url":"https://codeload.github.com/samialdury/gracy/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/samialdury%2Fgracy/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272405068,"owners_count":24929223,"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","status":"online","status_checked_at":"2025-08-27T02:00:09.397Z","response_time":76,"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":["cleanup","close","exit","graceful","gracy","node","nodejs","process","shutdown","signal","terminate"],"created_at":"2024-12-25T06:44:02.748Z","updated_at":"2025-08-28T00:31:52.336Z","avatar_url":"https://github.com/samialdury.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# `gracy`\n\n\u003e [!WARNING]\n\u003e This package and repository are deprecated and no longer maintained. For alternative, see [close-with-grace](https://github.com/mcollina/close-with-grace).\n\n[![CI status](https://github.com/samialdury/gracy/actions/workflows/ci.yml/badge.svg)](https://github.com/samialdury/gracy/actions/workflows/ci.yml)\n[![license](https://img.shields.io/github/license/samialdury/gracy)](LICENSE)\n[![npm version](https://img.shields.io/npm/v/gracy)](https://www.npmjs.com/package/gracy)\n\nGracy is a zero-dependency library that provides a simple way to execute custom function before a Node.js process exits. It helps you ensure that your applications perform cleanup tasks, gracefully close resources, and maintain data integrity during (un)expected shutdowns or terminations.\n\n## Installation\n\n```sh\npnpm i -E gracy\n```\n\n## Usage\n\n```ts\nimport { onExit } from 'gracy'\n\nonExit(\n    async () =\u003e {\n        closeHttpServer()\n        await closeDatabaseConnection()\n    },\n    { logger: pinoInstance }\n)\n```\n\n## Configuration\n\nThe `onExit` function accepts an configuration object as its second argument. The following options are available:\n\n| Name      | Default value                                 | Description                                                                                                                                                                                           |\n| --------- | --------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |\n| `logger`  |                `console`                               | Logger to use. You should use libraries for structured logging such as [pino](https://github.com/pinojs/pino). Set to `false` to disable logging. |\n| `logLevel`  |         `'info'`                                     | Log level to use. Valid options are `'debug'`, `'info'`, `'error'`. |\n| `logPrefix`  |         `'[gracy] '`                                     | Prefix to use for log messages. Set to empty string to disable prefixing. |\n| `timeout`  |         `10_000`                                     | Timeout (in milliseconds) to wait for the function to finish. If the function does not finish in time, the process will exit with code `1`. |\n| `events`  | `['uncaughtException', 'unhandledRejection']` | Events to listen to. Triggering these events will cause the process to exit with code `1`.                                                                                                            |\n| `signals` | `['SIGTERM', 'SIGINT']`                       | Signals to listen to. Triggering these signals will cause the process to exit with code `0`.                                                                                                          |\n\n## License\n\n[MIT](LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamialdury%2Fgracy","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsamialdury%2Fgracy","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsamialdury%2Fgracy/lists"}