{"id":23764426,"url":"https://github.com/chaqchase/shinu","last_synced_at":"2025-08-14T19:19:17.504Z","repository":{"id":71595073,"uuid":"604665724","full_name":"chaqchase/shinu","owner":"chaqchase","description":"Shinu - Elegant Process Exception Handling","archived":false,"fork":false,"pushed_at":"2023-05-12T23:30:17.000Z","size":128,"stargazers_count":5,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-12-29T00:24:38.412Z","etag":null,"topics":["unhandled-errors","unhandled-exceptions","unhandled-rejection"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/shinu","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/chaqchase.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":"2023-02-21T14:40:32.000Z","updated_at":"2024-05-27T16:46:22.000Z","dependencies_parsed_at":null,"dependency_job_id":"a63189ca-c572-4e83-9265-1a4cd5c92a8c","html_url":"https://github.com/chaqchase/shinu","commit_stats":{"total_commits":7,"total_committers":1,"mean_commits":7.0,"dds":0.0,"last_synced_commit":"4d7ff2867e63f8447ec1229b4bf633c2d8080bde"},"previous_names":["chaqchase/shinu"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaqchase%2Fshinu","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaqchase%2Fshinu/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaqchase%2Fshinu/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/chaqchase%2Fshinu/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/chaqchase","download_url":"https://codeload.github.com/chaqchase/shinu/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":232032223,"owners_count":18462986,"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":["unhandled-errors","unhandled-exceptions","unhandled-rejection"],"created_at":"2024-12-31T22:18:04.028Z","updated_at":"2024-12-31T22:18:04.632Z","avatar_url":"https://github.com/chaqchase.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Shinu - Elegant Process Exception Handling\n\nShinu is a lightweight Node.js library that makes it easy to handle signals and other process events in your application. It provides a simple interface for registering signal handlers and logging process information.\n\n## Features\n\n- Simple API for adding and removing signal handlers\n- Default signal handlers for common signals (SIGINT, SIGTERM, SIGQUIT)\n- Option to log process information for debugging purposes\n- Option to handle uncaught exceptions and unhandled rejections\n\n## Installation\n\nYou can install Shinu using npm or yarn:\n\n```bash\nnpm install shinu\n```\n\nor\n\n```bash\nyarn add shinu\n```\n\n## Usage\n\nHere's an example of how to use Shinu to handle the SIGINT signal:\n\n```js\nconst { Shinu } = require('shinu');\n\nconst shinu = new Shinu();\n\nshinu.addHandler('SIGINT', (signal) =\u003e {\n  console.log(`Received ${signal}`);\n  process.exit(0);\n});\n\nshinu.start();\n```\n\nIn this example, we create a new `Shinu` instance and add a handler for the `SIGINT` signal. The handler simply logs a message and exits the process. We then call the `start` method to begin listening for signals.\n\nBy default, Shinu includes handlers for the `SIGINT`, `SIGTERM`, and `SIGQUIT` signals, so you don't need to add these manually.\n\nYou can also pass options to the `Shinu` constructor to customize its behavior:\n\n```js\nconst { Shinu } = require('shinu');\n\nconst shinu = new Shinu({\n  debug: true,\n  handlers: [\n    {\n      signal: 'SIGUSR1',\n      handler: (signal) =\u003e {\n        console.log(`Received ${signal}`);\n      },\n    },\n  ],\n});\n\nshinu.start();\n```\n\nIn this example, we pass an options object to the `Shinu` constructor to enable debug logging and add a custom signal handler for `SIGUSR1`.\n\n## API\n\n### `new Shinu(options: IShinuOptions)`\n\nCreates a new `Shinu` instance with the specified options.\n\n```js\nconst shinu = new Shinu({\n  debug: true,\n  handlers: [\n    {\n      signal: 'SIGUSR1',\n      handler: (signal) =\u003e {\n        console.log(`Received ${signal}`);\n      },\n    },\n  ],\n});\n```\n\n#### `options.debug`\n\nType: `boolean`\nDefault: `false`\n\nEnables debug mode. When debug mode is enabled, Shinu will log detailed process information for each signal received.\n\n#### `options.handlers`\n\nType: `IHandler[]`\nDefault: `[]`\n\nAn array of signal handlers to register when the `Shinu` instance is started.\n\n#### `options.logger`\n\nType: `(message: string) =\u003e void`\nDefault: `console.log`\n\nA function that will be called to log messages. You can use your own logger or replace the default `console.log` method.\n\n#### `options.handleUncaughtException`\n\nType: `boolean`\nDefault: `false`\n\nEnables handling of uncaught exceptions. When this option is enabled, Shinu will log any uncaught exceptions and exit the process.\n\n#### `options.handleUnhandledRejection`\n\nType: `boolean`\nDefault: `false`\n\nEnables handling of unhandled rejections. When this option is enabled, Shinu will log any unhandled rejections and exit the process.\n\n### `shinu.addHandler(signal: signals, handler: handler)`\n\nAdds a handler function for the specified signal.\n\n```js\nshinu.addHandler('SIGUSR1', (signal) =\u003e {\n  console.log(`Received ${signal}`);\n});\n```\n\n### `shinu.removeHandler(signal: signals, handler?: handler)`\n\nRemoves the specified handler function for the specified signal. If no handler function is provided, removes all handlers for the signal.\n\n```js\nshinu.removeHandler('SIGUSR1');\n```\n\n### `shinu.removeAllHandlers()`\n\nRemoves all registered signal handlers.\n\n```js\nshinu.removeAllHandlers();\n```\n\n### `shinu.start()`\n\nStarts listening for registered signals and runs any associated handlers.\n\n```js\nshinu.start();\n```\n\n### `shinu.isHandlerAdded(signal: signals, handler: handler)`\n\nReturns `true` if the specified handler function is registered for the specified signal, `false` otherwise.\n\n```js\nconst isHandlerAdded = shinu.isHandlerAdded('SIGUSR1', myHandlerFunction);\n```\n\n## License\n\nThis project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaqchase%2Fshinu","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchaqchase%2Fshinu","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchaqchase%2Fshinu/lists"}