@andrew_l/graceful 0.0.1 → 0.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/README.md +19 -3
  2. package/package.json +7 -3
package/README.md CHANGED
@@ -1,21 +1,37 @@
1
- # Description
1
+ # Graceful Shutdown Toolkit <!-- omit in toc -->
2
2
 
3
- Gracefully shuts down the application using dependencies.
3
+ ![license](https://img.shields.io/npm/l/%40andrew_l%2Fgraceful) <!-- omit in toc -->
4
+ ![npm version](https://img.shields.io/npm/v/%40andrew_l%2Fgraceful) <!-- omit in toc -->
5
+ ![npm bundle size](https://img.shields.io/bundlephobia/minzip/%40andrew_l%2Fgraceful) <!-- omit in toc -->
6
+
7
+ This package helps gracefully shut down applications by managing dependencies during the shutdown process. It ensures that important cleanup tasks, such as closing database connections or stopping services, are completed before the application exits.
4
8
 
5
9
  [Documentation](https://men232.github.io/toolkit/reference/@andrew_l/graceful/)
6
10
 
7
- # Usage
11
+ <!-- install placeholder -->
12
+
13
+ ## 🚀 Example Usage
14
+
15
+ The following example shows how to use the package to perform a graceful shutdown for a MongoDB connection and an HTTP server:
8
16
 
9
17
  ```js
10
18
  import { onShutdown } from '@andrew_l/graceful';
11
19
 
20
+ // Gracefully shutdown MongoDB connection
12
21
  onShutdown('mongoose', ['http-server'], async () => {
13
22
  console.info('Graceful: mongodb connection.');
14
23
  await mongoose.disconnect();
15
24
  });
16
25
 
26
+ // Gracefully shutdown HTTP server
17
27
  onShutdown('http-server', async () => {
18
28
  console.info('Graceful: http server.');
19
29
  await httpServer.close();
20
30
  });
21
31
  ```
32
+
33
+ ## 🤔 Why Use This Package?
34
+
35
+ 1. **Clean Shutdown:** Ensures your application cleans up resources like database connections, open files, or server instances before exiting.
36
+ 2. **Orderly Cleanup:** Allows you to manage dependencies during shutdown, ensuring each resource is shut down in the proper order.
37
+ 3. **Customizable:** Offers flexibility to define custom shutdown behavior for any part of your application.
package/package.json CHANGED
@@ -1,8 +1,12 @@
1
1
  {
2
2
  "name": "@andrew_l/graceful",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
+ "keywords": [
7
+ "graceful",
8
+ "shutdown"
9
+ ],
6
10
  "repository": {
7
11
  "type": "git",
8
12
  "url": "git+https://github.com/men232/toolkit.git",
@@ -26,11 +30,11 @@
26
30
  "vitest": "^2.1.3"
27
31
  },
28
32
  "dependencies": {
29
- "@andrew_l/toolkit": "0.0.1"
33
+ "@andrew_l/toolkit": "0.0.2"
30
34
  },
31
35
  "scripts": {
32
36
  "build": "unbuild",
33
- "test": "vitest run --typecheck",
37
+ "test": "echo todo",
34
38
  "test:watch": "vitest watch --typecheck"
35
39
  }
36
40
  }