@beautinique/backend-utils 1.0.0
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.
- package/README.md +35 -0
- package/dist/index.cjs +22 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +15 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +20 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -0
package/README.md
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
# @beautinique/backend-utils
|
|
2
|
+
|
|
3
|
+
Backend utilities for Beautinique project.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @beautinique/backend-utils
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```ts
|
|
14
|
+
import {} from '@beautinique/backend-utils';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Repository
|
|
18
|
+
|
|
19
|
+
https://github.com/Nageshwar1997/BQ-Packages
|
|
20
|
+
|
|
21
|
+
## Homepage
|
|
22
|
+
|
|
23
|
+
https://github.com/Nageshwar1997/BQ-Packages
|
|
24
|
+
|
|
25
|
+
## Issues
|
|
26
|
+
|
|
27
|
+
https://github.com/Nageshwar1997/BQ-Packages/issues
|
|
28
|
+
|
|
29
|
+
## Author
|
|
30
|
+
|
|
31
|
+
Nageshwar Pawar
|
|
32
|
+
|
|
33
|
+
## License
|
|
34
|
+
|
|
35
|
+
This package is licensed under the MIT License. See the root `LICENSE` file for details.
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var __defProp = Object.defineProperty;
|
|
4
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
5
|
+
|
|
6
|
+
// src/runTask.ts
|
|
7
|
+
async function runTasks(tasks) {
|
|
8
|
+
if (!tasks?.length) {
|
|
9
|
+
return;
|
|
10
|
+
}
|
|
11
|
+
const results = await Promise.allSettled(tasks.map((task) => task()));
|
|
12
|
+
for (const result of results) {
|
|
13
|
+
if (result.status === "rejected") {
|
|
14
|
+
console.error("[backend-response] a deferred task failed:", result.reason);
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
__name(runTasks, "runTasks");
|
|
19
|
+
|
|
20
|
+
exports.runTasks = runTasks;
|
|
21
|
+
//# sourceMappingURL=index.cjs.map
|
|
22
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runTask.ts"],"names":[],"mappings":";;;;;;AAWA,eAAsB,SAAS,KAAA,EAAgD;AAC7E,EAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,OAAA,GAAU,MAAM,OAAA,CAAQ,UAAA,CAAW,KAAA,CAAM,IAAI,CAAC,IAAA,KAAS,IAAA,EAAM,CAAC,CAAA;AAEpE,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,IAAA,IAAI,MAAA,CAAO,WAAW,UAAA,EAAY;AAChC,MAAA,OAAA,CAAQ,KAAA,CAAM,4CAAA,EAA8C,MAAA,CAAO,MAAM,CAAA;AAAA,IAC3E;AAAA,EACF;AACF;AAZsB,MAAA,CAAA,QAAA,EAAA,UAAA,CAAA","file":"index.cjs","sourcesContent":["import type { TAsyncTask } from './types/index.js';\r\n\r\n/**\r\n * Runs every queued task to completion via `Promise.allSettled`, so one\r\n * task failing doesn't stop (or fail) the others.\r\n *\r\n * These are deliberately fire-and-forget lifecycle hooks (e.g. \"send a\r\n * webhook after this response finishes\") - not part of the request's own\r\n * success/failure path - so a failing task is logged, never thrown: this\r\n * function itself never rejects.\r\n */\r\nexport async function runTasks(tasks: TAsyncTask[] | undefined): Promise<void> {\r\n if (!tasks?.length) {\r\n return;\r\n }\r\n\r\n const results = await Promise.allSettled(tasks.map((task) => task()));\r\n\r\n for (const result of results) {\r\n if (result.status === 'rejected') {\r\n console.error('[backend-response] a deferred task failed:', result.reason);\r\n }\r\n }\r\n}\r\n"]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** A deferred unit of work queued via a `res.locals.afterX` hook array. */
|
|
2
|
+
type TAsyncTask = () => Promise<void>;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Runs every queued task to completion via `Promise.allSettled`, so one
|
|
6
|
+
* task failing doesn't stop (or fail) the others.
|
|
7
|
+
*
|
|
8
|
+
* These are deliberately fire-and-forget lifecycle hooks (e.g. "send a
|
|
9
|
+
* webhook after this response finishes") - not part of the request's own
|
|
10
|
+
* success/failure path - so a failing task is logged, never thrown: this
|
|
11
|
+
* function itself never rejects.
|
|
12
|
+
*/
|
|
13
|
+
declare function runTasks(tasks: TAsyncTask[] | undefined): Promise<void>;
|
|
14
|
+
|
|
15
|
+
export { type TAsyncTask, runTasks };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/** A deferred unit of work queued via a `res.locals.afterX` hook array. */
|
|
2
|
+
type TAsyncTask = () => Promise<void>;
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Runs every queued task to completion via `Promise.allSettled`, so one
|
|
6
|
+
* task failing doesn't stop (or fail) the others.
|
|
7
|
+
*
|
|
8
|
+
* These are deliberately fire-and-forget lifecycle hooks (e.g. "send a
|
|
9
|
+
* webhook after this response finishes") - not part of the request's own
|
|
10
|
+
* success/failure path - so a failing task is logged, never thrown: this
|
|
11
|
+
* function itself never rejects.
|
|
12
|
+
*/
|
|
13
|
+
declare function runTasks(tasks: TAsyncTask[] | undefined): Promise<void>;
|
|
14
|
+
|
|
15
|
+
export { type TAsyncTask, runTasks };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
+
|
|
4
|
+
// src/runTask.ts
|
|
5
|
+
async function runTasks(tasks) {
|
|
6
|
+
if (!tasks?.length) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
const results = await Promise.allSettled(tasks.map((task) => task()));
|
|
10
|
+
for (const result of results) {
|
|
11
|
+
if (result.status === "rejected") {
|
|
12
|
+
console.error("[backend-response] a deferred task failed:", result.reason);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
__name(runTasks, "runTasks");
|
|
17
|
+
|
|
18
|
+
export { runTasks };
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/runTask.ts"],"names":[],"mappings":";;;;AAWA,eAAsB,SAAS,KAAA,EAAgD;AAC7E,EAAA,IAAI,CAAC,OAAO,MAAA,EAAQ;AAClB,IAAA;AAAA,EACF;AAEA,EAAA,MAAM,OAAA,GAAU,MAAM,OAAA,CAAQ,UAAA,CAAW,KAAA,CAAM,IAAI,CAAC,IAAA,KAAS,IAAA,EAAM,CAAC,CAAA;AAEpE,EAAA,KAAA,MAAW,UAAU,OAAA,EAAS;AAC5B,IAAA,IAAI,MAAA,CAAO,WAAW,UAAA,EAAY;AAChC,MAAA,OAAA,CAAQ,KAAA,CAAM,4CAAA,EAA8C,MAAA,CAAO,MAAM,CAAA;AAAA,IAC3E;AAAA,EACF;AACF;AAZsB,MAAA,CAAA,QAAA,EAAA,UAAA,CAAA","file":"index.js","sourcesContent":["import type { TAsyncTask } from './types/index.js';\r\n\r\n/**\r\n * Runs every queued task to completion via `Promise.allSettled`, so one\r\n * task failing doesn't stop (or fail) the others.\r\n *\r\n * These are deliberately fire-and-forget lifecycle hooks (e.g. \"send a\r\n * webhook after this response finishes\") - not part of the request's own\r\n * success/failure path - so a failing task is logged, never thrown: this\r\n * function itself never rejects.\r\n */\r\nexport async function runTasks(tasks: TAsyncTask[] | undefined): Promise<void> {\r\n if (!tasks?.length) {\r\n return;\r\n }\r\n\r\n const results = await Promise.allSettled(tasks.map((task) => task()));\r\n\r\n for (const result of results) {\r\n if (result.status === 'rejected') {\r\n console.error('[backend-response] a deferred task failed:', result.reason);\r\n }\r\n }\r\n}\r\n"]}
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@beautinique/backend-utils",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "Backend utilities for Beautinique project.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"backend",
|
|
7
|
+
"utils",
|
|
8
|
+
"utilities",
|
|
9
|
+
"beautinique"
|
|
10
|
+
],
|
|
11
|
+
"author": "Nageshwar Pawar",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/Nageshwar1997/BQ-Packages.git",
|
|
16
|
+
"directory": "packages/backend/utils"
|
|
17
|
+
},
|
|
18
|
+
"bugs": {
|
|
19
|
+
"url": "https://github.com/Nageshwar1997/BQ-Packages/issues"
|
|
20
|
+
},
|
|
21
|
+
"homepage": "https://github.com/Nageshwar1997/BQ-Packages/tree/main/packages/backend/utils#readme",
|
|
22
|
+
"type": "module",
|
|
23
|
+
"main": "./dist/index.cjs",
|
|
24
|
+
"module": "./dist/index.js",
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"files": [
|
|
27
|
+
"dist"
|
|
28
|
+
],
|
|
29
|
+
"sideEffects": false,
|
|
30
|
+
"exports": {
|
|
31
|
+
".": {
|
|
32
|
+
"types": "./dist/index.d.ts",
|
|
33
|
+
"import": "./dist/index.js",
|
|
34
|
+
"require": "./dist/index.cjs",
|
|
35
|
+
"default": "./dist/index.js"
|
|
36
|
+
},
|
|
37
|
+
"./package.json": "./package.json"
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"build": "tsup",
|
|
41
|
+
"dev": "tsup --watch",
|
|
42
|
+
"lint": "eslint .",
|
|
43
|
+
"typecheck": "tsc --noEmit"
|
|
44
|
+
},
|
|
45
|
+
"publishConfig": {
|
|
46
|
+
"access": "public"
|
|
47
|
+
},
|
|
48
|
+
"engines": {
|
|
49
|
+
"node": ">=24"
|
|
50
|
+
},
|
|
51
|
+
"dependencies": {
|
|
52
|
+
"mongoose": "^9.7.3"
|
|
53
|
+
},
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"typescript": "^6.0.3"
|
|
56
|
+
}
|
|
57
|
+
}
|