fastify-rabbitmq 1.3.1 → 1.6.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 +6 -3
- package/{dist → lib}/cjs/errors.js +1 -1
- package/lib/cjs/index.js +120 -0
- package/lib/cjs/package.json +3 -0
- package/lib/cjs/validation.js +56 -0
- package/lib/esm/decorate.js +1 -0
- package/{dist → lib}/esm/errors.js +0 -1
- package/{dist → lib}/esm/index.js +0 -1
- package/lib/esm/package.json +3 -0
- package/lib/esm/types.js +1 -0
- package/{dist → lib}/esm/validation.js +0 -1
- package/package.json +30 -19
- package/CHANGELOG.md +0 -43
- package/dist/cjs/index.js +0 -76
- package/dist/cjs/validation.js +0 -17
- package/dist/esm/decorate.js +0 -2
- package/dist/esm/decorate.js.map +0 -1
- package/dist/esm/errors.js.map +0 -1
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/types.js +0 -2
- package/dist/esm/types.js.map +0 -1
- package/dist/esm/validation.js.map +0 -1
- package/dist/types/decorate.d.ts +0 -13
- package/dist/types/errors.d.ts +0 -14
- package/dist/types/index.d.ts +0 -26
- package/dist/types/types.d.ts +0 -12
- package/dist/types/validation.d.ts +0 -2
- /package/{dist → lib}/cjs/decorate.js +0 -0
- /package/{dist → lib}/cjs/types.js +0 -0
- /package/{dist/esm → lib/types}/decorate.d.ts +0 -0
- /package/{dist/esm → lib/types}/errors.d.ts +0 -0
- /package/{dist/esm → lib/types}/index.d.ts +0 -0
- /package/{dist/esm → lib/types}/types.d.ts +0 -0
- /package/{dist/esm → lib/types}/validation.d.ts +0 -0
package/README.md
CHANGED
|
@@ -5,19 +5,22 @@ It uses the [rabbitmq-client](https://github.com/cody-greene/node-rabbitmq-clien
|
|
|
5
5
|
|
|
6
6
|
The build exports this to valid ESM and CJS for ease of cross-compatibility.
|
|
7
7
|
|
|
8
|
+
If you are using this NPM package, please consider giving it a :star: star.
|
|
9
|
+
This will increase its visibility and solicit more contribution from the outside.
|
|
10
|
+
|
|
8
11
|
## Table of Contents
|
|
9
12
|
|
|
10
13
|
1. [Install](#install)
|
|
11
14
|
2. [Basic Usage](#basic-usage)
|
|
12
15
|
3. [Full Documentation](#full-documentation)
|
|
13
|
-
1
|
|
16
|
+
1. [Options](#options)
|
|
14
17
|
4. [Acknowledgements](#acknowledgements)
|
|
15
18
|
5. [License](#license)
|
|
16
19
|
|
|
17
20
|
## Install
|
|
18
21
|
|
|
19
|
-
```
|
|
20
|
-
npm
|
|
22
|
+
```
|
|
23
|
+
npm install fastify-rabbitmq
|
|
21
24
|
```
|
|
22
25
|
|
|
23
26
|
## Basic Usage
|
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.errors = void 0;
|
|
7
|
-
|
|
7
|
+
var error_1 = __importDefault(require("@fastify/error"));
|
|
8
8
|
exports.errors = {
|
|
9
9
|
/** Error if there is an invalid option used during registration. */
|
|
10
10
|
FASTIFY_RABBIT_MQ_ERR_INVALID_OPTS: (0, error_1.default)('FASTIFY_RABBIT_MQ_ERR_INVALID_OPTS', 'Invalid options: %s'),
|
package/lib/cjs/index.js
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
17
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
18
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
19
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
20
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
21
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
22
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
23
|
+
});
|
|
24
|
+
};
|
|
25
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
26
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
27
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
28
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
29
|
+
function step(op) {
|
|
30
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
31
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
32
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
33
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
34
|
+
switch (op[0]) {
|
|
35
|
+
case 0: case 1: t = op; break;
|
|
36
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
37
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
38
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
39
|
+
default:
|
|
40
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
41
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
42
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
43
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
44
|
+
if (t[2]) _.ops.pop();
|
|
45
|
+
_.trys.pop(); continue;
|
|
46
|
+
}
|
|
47
|
+
op = body.call(thisArg, _);
|
|
48
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
49
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
53
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
54
|
+
};
|
|
55
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
56
|
+
exports.decorateFastifyInstance = void 0;
|
|
57
|
+
var fastify_plugin_1 = __importDefault(require("fastify-plugin"));
|
|
58
|
+
var rabbitmq_client_1 = require("rabbitmq-client");
|
|
59
|
+
var errors_js_1 = require("./errors.js");
|
|
60
|
+
var validation_js_1 = require("./validation.js");
|
|
61
|
+
__exportStar(require("./types.js"), exports);
|
|
62
|
+
var decorateFastifyInstance = function (fastify, options, connection) {
|
|
63
|
+
var _a = options.namespace, namespace = _a === void 0 ? '' : _a;
|
|
64
|
+
if (typeof namespace !== 'undefined') {
|
|
65
|
+
fastify.log.debug('[fastify-rabbitmq] Namespace: %s', namespace);
|
|
66
|
+
}
|
|
67
|
+
if (typeof namespace !== 'undefined' && namespace !== '') {
|
|
68
|
+
if (typeof fastify.rabbitmq === 'undefined') {
|
|
69
|
+
fastify.decorate('rabbitmq', Object.create(null));
|
|
70
|
+
}
|
|
71
|
+
if (typeof fastify.rabbitmq[namespace] !== 'undefined') {
|
|
72
|
+
throw new errors_js_1.errors.FASTIFY_RABBIT_MQ_ERR_SETUP_ERRORS("Already registered with namespace: ".concat(namespace));
|
|
73
|
+
}
|
|
74
|
+
fastify.log.trace('[fastify-rabbitmq] Decorate Fastify with Namespace: %', namespace);
|
|
75
|
+
fastify.rabbitmq[namespace] = connection;
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
if (typeof fastify.rabbitmq !== 'undefined') {
|
|
79
|
+
throw new errors_js_1.errors.FASTIFY_RABBIT_MQ_ERR_SETUP_ERRORS('Already registered.');
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
if (typeof fastify.rabbitmq === 'undefined') {
|
|
83
|
+
fastify.log.trace('[fastify-rabbitmq] Decorate Fastify');
|
|
84
|
+
fastify.decorate('rabbitmq', connection);
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
exports.decorateFastifyInstance = decorateFastifyInstance;
|
|
88
|
+
/**
|
|
89
|
+
* Main Function
|
|
90
|
+
* @since 1.0.0
|
|
91
|
+
* @example
|
|
92
|
+
* This is the basics on how to use this plugin:
|
|
93
|
+
* ```js
|
|
94
|
+
* app.register(fastifyRabbit, {
|
|
95
|
+
* connection: 'amqp://guest:guest@localhost'
|
|
96
|
+
* })
|
|
97
|
+
* ```
|
|
98
|
+
* This will allow you to read from your Fastify "object" and
|
|
99
|
+
* use this plugin at the "rabbitmq" level. From there you can execute and maintain
|
|
100
|
+
* the RabbitMQ Connection using the 'rabbitmq-client' package, which is wrapping around
|
|
101
|
+
* this plugin to execute functions it provides.
|
|
102
|
+
*
|
|
103
|
+
* @see [https://cody-greene.github.io/node-rabbitmq-client/latest/index.html](https://cody-greene.github.io/node-rabbitmq-client/latest/index.html)
|
|
104
|
+
*
|
|
105
|
+
*/
|
|
106
|
+
var fastifyRabbit = (0, fastify_plugin_1.default)(function (fastify, opts) { return __awaiter(void 0, void 0, void 0, function () {
|
|
107
|
+
var connection, c;
|
|
108
|
+
return __generator(this, function (_a) {
|
|
109
|
+
switch (_a.label) {
|
|
110
|
+
case 0: return [4 /*yield*/, (0, validation_js_1.validateOpts)(opts)];
|
|
111
|
+
case 1:
|
|
112
|
+
_a.sent();
|
|
113
|
+
connection = opts.connection;
|
|
114
|
+
c = new rabbitmq_client_1.Connection(connection);
|
|
115
|
+
decorateFastifyInstance(fastify, opts, c);
|
|
116
|
+
return [2 /*return*/];
|
|
117
|
+
}
|
|
118
|
+
});
|
|
119
|
+
}); });
|
|
120
|
+
exports.default = fastifyRabbit;
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
+
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.validateOpts = void 0;
|
|
40
|
+
var errors_js_1 = require("./errors.js");
|
|
41
|
+
var validateOpts = function (options) { return __awaiter(void 0, void 0, void 0, function () {
|
|
42
|
+
return __generator(this, function (_a) {
|
|
43
|
+
// Mandatory
|
|
44
|
+
if (typeof options.connection === 'undefined') {
|
|
45
|
+
throw new errors_js_1.errors.FASTIFY_RABBIT_MQ_ERR_INVALID_OPTS('connection or findServers must be defined.');
|
|
46
|
+
}
|
|
47
|
+
// Mandatory
|
|
48
|
+
if (typeof options.connection !== 'undefined') {
|
|
49
|
+
if (typeof options.connection !== 'object') {
|
|
50
|
+
// we need to do some sort of check here to make sure RabbitMQOptions is "valid"
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
return [2 /*return*/];
|
|
54
|
+
});
|
|
55
|
+
}); };
|
|
56
|
+
exports.validateOpts = validateOpts;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/lib/esm/types.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,26 +1,34 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "fastify-rabbitmq",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.6.0",
|
|
4
4
|
"description": "A Fastify RabbitMQ Plugin Developed in Pure TypeScript.",
|
|
5
|
-
"module": "./
|
|
6
|
-
"main": "./
|
|
7
|
-
"types": "./
|
|
5
|
+
"module": "./lib/esm/index.js",
|
|
6
|
+
"main": "./lib/cjs/index.js",
|
|
7
|
+
"types": "./lib/types/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
-
"types": "./
|
|
11
|
-
"import": "./
|
|
12
|
-
"require": "./
|
|
13
|
-
"default": "./
|
|
10
|
+
"types": "./lib/types/index.d.ts",
|
|
11
|
+
"import": "./lib/esm/index.js",
|
|
12
|
+
"require": "./lib/cjs/index.js",
|
|
13
|
+
"default": "./lib/cjs/index.js"
|
|
14
14
|
}
|
|
15
15
|
},
|
|
16
|
+
"files": [
|
|
17
|
+
"lib/"
|
|
18
|
+
],
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": "^18 || ^20"
|
|
21
|
+
},
|
|
16
22
|
"scripts": {
|
|
17
|
-
"clean": "rm -rf
|
|
18
|
-
"build": "tsc && tsc -p tsconfig.cjs.json && tsc -p tsconfig.types.json && ./bin/build-types.sh",
|
|
19
|
-
"build:watch": "tsc -w",
|
|
20
|
-
"
|
|
21
|
-
"lint
|
|
23
|
+
"clean": "rm -rf lib coverage",
|
|
24
|
+
"build": "tsc -p tsconfig.esm.json && tsc -p tsconfig.cjs.json && tsc -p tsconfig.types.json && ./bin/build-types.sh",
|
|
25
|
+
"build:watch": "tsc -p tsconfig.esm.json -w",
|
|
26
|
+
"npmPkgJsonLint": "npmPkgJsonLint .",
|
|
27
|
+
"lint": "npmPkgJsonLint . && ts-standard | snazzy",
|
|
28
|
+
"lint:fix": "npmPkgJsonLint . && ts-standard --fix | snazzy",
|
|
22
29
|
"pack": "npm pack",
|
|
23
|
-
"
|
|
30
|
+
"publish": "clean-publish",
|
|
31
|
+
"prepublishOnly": "npm run clean && npm run build && npm run pack",
|
|
24
32
|
"test": "jest",
|
|
25
33
|
"test:open": "jest --detectOpenHandles",
|
|
26
34
|
"test:ci": "jest --ci",
|
|
@@ -29,7 +37,8 @@
|
|
|
29
37
|
"typedoc:watch": "typedoc -watch",
|
|
30
38
|
"semantic-release": "semantic-release",
|
|
31
39
|
"semantic-release:dry-run": "semantic-release --dry-run",
|
|
32
|
-
"update": "npx npm-check-updates -u && npm
|
|
40
|
+
"update": "npx npm-check-updates -u && npm run update:post-update",
|
|
41
|
+
"update:post-update": "npm install && npm run test:ci"
|
|
33
42
|
},
|
|
34
43
|
"repository": {
|
|
35
44
|
"type": "git",
|
|
@@ -51,7 +60,7 @@
|
|
|
51
60
|
"dependencies": {
|
|
52
61
|
"@fastify/error": "^3.4.1",
|
|
53
62
|
"fastify-plugin": "^4.5.1",
|
|
54
|
-
"rabbitmq-client": "^4.
|
|
63
|
+
"rabbitmq-client": "^4.5.0"
|
|
55
64
|
},
|
|
56
65
|
"devDependencies": {
|
|
57
66
|
"@semantic-release/changelog": "^6.0.3",
|
|
@@ -59,21 +68,23 @@
|
|
|
59
68
|
"@semantic-release/git": "^10.0.1",
|
|
60
69
|
"@semantic-release/release-notes-generator": "^12.1.0",
|
|
61
70
|
"@the-rabbit-hole/semantic-release-config": "^1.4.0",
|
|
71
|
+
"clean-publish": "^4.2.0",
|
|
62
72
|
"@types/jest": "^29.5.11",
|
|
63
73
|
"@types/node": "^20.10.5",
|
|
64
74
|
"@types/randomstring": "^1.1.11",
|
|
65
|
-
"@typescript-eslint/parser": "^6.
|
|
66
|
-
"fastify": "^4.25.
|
|
75
|
+
"@typescript-eslint/parser": "^6.16.0",
|
|
76
|
+
"fastify": "^4.25.2",
|
|
67
77
|
"jest": "^29.7.0",
|
|
68
78
|
"jest-ts-webcompat-resolver": "^1.0.0",
|
|
69
79
|
"npm-check-updates": "^16.14.12",
|
|
80
|
+
"npm-package-json-lint": "^7.1.0",
|
|
70
81
|
"pre-commit": "^1.2.2",
|
|
71
82
|
"semantic-release": "^22.0.12",
|
|
72
83
|
"snazzy": "^9.0.0",
|
|
73
84
|
"ts-jest": "^29.1.1",
|
|
74
85
|
"ts-node": "^10.9.2",
|
|
75
86
|
"ts-standard": "^12.0.2",
|
|
76
|
-
"tsd": "^0.30.
|
|
87
|
+
"tsd": "^0.30.1",
|
|
77
88
|
"typedoc": "^0.25.4",
|
|
78
89
|
"typescript": "^5.3.3"
|
|
79
90
|
},
|
package/CHANGELOG.md
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
## [1.3.1](https://github.com/Bugs5382/fastify-rabbitmq/compare/v1.3.0...v1.3.1) (2023-12-18)
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
### Bug Fixes
|
|
5
|
-
|
|
6
|
-
* url wrong ([f5cf4a7](https://github.com/Bugs5382/fastify-rabbitmq/commit/f5cf4a7f3ca5ceddc6ef8fa7b0d0b9148892e65c))
|
|
7
|
-
|
|
8
|
-
# [1.3.0](https://github.com/Bugs5382/fastify-rabbitmq/compare/v1.2.0...v1.3.0) (2023-12-18)
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
### Features
|
|
12
|
-
|
|
13
|
-
* fastify v5 prep fixes ([f2bbc61](https://github.com/Bugs5382/fastify-rabbitmq/commit/f2bbc6185b5ff76089ec6448f8a847183c2f368e))
|
|
14
|
-
|
|
15
|
-
# 1.0.0 (2023-11-17)
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
### Bug Fixes
|
|
19
|
-
|
|
20
|
-
* fix ci for release ([5f6982a](https://github.com/Bugs5382/fastify-rabbitmq/commit/5f6982a5676341063260e9243b4c6c4ea0810b56))
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
* 19 build in rpc clientserver (#20) ([fc03bd1](https://github.com/Bugs5382/fastify-rabbitmq/commit/fc03bd1fa8ee0932043e778135f712530b28ac9b)), closes [#20](https://github.com/Bugs5382/fastify-rabbitmq/issues/20) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19) [#19](https://github.com/Bugs5382/fastify-rabbitmq/issues/19)
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
### Features
|
|
27
|
-
|
|
28
|
-
* added .idea to gitignore ([4a7ca5b](https://github.com/Bugs5382/fastify-rabbitmq/commit/4a7ca5bf8d8b2a7e7383d0365f9cbb9caaa805d4))
|
|
29
|
-
* fastify namespace issue ([5d12ca1](https://github.com/Bugs5382/fastify-rabbitmq/commit/5d12ca129e6722ba56b4e0ff8bc7920cdd437f01))
|
|
30
|
-
* formatting, update README.md ([97d06ff](https://github.com/Bugs5382/fastify-rabbitmq/commit/97d06ff67fc37e45e34d9f19d2daa1a9402401ae))
|
|
31
|
-
* initial code structure ([bb6c46b](https://github.com/Bugs5382/fastify-rabbitmq/commit/bb6c46b503b2cb386676ad20aa3fa367c5a12721))
|
|
32
|
-
* major code revamp ([426d10a](https://github.com/Bugs5382/fastify-rabbitmq/commit/426d10abfc97cad177736be18cd2bdc8c682426a))
|
|
33
|
-
* npm install works ([bd7fac3](https://github.com/Bugs5382/fastify-rabbitmq/commit/bd7fac3471faff6525a666ba728d2debb504a181))
|
|
34
|
-
* set to version 0.0.0 for now ([a330c71](https://github.com/Bugs5382/fastify-rabbitmq/commit/a330c71773d3b89aacb2d8b19528679ce2ec9484))
|
|
35
|
-
* updated main methods ([a05a897](https://github.com/Bugs5382/fastify-rabbitmq/commit/a05a8973d202a09300d34607c70938573fdf0eb3))
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
### BREAKING CHANGES
|
|
39
|
-
|
|
40
|
-
* dropped node-amqp-connection-manager support
|
|
41
|
-
|
|
42
|
-
* feature: typedoc generation added
|
|
43
|
-
* new style
|
package/dist/cjs/index.js
DELETED
|
@@ -1,76 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
17
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
|
-
};
|
|
19
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.decorateFastifyInstance = void 0;
|
|
21
|
-
const fastify_plugin_1 = __importDefault(require("fastify-plugin"));
|
|
22
|
-
const rabbitmq_client_1 = require("rabbitmq-client");
|
|
23
|
-
const errors_js_1 = require("./errors.js");
|
|
24
|
-
const validation_js_1 = require("./validation.js");
|
|
25
|
-
__exportStar(require("./types.js"), exports);
|
|
26
|
-
const decorateFastifyInstance = (fastify, options, connection) => {
|
|
27
|
-
const { namespace = '' } = options;
|
|
28
|
-
if (typeof namespace !== 'undefined') {
|
|
29
|
-
fastify.log.debug('[fastify-rabbitmq] Namespace: %s', namespace);
|
|
30
|
-
}
|
|
31
|
-
if (typeof namespace !== 'undefined' && namespace !== '') {
|
|
32
|
-
if (typeof fastify.rabbitmq === 'undefined') {
|
|
33
|
-
fastify.decorate('rabbitmq', Object.create(null));
|
|
34
|
-
}
|
|
35
|
-
if (typeof fastify.rabbitmq[namespace] !== 'undefined') {
|
|
36
|
-
throw new errors_js_1.errors.FASTIFY_RABBIT_MQ_ERR_SETUP_ERRORS(`Already registered with namespace: ${namespace}`);
|
|
37
|
-
}
|
|
38
|
-
fastify.log.trace('[fastify-rabbitmq] Decorate Fastify with Namespace: %', namespace);
|
|
39
|
-
fastify.rabbitmq[namespace] = connection;
|
|
40
|
-
}
|
|
41
|
-
else {
|
|
42
|
-
if (typeof fastify.rabbitmq !== 'undefined') {
|
|
43
|
-
throw new errors_js_1.errors.FASTIFY_RABBIT_MQ_ERR_SETUP_ERRORS('Already registered.');
|
|
44
|
-
}
|
|
45
|
-
}
|
|
46
|
-
if (typeof fastify.rabbitmq === 'undefined') {
|
|
47
|
-
fastify.log.trace('[fastify-rabbitmq] Decorate Fastify');
|
|
48
|
-
fastify.decorate('rabbitmq', connection);
|
|
49
|
-
}
|
|
50
|
-
};
|
|
51
|
-
exports.decorateFastifyInstance = decorateFastifyInstance;
|
|
52
|
-
/**
|
|
53
|
-
* Main Function
|
|
54
|
-
* @since 1.0.0
|
|
55
|
-
* @example
|
|
56
|
-
* This is the basics on how to use this plugin:
|
|
57
|
-
* ```js
|
|
58
|
-
* app.register(fastifyRabbit, {
|
|
59
|
-
* connection: 'amqp://guest:guest@localhost'
|
|
60
|
-
* })
|
|
61
|
-
* ```
|
|
62
|
-
* This will allow you to read from your Fastify "object" and
|
|
63
|
-
* use this plugin at the "rabbitmq" level. From there you can execute and maintain
|
|
64
|
-
* the RabbitMQ Connection using the 'rabbitmq-client' package, which is wrapping around
|
|
65
|
-
* this plugin to execute functions it provides.
|
|
66
|
-
*
|
|
67
|
-
* @see [https://cody-greene.github.io/node-rabbitmq-client/latest/index.html](https://cody-greene.github.io/node-rabbitmq-client/latest/index.html)
|
|
68
|
-
*
|
|
69
|
-
*/
|
|
70
|
-
const fastifyRabbit = (0, fastify_plugin_1.default)(async (fastify, opts) => {
|
|
71
|
-
await (0, validation_js_1.validateOpts)(opts);
|
|
72
|
-
const { connection } = opts;
|
|
73
|
-
const c = new rabbitmq_client_1.Connection(connection);
|
|
74
|
-
decorateFastifyInstance(fastify, opts, c);
|
|
75
|
-
});
|
|
76
|
-
exports.default = fastifyRabbit;
|
package/dist/cjs/validation.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.validateOpts = void 0;
|
|
4
|
-
const errors_js_1 = require("./errors.js");
|
|
5
|
-
const validateOpts = async (options) => {
|
|
6
|
-
// Mandatory
|
|
7
|
-
if (typeof options.connection === 'undefined') {
|
|
8
|
-
throw new errors_js_1.errors.FASTIFY_RABBIT_MQ_ERR_INVALID_OPTS('connection or findServers must be defined.');
|
|
9
|
-
}
|
|
10
|
-
// Mandatory
|
|
11
|
-
if (typeof options.connection !== 'undefined') {
|
|
12
|
-
if (typeof options.connection !== 'object') {
|
|
13
|
-
// we need to do some sort of check here to make sure RabbitMQOptions is "valid"
|
|
14
|
-
}
|
|
15
|
-
}
|
|
16
|
-
};
|
|
17
|
-
exports.validateOpts = validateOpts;
|
package/dist/esm/decorate.js
DELETED
package/dist/esm/decorate.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decorate.js","sourceRoot":"","sources":["../../src/decorate.ts"],"names":[],"mappings":""}
|
package/dist/esm/errors.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/errors.ts"],"names":[],"mappings":"AAAA,OAAO,WAAW,MAAM,gBAAgB,CAAA;AAExC,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,oEAAoE;IACpE,kCAAkC,EAAE,WAAW,CAC7C,oCAAoC,EACpC,qBAAqB,CACtB;IACD,6DAA6D;IAC7D,kCAAkC,EAAE,WAAW,CAC7C,oCAAoC,EACpC,iBAAiB,CAClB;IACD,mEAAmE;IACnE,2BAA2B,EAAE,WAAW,CACtC,6BAA6B,EAC7B,iBAAiB,CAClB;CACF,CAAA"}
|
package/dist/esm/index.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,gBAAgB,CAAA;AAC/B,OAAO,EAAqB,UAAU,IAAI,kBAAkB,EAAE,MAAM,iBAAiB,CAAA;AAErF,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAC9C,cAAc,YAAY,CAAA;AAE1B,MAAM,uBAAuB,GAAG,CAAC,OAAwB,EAAE,OAA+B,EAAE,UAAe,EAAQ,EAAE;IACnH,MAAM,EACJ,SAAS,GAAG,EAAE,EACf,GAAG,OAAO,CAAA;IAEX,IAAI,OAAO,SAAS,KAAK,WAAW,EAAE,CAAC;QACrC,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,kCAAkC,EAAE,SAAS,CAAC,CAAA;IAClE,CAAC;IACD,IAAI,OAAO,SAAS,KAAK,WAAW,IAAI,SAAS,KAAK,EAAE,EAAE,CAAC;QACzD,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;YAC5C,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAA;QACnD,CAAC;QAED,IAAI,OAAO,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,WAAW,EAAE,CAAC;YACvD,MAAM,IAAI,MAAM,CAAC,kCAAkC,CAAC,sCAAsC,SAAS,EAAE,CAAC,CAAA;QACxG,CAAC;QAED,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,uDAAuD,EAAE,SAAS,CAAC,CAAA;QACrF,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAC,GAAG,UAAU,CAAA;IAC1C,CAAC;SAAM,CAAC;QACN,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;YAC5C,MAAM,IAAI,MAAM,CAAC,kCAAkC,CAAC,qBAAqB,CAAC,CAAA;QAC5E,CAAC;IACH,CAAC;IAED,IAAI,OAAO,OAAO,CAAC,QAAQ,KAAK,WAAW,EAAE,CAAC;QAC5C,OAAO,CAAC,GAAG,CAAC,KAAK,CAAC,qCAAqC,CAAC,CAAA;QACxD,OAAO,CAAC,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC,CAAA;IAC1C,CAAC;AACH,CAAC,CAAA;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAM,aAAa,GAAG,EAAE,CAAyB,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;IACvE,MAAM,YAAY,CAAC,IAAI,CAAC,CAAA;IAExB,MAAM,EAAE,UAAU,EAAE,GAAG,IAAI,CAAA;IAE3B,MAAM,CAAC,GAAG,IAAI,kBAAkB,CAAC,UAAU,CAAC,CAAA;IAE5C,uBAAuB,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC,CAAC,CAAA;AAC3C,CAAC,CAAC,CAAA;AAEF,eAAe,aAAa,CAAA;AAE5B,OAAO,EAAE,uBAAuB,EAA6C,CAAA"}
|
package/dist/esm/types.js
DELETED
package/dist/esm/types.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/types.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"validation.js","sourceRoot":"","sources":["../../src/validation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAA;AAEpC,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,EAAE,OAA+B,EAAiB,EAAE;IACnF,YAAY;IACZ,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,WAAW,EAAE,CAAC;QAC9C,MAAM,IAAI,MAAM,CAAC,kCAAkC,CAAC,4CAA4C,CAAC,CAAA;IACnG,CAAC;IAED,YAAY;IACZ,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,WAAW,EAAE,CAAC;QAC9C,IAAI,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;YAC3C,gFAAgF;QAClF,CAAC;IACH,CAAC;AACH,CAAC,CAAA"}
|
package/dist/types/decorate.d.ts
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { ConnectionOptions } from 'rabbitmq-client';
|
|
2
|
-
export interface FastifyRabbitMQOptions {
|
|
3
|
-
/**
|
|
4
|
-
* @since 1.0.0
|
|
5
|
-
* @description Connection String or object pointing to the RabbitMQ Broker Services
|
|
6
|
-
*/
|
|
7
|
-
connection: string | ConnectionOptions;
|
|
8
|
-
/**
|
|
9
|
-
* @since 1.0.0
|
|
10
|
-
* @description To set the custom nNamespace within this plugin instance. Used to register this plugin more than one time.
|
|
11
|
-
*/
|
|
12
|
-
namespace?: string;
|
|
13
|
-
}
|
package/dist/types/errors.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare const errors: {
|
|
2
|
-
/** Error if there is an invalid option used during registration. */
|
|
3
|
-
FASTIFY_RABBIT_MQ_ERR_INVALID_OPTS: import("@fastify/error").FastifyErrorConstructor<{
|
|
4
|
-
code: "FASTIFY_RABBIT_MQ_ERR_INVALID_OPTS";
|
|
5
|
-
}, [any?, any?, any?]>;
|
|
6
|
-
/** Error if there is an setup error of the plugin itself. */
|
|
7
|
-
FASTIFY_RABBIT_MQ_ERR_SETUP_ERRORS: import("@fastify/error").FastifyErrorConstructor<{
|
|
8
|
-
code: "FASTIFY_RABBIT_MQ_ERR_SETUP_ERRORS";
|
|
9
|
-
}, [any?, any?, any?]>;
|
|
10
|
-
/** If an invalid usage error was done, this error would pop up. */
|
|
11
|
-
FASTIFY_RABBIT_MQ_ERR_USAGE: import("@fastify/error").FastifyErrorConstructor<{
|
|
12
|
-
code: "FASTIFY_RABBIT_MQ_ERR_USAGE";
|
|
13
|
-
}, [any?, any?, any?]>;
|
|
14
|
-
};
|
package/dist/types/index.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { FastifyInstance } from 'fastify';
|
|
2
|
-
import { ConnectionOptions } from 'rabbitmq-client';
|
|
3
|
-
import { FastifyRabbitMQOptions } from './decorate.js';
|
|
4
|
-
export * from './types.js';
|
|
5
|
-
declare const decorateFastifyInstance: (fastify: FastifyInstance, options: FastifyRabbitMQOptions, connection: any) => void;
|
|
6
|
-
/**
|
|
7
|
-
* Main Function
|
|
8
|
-
* @since 1.0.0
|
|
9
|
-
* @example
|
|
10
|
-
* This is the basics on how to use this plugin:
|
|
11
|
-
* ```js
|
|
12
|
-
* app.register(fastifyRabbit, {
|
|
13
|
-
* connection: 'amqp://guest:guest@localhost'
|
|
14
|
-
* })
|
|
15
|
-
* ```
|
|
16
|
-
* This will allow you to read from your Fastify "object" and
|
|
17
|
-
* use this plugin at the "rabbitmq" level. From there you can execute and maintain
|
|
18
|
-
* the RabbitMQ Connection using the 'rabbitmq-client' package, which is wrapping around
|
|
19
|
-
* this plugin to execute functions it provides.
|
|
20
|
-
*
|
|
21
|
-
* @see [https://cody-greene.github.io/node-rabbitmq-client/latest/index.html](https://cody-greene.github.io/node-rabbitmq-client/latest/index.html)
|
|
22
|
-
*
|
|
23
|
-
*/
|
|
24
|
-
declare const fastifyRabbit: import("fastify").FastifyPluginCallback<FastifyRabbitMQOptions, import("fastify").RawServerDefault, import("fastify").FastifyTypeProviderDefault, import("fastify").FastifyBaseLogger>;
|
|
25
|
-
export default fastifyRabbit;
|
|
26
|
-
export { decorateFastifyInstance, FastifyRabbitMQOptions, ConnectionOptions };
|
package/dist/types/types.d.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { Connection as RabbitMQConnection } from 'rabbitmq-client';
|
|
2
|
-
declare module 'fastify' {
|
|
3
|
-
interface FastifyInstance {
|
|
4
|
-
/** Main Decorator for Fastify **/
|
|
5
|
-
rabbitmq: RabbitMQConnection & fastifyRabbitMQ.FastifyRabbitMQNO;
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
export declare namespace fastifyRabbitMQ {
|
|
9
|
-
interface FastifyRabbitMQNO {
|
|
10
|
-
[namespace: string]: RabbitMQConnection;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|