plutin 1.2.3 → 1.3.1
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/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +286 -27
- package/dist/index.d.ts +286 -27
- package/dist/{index.js → index.mjs} +1 -1
- package/package.json +5 -4
- package/dist/base-controller-68008870.d.ts +0 -46
- package/dist/core/decorators/controller-http-decorator.cjs +0 -310
- package/dist/core/decorators/controller-http-decorator.cjs.map +0 -1
- package/dist/core/decorators/controller-http-decorator.d.cts +0 -13
- package/dist/core/decorators/controller-http-decorator.d.ts +0 -13
- package/dist/core/decorators/controller-http-decorator.js +0 -285
- package/dist/core/decorators/controller-http-decorator.js.map +0 -1
- package/dist/core/decorators/dependency-container.cjs +0 -95
- package/dist/core/decorators/dependency-container.cjs.map +0 -1
- package/dist/core/decorators/dependency-container.d.cts +0 -22
- package/dist/core/decorators/dependency-container.d.ts +0 -22
- package/dist/core/decorators/dependency-container.js +0 -71
- package/dist/core/decorators/dependency-container.js.map +0 -1
- package/dist/core/entities/aggregate-root.cjs +0 -99
- package/dist/core/entities/aggregate-root.cjs.map +0 -1
- package/dist/core/entities/aggregate-root.d.cts +0 -8
- package/dist/core/entities/aggregate-root.d.ts +0 -8
- package/dist/core/entities/aggregate-root.js +0 -74
- package/dist/core/entities/aggregate-root.js.map +0 -1
- package/dist/core/entities/common-dto.cjs +0 -19
- package/dist/core/entities/common-dto.cjs.map +0 -1
- package/dist/core/entities/common-dto.d.cts +0 -10
- package/dist/core/entities/common-dto.d.ts +0 -10
- package/dist/core/entities/common-dto.js +0 -1
- package/dist/core/entities/common-dto.js.map +0 -1
- package/dist/core/entities/domain-event.cjs +0 -19
- package/dist/core/entities/domain-event.cjs.map +0 -1
- package/dist/core/entities/domain-event.d.cts +0 -6
- package/dist/core/entities/domain-event.d.ts +0 -6
- package/dist/core/entities/domain-event.js +0 -1
- package/dist/core/entities/domain-event.js.map +0 -1
- package/dist/core/entities/entity.cjs +0 -92
- package/dist/core/entities/entity.cjs.map +0 -1
- package/dist/core/entities/entity.d.cts +0 -18
- package/dist/core/entities/entity.d.ts +0 -18
- package/dist/core/entities/entity.js +0 -67
- package/dist/core/entities/entity.js.map +0 -1
- package/dist/core/entities/optional.cjs +0 -19
- package/dist/core/entities/optional.cjs.map +0 -1
- package/dist/core/entities/optional.d.cts +0 -3
- package/dist/core/entities/optional.d.ts +0 -3
- package/dist/core/entities/optional.js +0 -1
- package/dist/core/entities/optional.js.map +0 -1
- package/dist/core/entities/unique-entity-id.cjs +0 -50
- package/dist/core/entities/unique-entity-id.cjs.map +0 -1
- package/dist/core/entities/unique-entity-id.d.cts +0 -9
- package/dist/core/entities/unique-entity-id.d.ts +0 -9
- package/dist/core/entities/unique-entity-id.js +0 -27
- package/dist/core/entities/unique-entity-id.js.map +0 -1
- package/dist/core/entities/value-object.cjs +0 -40
- package/dist/core/entities/value-object.cjs.map +0 -1
- package/dist/core/entities/value-object.d.cts +0 -6
- package/dist/core/entities/value-object.d.ts +0 -6
- package/dist/core/entities/value-object.js +0 -17
- package/dist/core/entities/value-object.js.map +0 -1
- package/dist/core/entities/watched-list.cjs +0 -121
- package/dist/core/entities/watched-list.cjs.map +0 -1
- package/dist/core/entities/watched-list.d.cts +0 -27
- package/dist/core/entities/watched-list.d.ts +0 -27
- package/dist/core/entities/watched-list.js +0 -98
- package/dist/core/entities/watched-list.js.map +0 -1
- package/dist/core/entities/watched-list.test.cjs +0 -186
- package/dist/core/entities/watched-list.test.cjs.map +0 -1
- package/dist/core/entities/watched-list.test.d.cts +0 -2
- package/dist/core/entities/watched-list.test.d.ts +0 -2
- package/dist/core/entities/watched-list.test.js +0 -185
- package/dist/core/entities/watched-list.test.js.map +0 -1
- package/dist/core/errors/api-common-error.cjs +0 -38
- package/dist/core/errors/api-common-error.cjs.map +0 -1
- package/dist/core/errors/api-common-error.d.cts +0 -28
- package/dist/core/errors/api-common-error.d.ts +0 -28
- package/dist/core/errors/api-common-error.js +0 -13
- package/dist/core/errors/api-common-error.js.map +0 -1
- package/dist/core/errors/application-error.cjs +0 -54
- package/dist/core/errors/application-error.cjs.map +0 -1
- package/dist/core/errors/application-error.d.cts +0 -8
- package/dist/core/errors/application-error.d.ts +0 -8
- package/dist/core/errors/application-error.js +0 -33
- package/dist/core/errors/application-error.js.map +0 -1
- package/dist/core/errors/conflict-error.cjs +0 -56
- package/dist/core/errors/conflict-error.cjs.map +0 -1
- package/dist/core/errors/conflict-error.d.cts +0 -13
- package/dist/core/errors/conflict-error.d.ts +0 -13
- package/dist/core/errors/conflict-error.js +0 -35
- package/dist/core/errors/conflict-error.js.map +0 -1
- package/dist/core/errors/domain-error.cjs +0 -54
- package/dist/core/errors/domain-error.cjs.map +0 -1
- package/dist/core/errors/domain-error.d.cts +0 -8
- package/dist/core/errors/domain-error.d.ts +0 -8
- package/dist/core/errors/domain-error.js +0 -33
- package/dist/core/errors/domain-error.js.map +0 -1
- package/dist/core/errors/http-client-error.cjs +0 -54
- package/dist/core/errors/http-client-error.cjs.map +0 -1
- package/dist/core/errors/http-client-error.d.cts +0 -8
- package/dist/core/errors/http-client-error.d.ts +0 -8
- package/dist/core/errors/http-client-error.js +0 -33
- package/dist/core/errors/http-client-error.js.map +0 -1
- package/dist/core/errors/infra-error.cjs +0 -54
- package/dist/core/errors/infra-error.cjs.map +0 -1
- package/dist/core/errors/infra-error.d.cts +0 -8
- package/dist/core/errors/infra-error.d.ts +0 -8
- package/dist/core/errors/infra-error.js +0 -33
- package/dist/core/errors/infra-error.js.map +0 -1
- package/dist/core/errors/validation-error.cjs +0 -55
- package/dist/core/errors/validation-error.cjs.map +0 -1
- package/dist/core/errors/validation-error.d.cts +0 -8
- package/dist/core/errors/validation-error.d.ts +0 -8
- package/dist/core/errors/validation-error.js +0 -34
- package/dist/core/errors/validation-error.js.map +0 -1
- package/dist/core/http/base-controller.cjs +0 -295
- package/dist/core/http/base-controller.cjs.map +0 -1
- package/dist/core/http/base-controller.d.cts +0 -1
- package/dist/core/http/base-controller.d.ts +0 -1
- package/dist/core/http/base-controller.js +0 -270
- package/dist/core/http/base-controller.js.map +0 -1
- package/dist/core/http/dto-response.cjs +0 -19
- package/dist/core/http/dto-response.cjs.map +0 -1
- package/dist/core/http/dto-response.d.cts +0 -10
- package/dist/core/http/dto-response.d.ts +0 -10
- package/dist/core/http/dto-response.js +0 -1
- package/dist/core/http/dto-response.js.map +0 -1
- package/dist/core/http/error-notifier.cjs +0 -19
- package/dist/core/http/error-notifier.cjs.map +0 -1
- package/dist/core/http/error-notifier.d.cts +0 -1
- package/dist/core/http/error-notifier.d.ts +0 -1
- package/dist/core/http/error-notifier.js +0 -1
- package/dist/core/http/error-notifier.js.map +0 -1
- package/dist/core/http/get-take-and-skip.cjs +0 -40
- package/dist/core/http/get-take-and-skip.cjs.map +0 -1
- package/dist/core/http/get-take-and-skip.d.cts +0 -6
- package/dist/core/http/get-take-and-skip.d.ts +0 -6
- package/dist/core/http/get-take-and-skip.js +0 -17
- package/dist/core/http/get-take-and-skip.js.map +0 -1
- package/dist/core/http/health-connections.cjs +0 -42
- package/dist/core/http/health-connections.cjs.map +0 -1
- package/dist/core/http/health-connections.d.cts +0 -16
- package/dist/core/http/health-connections.d.ts +0 -16
- package/dist/core/http/health-connections.js +0 -23
- package/dist/core/http/health-connections.js.map +0 -1
- package/dist/core/http/http.cjs +0 -19
- package/dist/core/http/http.cjs.map +0 -1
- package/dist/core/http/http.d.cts +0 -10
- package/dist/core/http/http.d.ts +0 -10
- package/dist/core/http/http.js +0 -1
- package/dist/core/http/http.js.map +0 -1
- package/dist/core/http/pagination.cjs +0 -19
- package/dist/core/http/pagination.cjs.map +0 -1
- package/dist/core/http/pagination.d.cts +0 -9
- package/dist/core/http/pagination.d.ts +0 -9
- package/dist/core/http/pagination.js +0 -1
- package/dist/core/http/pagination.js.map +0 -1
- package/dist/core/http/validator.cjs +0 -19
- package/dist/core/http/validator.cjs.map +0 -1
- package/dist/core/http/validator.d.cts +0 -11
- package/dist/core/http/validator.d.ts +0 -11
- package/dist/core/http/validator.js +0 -1
- package/dist/core/http/validator.js.map +0 -1
- package/dist/infra/adapters/http/express-adapter.cjs +0 -139
- package/dist/infra/adapters/http/express-adapter.cjs.map +0 -1
- package/dist/infra/adapters/http/express-adapter.d.cts +0 -15
- package/dist/infra/adapters/http/express-adapter.d.ts +0 -15
- package/dist/infra/adapters/http/express-adapter.js +0 -106
- package/dist/infra/adapters/http/express-adapter.js.map +0 -1
- package/dist/infra/adapters/http/fastify-adapter.cjs +0 -124
- package/dist/infra/adapters/http/fastify-adapter.cjs.map +0 -1
- package/dist/infra/adapters/http/fastify-adapter.d.cts +0 -14
- package/dist/infra/adapters/http/fastify-adapter.d.ts +0 -14
- package/dist/infra/adapters/http/fastify-adapter.js +0 -91
- package/dist/infra/adapters/http/fastify-adapter.js.map +0 -1
- package/dist/infra/adapters/http/response-error-code.cjs +0 -35
- package/dist/infra/adapters/http/response-error-code.cjs.map +0 -1
- package/dist/infra/adapters/http/response-error-code.d.cts +0 -6
- package/dist/infra/adapters/http/response-error-code.d.ts +0 -6
- package/dist/infra/adapters/http/response-error-code.js +0 -10
- package/dist/infra/adapters/http/response-error-code.js.map +0 -1
- package/dist/infra/adapters/http/validate-controller-metadata.cjs +0 -42
- package/dist/infra/adapters/http/validate-controller-metadata.cjs.map +0 -1
- package/dist/infra/adapters/http/validate-controller-metadata.d.cts +0 -11
- package/dist/infra/adapters/http/validate-controller-metadata.d.ts +0 -11
- package/dist/infra/adapters/http/validate-controller-metadata.js +0 -19
- package/dist/infra/adapters/http/validate-controller-metadata.js.map +0 -1
- package/dist/infra/adapters/notifications/discord.cjs +0 -90
- package/dist/infra/adapters/notifications/discord.cjs.map +0 -1
- package/dist/infra/adapters/notifications/discord.d.cts +0 -14
- package/dist/infra/adapters/notifications/discord.d.ts +0 -14
- package/dist/infra/adapters/notifications/discord.js +0 -65
- package/dist/infra/adapters/notifications/discord.js.map +0 -1
- package/dist/infra/adapters/notifications/in-memory.cjs +0 -44
- package/dist/infra/adapters/notifications/in-memory.cjs.map +0 -1
- package/dist/infra/adapters/notifications/in-memory.d.cts +0 -8
- package/dist/infra/adapters/notifications/in-memory.d.ts +0 -8
- package/dist/infra/adapters/notifications/in-memory.js +0 -21
- package/dist/infra/adapters/notifications/in-memory.js.map +0 -1
- package/dist/infra/adapters/notifications/notification-factory.cjs +0 -219
- package/dist/infra/adapters/notifications/notification-factory.cjs.map +0 -1
- package/dist/infra/adapters/notifications/notification-factory.d.cts +0 -18
- package/dist/infra/adapters/notifications/notification-factory.d.ts +0 -18
- package/dist/infra/adapters/notifications/notification-factory.js +0 -184
- package/dist/infra/adapters/notifications/notification-factory.js.map +0 -1
- package/dist/infra/adapters/notifications/sentry.cjs +0 -129
- package/dist/infra/adapters/notifications/sentry.cjs.map +0 -1
- package/dist/infra/adapters/notifications/sentry.d.cts +0 -13
- package/dist/infra/adapters/notifications/sentry.d.ts +0 -13
- package/dist/infra/adapters/notifications/sentry.js +0 -96
- package/dist/infra/adapters/notifications/sentry.js.map +0 -1
- package/dist/infra/adapters/validators/zod/index.cjs +0 -179
- package/dist/infra/adapters/validators/zod/index.cjs.map +0 -1
- package/dist/infra/adapters/validators/zod/index.d.cts +0 -19
- package/dist/infra/adapters/validators/zod/index.d.ts +0 -19
- package/dist/infra/adapters/validators/zod/index.js +0 -154
- package/dist/infra/adapters/validators/zod/index.js.map +0 -1
- package/dist/infra/adapters/validators/zod/zod-map-error.cjs +0 -79
- package/dist/infra/adapters/validators/zod/zod-map-error.cjs.map +0 -1
- package/dist/infra/adapters/validators/zod/zod-map-error.d.cts +0 -15
- package/dist/infra/adapters/validators/zod/zod-map-error.d.ts +0 -15
- package/dist/infra/adapters/validators/zod/zod-map-error.js +0 -60
- package/dist/infra/adapters/validators/zod/zod-map-error.js.map +0 -1
- package/dist/infra/adapters/validators/zod/zod-validator.cjs +0 -178
- package/dist/infra/adapters/validators/zod/zod-validator.cjs.map +0 -1
- package/dist/infra/adapters/validators/zod/zod-validator.d.cts +0 -13
- package/dist/infra/adapters/validators/zod/zod-validator.d.ts +0 -13
- package/dist/infra/adapters/validators/zod/zod-validator.js +0 -153
- package/dist/infra/adapters/validators/zod/zod-validator.js.map +0 -1
- package/dist/infra/env/index.cjs +0 -467
- package/dist/infra/env/index.cjs.map +0 -1
- package/dist/infra/env/index.d.cts +0 -26
- package/dist/infra/env/index.d.ts +0 -26
- package/dist/infra/env/index.js +0 -452
- package/dist/infra/env/index.js.map +0 -1
- /package/dist/{index.js.map → index.mjs.map} +0 -0
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/infra/adapters/notifications/discord.ts
|
|
22
|
-
var discord_exports = {};
|
|
23
|
-
__export(discord_exports, {
|
|
24
|
-
DiscordNotifier: () => DiscordNotifier
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(discord_exports);
|
|
27
|
-
|
|
28
|
-
// src/core/decorators/dependency-container.ts
|
|
29
|
-
var import_reflect_metadata = require("reflect-metadata");
|
|
30
|
-
function Inject(token) {
|
|
31
|
-
return (target, _propertyKey, parameterIndex) => {
|
|
32
|
-
const constructor = typeof target === "function" ? target : target.constructor;
|
|
33
|
-
const existingInjectedParams = Reflect.getOwnMetadata("inject:params", constructor) || {};
|
|
34
|
-
existingInjectedParams[parameterIndex] = token;
|
|
35
|
-
Reflect.defineMetadata("inject:params", existingInjectedParams, constructor);
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
|
-
__name(Inject, "Inject");
|
|
39
|
-
|
|
40
|
-
// src/infra/adapters/notifications/discord.ts
|
|
41
|
-
var import_discord_webhook_node = require("discord-webhook-node");
|
|
42
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
43
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
44
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
45
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
46
|
-
else
|
|
47
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
48
|
-
if (d = decorators[i])
|
|
49
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
50
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
51
|
-
}
|
|
52
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
53
|
-
function _ts_metadata(k, v) {
|
|
54
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
55
|
-
return Reflect.metadata(k, v);
|
|
56
|
-
}
|
|
57
|
-
__name(_ts_metadata, "_ts_metadata");
|
|
58
|
-
function _ts_param(paramIndex, decorator) {
|
|
59
|
-
return function(target, key) {
|
|
60
|
-
decorator(target, key, paramIndex);
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
__name(_ts_param, "_ts_param");
|
|
64
|
-
var DiscordNotifier = class {
|
|
65
|
-
static {
|
|
66
|
-
__name(this, "DiscordNotifier");
|
|
67
|
-
}
|
|
68
|
-
options;
|
|
69
|
-
webhook;
|
|
70
|
-
constructor(options) {
|
|
71
|
-
this.options = options;
|
|
72
|
-
this.webhook = new import_discord_webhook_node.Webhook(this.options.url);
|
|
73
|
-
}
|
|
74
|
-
async notify(error, context) {
|
|
75
|
-
const embed = new import_discord_webhook_node.MessageBuilder().setTitle("\u{1F6A8} Error").addField("Message", `\`\`\`${error.message.slice(0, 300)}\`\`\``).addField("Route:", `\`[${context?.request?.method}] ${context?.request?.url}\``, true).addField("Params:", "```json\n" + JSON.stringify(context?.request?.params, null, 2) + "\n```", true).addField("Query:", "```json\n" + JSON.stringify(context?.request?.query, null, 2) + "\n```", true).addField("Headers:", "```json\n" + JSON.stringify(context?.request?.headers, null, 2) + "\n```", true).addField("Body:", "```json\n" + JSON.stringify(context?.request?.body, null, 2) + "\n```").addField("Stack Trace:", "```" + (error.stack || "No stack provided").slice(0, 900) + "```").setFooter(`Env: ${this.options.env || "development"}`).setTimestamp();
|
|
76
|
-
await this.webhook.send(embed);
|
|
77
|
-
}
|
|
78
|
-
};
|
|
79
|
-
DiscordNotifier = _ts_decorate([
|
|
80
|
-
_ts_param(0, Inject("DiscordConfig")),
|
|
81
|
-
_ts_metadata("design:type", Function),
|
|
82
|
-
_ts_metadata("design:paramtypes", [
|
|
83
|
-
typeof DiscordOptions === "undefined" ? Object : DiscordOptions
|
|
84
|
-
])
|
|
85
|
-
], DiscordNotifier);
|
|
86
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
87
|
-
0 && (module.exports = {
|
|
88
|
-
DiscordNotifier
|
|
89
|
-
});
|
|
90
|
-
//# sourceMappingURL=discord.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/decorators/dependency-container.ts","../../../../src/infra/adapters/notifications/discord.ts"],"sourcesContent":["import 'reflect-metadata'\n\ntype Class<T = any> = new (...args: any[]) => T\n\ntype Registration =\n | { type: 'class'; myClass: Class; singleton: boolean }\n | { type: 'value'; value: any }\n\nexport class DependencyContainer {\n static registry = new Map<string, Registration>()\n static singletons = new Map<string, any>()\n\n static register<T>(\n token: string,\n myClass: Class<T>,\n options: { singleton: boolean }\n ) {\n this.registry.set(token, {\n type: 'class',\n myClass,\n singleton: options.singleton,\n })\n }\n\n static registerValue<T>(token: string, value: T) {\n this.registry.set(token, { type: 'value', value })\n }\n\n static resolve<T>(target: Class<T>): T {\n const injectMetadata: Record<number, string> =\n Reflect.getOwnMetadata('inject:params', target) || {}\n\n const paramCount = Object.keys(injectMetadata).length\n\n const params = Array.from({ length: paramCount }, (_, index) => {\n const token = injectMetadata[index]\n if (!token) {\n throw new Error(\n `Missing @Inject token for parameter index ${index} in ${target.name}`\n )\n }\n return this.resolveToken(token)\n })\n\n return new target(...params)\n }\n\n static resolveToken(token: string): any {\n const registration = this.registry.get(token)\n\n if (!registration) {\n throw new Error(\n `\"${token}\" not registered. Please register it in the container.`\n )\n }\n\n if (registration.type === 'value') {\n return registration.value\n }\n\n const { myClass, singleton } = registration\n\n if (singleton) {\n if (!this.singletons.has(token)) {\n const instance = this.resolve(myClass)\n this.singletons.set(token, instance)\n }\n return this.singletons.get(token)\n }\n\n return this.resolve(myClass)\n }\n}\n\nexport function Inject(token: string): ParameterDecorator {\n return (\n target: object,\n _propertyKey: string | symbol | undefined,\n parameterIndex: number\n ): void => {\n const constructor =\n typeof target === 'function' ? target : target.constructor\n\n const existingInjectedParams: Record<number, string> =\n Reflect.getOwnMetadata('inject:params', constructor) || {}\n\n existingInjectedParams[parameterIndex] = token\n\n Reflect.defineMetadata('inject:params', existingInjectedParams, constructor)\n }\n}\n","import { Inject } from 'core/decorators/dependency-container'\nimport { MessageBuilder, Webhook } from 'discord-webhook-node'\n\nimport type { ContextError } from '../../../core/http/base-controller'\nimport type { IErrorNotifier } from '../../../core/http/error-notifier'\n\ntype DiscordOptions = {\n url: string\n env: string\n}\n\nexport class DiscordNotifier implements IErrorNotifier {\n private webhook: Webhook\n\n constructor(\n @Inject('DiscordConfig') private readonly options: DiscordOptions\n ) {\n this.webhook = new Webhook(this.options.url)\n }\n\n async notify(error: Error, context: ContextError): Promise<void> {\n const embed = new MessageBuilder()\n .setTitle('🚨 Error')\n .addField('Message', `\\`\\`\\`${error.message.slice(0, 300)}\\`\\`\\``)\n .addField(\n 'Route:',\n `\\`[${context?.request?.method}] ${context?.request?.url}\\``,\n true\n )\n .addField(\n 'Params:',\n '```json\\n' +\n JSON.stringify(context?.request?.params, null, 2) +\n '\\n```',\n true\n )\n .addField(\n 'Query:',\n '```json\\n' +\n JSON.stringify(context?.request?.query, null, 2) +\n '\\n```',\n true\n )\n .addField(\n 'Headers:',\n '```json\\n' +\n JSON.stringify(context?.request?.headers, null, 2) +\n '\\n```',\n true\n )\n .addField(\n 'Body:',\n '```json\\n' + JSON.stringify(context?.request?.body, null, 2) + '\\n```'\n )\n .addField(\n 'Stack Trace:',\n '```' + (error.stack || 'No stack provided').slice(0, 900) + '```'\n )\n .setFooter(`Env: ${this.options.env || 'development'}`)\n .setTimestamp()\n\n await this.webhook.send(embed)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8BAAO;AA0EA,SAASA,OAAOC,OAAa;AAClC,SAAO,CACLC,QACAC,cACAC,mBAAAA;AAEA,UAAMC,cACJ,OAAOH,WAAW,aAAaA,SAASA,OAAOG;AAEjD,UAAMC,yBACJC,QAAQC,eAAe,iBAAiBH,WAAAA,KAAgB,CAAC;AAE3DC,2BAAuBF,cAAAA,IAAkBH;AAEzCM,YAAQE,eAAe,iBAAiBH,wBAAwBD,WAAAA;EAClE;AACF;AAhBgBL;;;ACzEhB,kCAAwC;;;;;;;;;;;;;;;;;;;;;;;AAUjC,IAAMU,kBAAN,MAAMA;SAAAA;;;;EACHC;EAERC,YAC4CC,SAC1C;SAD0CA,UAAAA;AAE1C,SAAKF,UAAU,IAAIG,oCAAQ,KAAKD,QAAQE,GAAG;EAC7C;EAEA,MAAMC,OAAOC,OAAcC,SAAsC;AAC/D,UAAMC,QAAQ,IAAIC,2CAAAA,EACfC,SAAS,iBAAA,EACTC,SAAS,WAAW,SAASL,MAAMM,QAAQC,MAAM,GAAG,GAAA,CAAA,QAAY,EAChEF,SACC,UACA,MAAMJ,SAASO,SAASC,MAAAA,KAAWR,SAASO,SAASV,GAAAA,MACrD,IAAA,EAEDO,SACC,WACA,cACEK,KAAKC,UAAUV,SAASO,SAASI,QAAQ,MAAM,CAAA,IAC/C,SACF,IAAA,EAEDP,SACC,UACA,cACEK,KAAKC,UAAUV,SAASO,SAASK,OAAO,MAAM,CAAA,IAC9C,SACF,IAAA,EAEDR,SACC,YACA,cACEK,KAAKC,UAAUV,SAASO,SAASM,SAAS,MAAM,CAAA,IAChD,SACF,IAAA,EAEDT,SACC,SACA,cAAcK,KAAKC,UAAUV,SAASO,SAASO,MAAM,MAAM,CAAA,IAAK,OAAA,EAEjEV,SACC,gBACA,SAASL,MAAMgB,SAAS,qBAAqBT,MAAM,GAAG,GAAA,IAAO,KAAA,EAE9DU,UAAU,QAAQ,KAAKrB,QAAQsB,OAAO,aAAA,EAAe,EACrDC,aAAY;AAEf,UAAM,KAAKzB,QAAQ0B,KAAKlB,KAAAA;EAC1B;AACF;;;;;;;;","names":["Inject","token","target","_propertyKey","parameterIndex","constructor","existingInjectedParams","Reflect","getOwnMetadata","defineMetadata","DiscordNotifier","webhook","constructor","options","Webhook","url","notify","error","context","embed","MessageBuilder","setTitle","addField","message","slice","request","method","JSON","stringify","params","query","headers","body","stack","setFooter","env","setTimestamp","send"]}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { I as IErrorNotifier, C as ContextError } from '../../../base-controller-68008870.js';
|
|
2
|
-
|
|
3
|
-
type DiscordOptions = {
|
|
4
|
-
url: string;
|
|
5
|
-
env: string;
|
|
6
|
-
};
|
|
7
|
-
declare class DiscordNotifier implements IErrorNotifier {
|
|
8
|
-
private readonly options;
|
|
9
|
-
private webhook;
|
|
10
|
-
constructor(options: DiscordOptions);
|
|
11
|
-
notify(error: Error, context: ContextError): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { DiscordNotifier };
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { I as IErrorNotifier, C as ContextError } from '../../../base-controller-68008870.js';
|
|
2
|
-
|
|
3
|
-
type DiscordOptions = {
|
|
4
|
-
url: string;
|
|
5
|
-
env: string;
|
|
6
|
-
};
|
|
7
|
-
declare class DiscordNotifier implements IErrorNotifier {
|
|
8
|
-
private readonly options;
|
|
9
|
-
private webhook;
|
|
10
|
-
constructor(options: DiscordOptions);
|
|
11
|
-
notify(error: Error, context: ContextError): Promise<void>;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export { DiscordNotifier };
|
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/core/decorators/dependency-container.ts
|
|
5
|
-
import "reflect-metadata";
|
|
6
|
-
function Inject(token) {
|
|
7
|
-
return (target, _propertyKey, parameterIndex) => {
|
|
8
|
-
const constructor = typeof target === "function" ? target : target.constructor;
|
|
9
|
-
const existingInjectedParams = Reflect.getOwnMetadata("inject:params", constructor) || {};
|
|
10
|
-
existingInjectedParams[parameterIndex] = token;
|
|
11
|
-
Reflect.defineMetadata("inject:params", existingInjectedParams, constructor);
|
|
12
|
-
};
|
|
13
|
-
}
|
|
14
|
-
__name(Inject, "Inject");
|
|
15
|
-
|
|
16
|
-
// src/infra/adapters/notifications/discord.ts
|
|
17
|
-
import { MessageBuilder, Webhook } from "discord-webhook-node";
|
|
18
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
19
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
21
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
22
|
-
else
|
|
23
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
24
|
-
if (d = decorators[i])
|
|
25
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
26
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
27
|
-
}
|
|
28
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
29
|
-
function _ts_metadata(k, v) {
|
|
30
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
31
|
-
return Reflect.metadata(k, v);
|
|
32
|
-
}
|
|
33
|
-
__name(_ts_metadata, "_ts_metadata");
|
|
34
|
-
function _ts_param(paramIndex, decorator) {
|
|
35
|
-
return function(target, key) {
|
|
36
|
-
decorator(target, key, paramIndex);
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
__name(_ts_param, "_ts_param");
|
|
40
|
-
var DiscordNotifier = class {
|
|
41
|
-
static {
|
|
42
|
-
__name(this, "DiscordNotifier");
|
|
43
|
-
}
|
|
44
|
-
options;
|
|
45
|
-
webhook;
|
|
46
|
-
constructor(options) {
|
|
47
|
-
this.options = options;
|
|
48
|
-
this.webhook = new Webhook(this.options.url);
|
|
49
|
-
}
|
|
50
|
-
async notify(error, context) {
|
|
51
|
-
const embed = new MessageBuilder().setTitle("\u{1F6A8} Error").addField("Message", `\`\`\`${error.message.slice(0, 300)}\`\`\``).addField("Route:", `\`[${context?.request?.method}] ${context?.request?.url}\``, true).addField("Params:", "```json\n" + JSON.stringify(context?.request?.params, null, 2) + "\n```", true).addField("Query:", "```json\n" + JSON.stringify(context?.request?.query, null, 2) + "\n```", true).addField("Headers:", "```json\n" + JSON.stringify(context?.request?.headers, null, 2) + "\n```", true).addField("Body:", "```json\n" + JSON.stringify(context?.request?.body, null, 2) + "\n```").addField("Stack Trace:", "```" + (error.stack || "No stack provided").slice(0, 900) + "```").setFooter(`Env: ${this.options.env || "development"}`).setTimestamp();
|
|
52
|
-
await this.webhook.send(embed);
|
|
53
|
-
}
|
|
54
|
-
};
|
|
55
|
-
DiscordNotifier = _ts_decorate([
|
|
56
|
-
_ts_param(0, Inject("DiscordConfig")),
|
|
57
|
-
_ts_metadata("design:type", Function),
|
|
58
|
-
_ts_metadata("design:paramtypes", [
|
|
59
|
-
typeof DiscordOptions === "undefined" ? Object : DiscordOptions
|
|
60
|
-
])
|
|
61
|
-
], DiscordNotifier);
|
|
62
|
-
export {
|
|
63
|
-
DiscordNotifier
|
|
64
|
-
};
|
|
65
|
-
//# sourceMappingURL=discord.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/core/decorators/dependency-container.ts","../../../../src/infra/adapters/notifications/discord.ts"],"sourcesContent":["import 'reflect-metadata'\n\ntype Class<T = any> = new (...args: any[]) => T\n\ntype Registration =\n | { type: 'class'; myClass: Class; singleton: boolean }\n | { type: 'value'; value: any }\n\nexport class DependencyContainer {\n static registry = new Map<string, Registration>()\n static singletons = new Map<string, any>()\n\n static register<T>(\n token: string,\n myClass: Class<T>,\n options: { singleton: boolean }\n ) {\n this.registry.set(token, {\n type: 'class',\n myClass,\n singleton: options.singleton,\n })\n }\n\n static registerValue<T>(token: string, value: T) {\n this.registry.set(token, { type: 'value', value })\n }\n\n static resolve<T>(target: Class<T>): T {\n const injectMetadata: Record<number, string> =\n Reflect.getOwnMetadata('inject:params', target) || {}\n\n const paramCount = Object.keys(injectMetadata).length\n\n const params = Array.from({ length: paramCount }, (_, index) => {\n const token = injectMetadata[index]\n if (!token) {\n throw new Error(\n `Missing @Inject token for parameter index ${index} in ${target.name}`\n )\n }\n return this.resolveToken(token)\n })\n\n return new target(...params)\n }\n\n static resolveToken(token: string): any {\n const registration = this.registry.get(token)\n\n if (!registration) {\n throw new Error(\n `\"${token}\" not registered. Please register it in the container.`\n )\n }\n\n if (registration.type === 'value') {\n return registration.value\n }\n\n const { myClass, singleton } = registration\n\n if (singleton) {\n if (!this.singletons.has(token)) {\n const instance = this.resolve(myClass)\n this.singletons.set(token, instance)\n }\n return this.singletons.get(token)\n }\n\n return this.resolve(myClass)\n }\n}\n\nexport function Inject(token: string): ParameterDecorator {\n return (\n target: object,\n _propertyKey: string | symbol | undefined,\n parameterIndex: number\n ): void => {\n const constructor =\n typeof target === 'function' ? target : target.constructor\n\n const existingInjectedParams: Record<number, string> =\n Reflect.getOwnMetadata('inject:params', constructor) || {}\n\n existingInjectedParams[parameterIndex] = token\n\n Reflect.defineMetadata('inject:params', existingInjectedParams, constructor)\n }\n}\n","import { Inject } from 'core/decorators/dependency-container'\nimport { MessageBuilder, Webhook } from 'discord-webhook-node'\n\nimport type { ContextError } from '../../../core/http/base-controller'\nimport type { IErrorNotifier } from '../../../core/http/error-notifier'\n\ntype DiscordOptions = {\n url: string\n env: string\n}\n\nexport class DiscordNotifier implements IErrorNotifier {\n private webhook: Webhook\n\n constructor(\n @Inject('DiscordConfig') private readonly options: DiscordOptions\n ) {\n this.webhook = new Webhook(this.options.url)\n }\n\n async notify(error: Error, context: ContextError): Promise<void> {\n const embed = new MessageBuilder()\n .setTitle('🚨 Error')\n .addField('Message', `\\`\\`\\`${error.message.slice(0, 300)}\\`\\`\\``)\n .addField(\n 'Route:',\n `\\`[${context?.request?.method}] ${context?.request?.url}\\``,\n true\n )\n .addField(\n 'Params:',\n '```json\\n' +\n JSON.stringify(context?.request?.params, null, 2) +\n '\\n```',\n true\n )\n .addField(\n 'Query:',\n '```json\\n' +\n JSON.stringify(context?.request?.query, null, 2) +\n '\\n```',\n true\n )\n .addField(\n 'Headers:',\n '```json\\n' +\n JSON.stringify(context?.request?.headers, null, 2) +\n '\\n```',\n true\n )\n .addField(\n 'Body:',\n '```json\\n' + JSON.stringify(context?.request?.body, null, 2) + '\\n```'\n )\n .addField(\n 'Stack Trace:',\n '```' + (error.stack || 'No stack provided').slice(0, 900) + '```'\n )\n .setFooter(`Env: ${this.options.env || 'development'}`)\n .setTimestamp()\n\n await this.webhook.send(embed)\n }\n}\n"],"mappings":";;;;AAAA,OAAO;AA0EA,SAASA,OAAOC,OAAa;AAClC,SAAO,CACLC,QACAC,cACAC,mBAAAA;AAEA,UAAMC,cACJ,OAAOH,WAAW,aAAaA,SAASA,OAAOG;AAEjD,UAAMC,yBACJC,QAAQC,eAAe,iBAAiBH,WAAAA,KAAgB,CAAC;AAE3DC,2BAAuBF,cAAAA,IAAkBH;AAEzCM,YAAQE,eAAe,iBAAiBH,wBAAwBD,WAAAA;EAClE;AACF;AAhBgBL;;;ACzEhB,SAASU,gBAAgBC,eAAe;;;;;;;;;;;;;;;;;;;;;;;AAUjC,IAAMC,kBAAN,MAAMA;SAAAA;;;;EACHC;EAERC,YAC4CC,SAC1C;SAD0CA,UAAAA;AAE1C,SAAKF,UAAU,IAAIG,QAAQ,KAAKD,QAAQE,GAAG;EAC7C;EAEA,MAAMC,OAAOC,OAAcC,SAAsC;AAC/D,UAAMC,QAAQ,IAAIC,eAAAA,EACfC,SAAS,iBAAA,EACTC,SAAS,WAAW,SAASL,MAAMM,QAAQC,MAAM,GAAG,GAAA,CAAA,QAAY,EAChEF,SACC,UACA,MAAMJ,SAASO,SAASC,MAAAA,KAAWR,SAASO,SAASV,GAAAA,MACrD,IAAA,EAEDO,SACC,WACA,cACEK,KAAKC,UAAUV,SAASO,SAASI,QAAQ,MAAM,CAAA,IAC/C,SACF,IAAA,EAEDP,SACC,UACA,cACEK,KAAKC,UAAUV,SAASO,SAASK,OAAO,MAAM,CAAA,IAC9C,SACF,IAAA,EAEDR,SACC,YACA,cACEK,KAAKC,UAAUV,SAASO,SAASM,SAAS,MAAM,CAAA,IAChD,SACF,IAAA,EAEDT,SACC,SACA,cAAcK,KAAKC,UAAUV,SAASO,SAASO,MAAM,MAAM,CAAA,IAAK,OAAA,EAEjEV,SACC,gBACA,SAASL,MAAMgB,SAAS,qBAAqBT,MAAM,GAAG,GAAA,IAAO,KAAA,EAE9DU,UAAU,QAAQ,KAAKrB,QAAQsB,OAAO,aAAA,EAAe,EACrDC,aAAY;AAEf,UAAM,KAAKzB,QAAQ0B,KAAKlB,KAAAA;EAC1B;AACF;;;;;;;;","names":["Inject","token","target","_propertyKey","parameterIndex","constructor","existingInjectedParams","Reflect","getOwnMetadata","defineMetadata","MessageBuilder","Webhook","DiscordNotifier","webhook","constructor","options","Webhook","url","notify","error","context","embed","MessageBuilder","setTitle","addField","message","slice","request","method","JSON","stringify","params","query","headers","body","stack","setFooter","env","setTimestamp","send"]}
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __defProp = Object.defineProperty;
|
|
3
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
|
-
var __export = (target, all) => {
|
|
8
|
-
for (var name in all)
|
|
9
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
-
};
|
|
11
|
-
var __copyProps = (to, from, except, desc) => {
|
|
12
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
-
for (let key of __getOwnPropNames(from))
|
|
14
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
-
}
|
|
17
|
-
return to;
|
|
18
|
-
};
|
|
19
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
|
-
|
|
21
|
-
// src/infra/adapters/notifications/in-memory.ts
|
|
22
|
-
var in_memory_exports = {};
|
|
23
|
-
__export(in_memory_exports, {
|
|
24
|
-
NotificationErrorInMemory: () => NotificationErrorInMemory
|
|
25
|
-
});
|
|
26
|
-
module.exports = __toCommonJS(in_memory_exports);
|
|
27
|
-
var NotificationErrorInMemory = class {
|
|
28
|
-
static {
|
|
29
|
-
__name(this, "NotificationErrorInMemory");
|
|
30
|
-
}
|
|
31
|
-
errors = [];
|
|
32
|
-
async notify(error, context) {
|
|
33
|
-
console.log("NOTIFICATION ERROR: ", error);
|
|
34
|
-
this.errors.push({
|
|
35
|
-
error: error.message,
|
|
36
|
-
context
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
};
|
|
40
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
41
|
-
0 && (module.exports = {
|
|
42
|
-
NotificationErrorInMemory
|
|
43
|
-
});
|
|
44
|
-
//# sourceMappingURL=in-memory.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/infra/adapters/notifications/in-memory.ts"],"sourcesContent":["import type { ContextError } from '../../../core/http/base-controller'\nimport type { IErrorNotifier } from '../../../core/http/error-notifier'\n\nexport class NotificationErrorInMemory implements IErrorNotifier {\n public errors: any[] = []\n\n async notify(error: Error, context?: ContextError): Promise<void> {\n console.log('NOTIFICATION ERROR: ', error)\n\n this.errors.push({\n error: error.message,\n context,\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAGA;;;;;AAAO,IAAMA,4BAAN,MAAMA;EAAb,OAAaA;;;EACJC,SAAgB,CAAA;EAEvB,MAAMC,OAAOC,OAAcC,SAAuC;AAChEC,YAAQC,IAAI,wBAAwBH,KAAAA;AAEpC,SAAKF,OAAOM,KAAK;MACfJ,OAAOA,MAAMK;MACbJ;IACF,CAAA;EACF;AACF;","names":["NotificationErrorInMemory","errors","notify","error","context","console","log","push","message"]}
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { I as IErrorNotifier, C as ContextError } from '../../../base-controller-68008870.js';
|
|
2
|
-
|
|
3
|
-
declare class NotificationErrorInMemory implements IErrorNotifier {
|
|
4
|
-
errors: any[];
|
|
5
|
-
notify(error: Error, context?: ContextError): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export { NotificationErrorInMemory };
|
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
import { I as IErrorNotifier, C as ContextError } from '../../../base-controller-68008870.js';
|
|
2
|
-
|
|
3
|
-
declare class NotificationErrorInMemory implements IErrorNotifier {
|
|
4
|
-
errors: any[];
|
|
5
|
-
notify(error: Error, context?: ContextError): Promise<void>;
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
export { NotificationErrorInMemory };
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
var __defProp = Object.defineProperty;
|
|
2
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
|
-
|
|
4
|
-
// src/infra/adapters/notifications/in-memory.ts
|
|
5
|
-
var NotificationErrorInMemory = class {
|
|
6
|
-
static {
|
|
7
|
-
__name(this, "NotificationErrorInMemory");
|
|
8
|
-
}
|
|
9
|
-
errors = [];
|
|
10
|
-
async notify(error, context) {
|
|
11
|
-
console.log("NOTIFICATION ERROR: ", error);
|
|
12
|
-
this.errors.push({
|
|
13
|
-
error: error.message,
|
|
14
|
-
context
|
|
15
|
-
});
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
export {
|
|
19
|
-
NotificationErrorInMemory
|
|
20
|
-
};
|
|
21
|
-
//# sourceMappingURL=in-memory.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/infra/adapters/notifications/in-memory.ts"],"sourcesContent":["import type { ContextError } from '../../../core/http/base-controller'\nimport type { IErrorNotifier } from '../../../core/http/error-notifier'\n\nexport class NotificationErrorInMemory implements IErrorNotifier {\n public errors: any[] = []\n\n async notify(error: Error, context?: ContextError): Promise<void> {\n console.log('NOTIFICATION ERROR: ', error)\n\n this.errors.push({\n error: error.message,\n context,\n })\n }\n}\n"],"mappings":";;;;AAGO,IAAMA,4BAAN,MAAMA;EAAb,OAAaA;;;EACJC,SAAgB,CAAA;EAEvB,MAAMC,OAAOC,OAAcC,SAAuC;AAChEC,YAAQC,IAAI,wBAAwBH,KAAAA;AAEpC,SAAKF,OAAOM,KAAK;MACfJ,OAAOA,MAAMK;MACbJ;IACF,CAAA;EACF;AACF;","names":["NotificationErrorInMemory","errors","notify","error","context","console","log","push","message"]}
|
|
@@ -1,219 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __create = Object.create;
|
|
3
|
-
var __defProp = Object.defineProperty;
|
|
4
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
5
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
-
var __getProtoOf = Object.getPrototypeOf;
|
|
7
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
8
|
-
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
9
|
-
var __export = (target, all) => {
|
|
10
|
-
for (var name in all)
|
|
11
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
12
|
-
};
|
|
13
|
-
var __copyProps = (to, from, except, desc) => {
|
|
14
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
15
|
-
for (let key of __getOwnPropNames(from))
|
|
16
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
17
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
|
-
}
|
|
19
|
-
return to;
|
|
20
|
-
};
|
|
21
|
-
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
22
|
-
// If the importer is in node compatibility mode or this is not an ESM
|
|
23
|
-
// file that has been converted to a CommonJS file using a Babel-
|
|
24
|
-
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
25
|
-
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
26
|
-
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
27
|
-
mod
|
|
28
|
-
));
|
|
29
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
30
|
-
|
|
31
|
-
// src/infra/adapters/notifications/notification-factory.ts
|
|
32
|
-
var notification_factory_exports = {};
|
|
33
|
-
__export(notification_factory_exports, {
|
|
34
|
-
NotificationFactory: () => NotificationFactory
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(notification_factory_exports);
|
|
37
|
-
|
|
38
|
-
// src/core/decorators/dependency-container.ts
|
|
39
|
-
var import_reflect_metadata = require("reflect-metadata");
|
|
40
|
-
function Inject(token) {
|
|
41
|
-
return (target, _propertyKey, parameterIndex) => {
|
|
42
|
-
const constructor = typeof target === "function" ? target : target.constructor;
|
|
43
|
-
const existingInjectedParams = Reflect.getOwnMetadata("inject:params", constructor) || {};
|
|
44
|
-
existingInjectedParams[parameterIndex] = token;
|
|
45
|
-
Reflect.defineMetadata("inject:params", existingInjectedParams, constructor);
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
__name(Inject, "Inject");
|
|
49
|
-
|
|
50
|
-
// src/infra/adapters/notifications/discord.ts
|
|
51
|
-
var import_discord_webhook_node = require("discord-webhook-node");
|
|
52
|
-
function _ts_decorate(decorators, target, key, desc) {
|
|
53
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
54
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
55
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
56
|
-
else
|
|
57
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
58
|
-
if (d = decorators[i])
|
|
59
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
60
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
61
|
-
}
|
|
62
|
-
__name(_ts_decorate, "_ts_decorate");
|
|
63
|
-
function _ts_metadata(k, v) {
|
|
64
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
65
|
-
return Reflect.metadata(k, v);
|
|
66
|
-
}
|
|
67
|
-
__name(_ts_metadata, "_ts_metadata");
|
|
68
|
-
function _ts_param(paramIndex, decorator) {
|
|
69
|
-
return function(target, key) {
|
|
70
|
-
decorator(target, key, paramIndex);
|
|
71
|
-
};
|
|
72
|
-
}
|
|
73
|
-
__name(_ts_param, "_ts_param");
|
|
74
|
-
var DiscordNotifier = class {
|
|
75
|
-
static {
|
|
76
|
-
__name(this, "DiscordNotifier");
|
|
77
|
-
}
|
|
78
|
-
options;
|
|
79
|
-
webhook;
|
|
80
|
-
constructor(options) {
|
|
81
|
-
this.options = options;
|
|
82
|
-
this.webhook = new import_discord_webhook_node.Webhook(this.options.url);
|
|
83
|
-
}
|
|
84
|
-
async notify(error, context) {
|
|
85
|
-
const embed = new import_discord_webhook_node.MessageBuilder().setTitle("\u{1F6A8} Error").addField("Message", `\`\`\`${error.message.slice(0, 300)}\`\`\``).addField("Route:", `\`[${context?.request?.method}] ${context?.request?.url}\``, true).addField("Params:", "```json\n" + JSON.stringify(context?.request?.params, null, 2) + "\n```", true).addField("Query:", "```json\n" + JSON.stringify(context?.request?.query, null, 2) + "\n```", true).addField("Headers:", "```json\n" + JSON.stringify(context?.request?.headers, null, 2) + "\n```", true).addField("Body:", "```json\n" + JSON.stringify(context?.request?.body, null, 2) + "\n```").addField("Stack Trace:", "```" + (error.stack || "No stack provided").slice(0, 900) + "```").setFooter(`Env: ${this.options.env || "development"}`).setTimestamp();
|
|
86
|
-
await this.webhook.send(embed);
|
|
87
|
-
}
|
|
88
|
-
};
|
|
89
|
-
DiscordNotifier = _ts_decorate([
|
|
90
|
-
_ts_param(0, Inject("DiscordConfig")),
|
|
91
|
-
_ts_metadata("design:type", Function),
|
|
92
|
-
_ts_metadata("design:paramtypes", [
|
|
93
|
-
typeof DiscordOptions === "undefined" ? Object : DiscordOptions
|
|
94
|
-
])
|
|
95
|
-
], DiscordNotifier);
|
|
96
|
-
|
|
97
|
-
// src/infra/adapters/notifications/in-memory.ts
|
|
98
|
-
var NotificationErrorInMemory = class {
|
|
99
|
-
static {
|
|
100
|
-
__name(this, "NotificationErrorInMemory");
|
|
101
|
-
}
|
|
102
|
-
errors = [];
|
|
103
|
-
async notify(error, context) {
|
|
104
|
-
console.log("NOTIFICATION ERROR: ", error);
|
|
105
|
-
this.errors.push({
|
|
106
|
-
error: error.message,
|
|
107
|
-
context
|
|
108
|
-
});
|
|
109
|
-
}
|
|
110
|
-
};
|
|
111
|
-
|
|
112
|
-
// src/infra/adapters/notifications/sentry.ts
|
|
113
|
-
var Sentry = __toESM(require("@sentry/node"), 1);
|
|
114
|
-
function _ts_decorate2(decorators, target, key, desc) {
|
|
115
|
-
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
116
|
-
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
|
|
117
|
-
r = Reflect.decorate(decorators, target, key, desc);
|
|
118
|
-
else
|
|
119
|
-
for (var i = decorators.length - 1; i >= 0; i--)
|
|
120
|
-
if (d = decorators[i])
|
|
121
|
-
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
122
|
-
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
123
|
-
}
|
|
124
|
-
__name(_ts_decorate2, "_ts_decorate");
|
|
125
|
-
function _ts_metadata2(k, v) {
|
|
126
|
-
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
|
|
127
|
-
return Reflect.metadata(k, v);
|
|
128
|
-
}
|
|
129
|
-
__name(_ts_metadata2, "_ts_metadata");
|
|
130
|
-
function _ts_param2(paramIndex, decorator) {
|
|
131
|
-
return function(target, key) {
|
|
132
|
-
decorator(target, key, paramIndex);
|
|
133
|
-
};
|
|
134
|
-
}
|
|
135
|
-
__name(_ts_param2, "_ts_param");
|
|
136
|
-
var SentryNotifier = class {
|
|
137
|
-
static {
|
|
138
|
-
__name(this, "SentryNotifier");
|
|
139
|
-
}
|
|
140
|
-
options;
|
|
141
|
-
constructor(options) {
|
|
142
|
-
this.options = options;
|
|
143
|
-
Sentry.init({
|
|
144
|
-
dsn: this.options.dsn,
|
|
145
|
-
environment: this.options.environment,
|
|
146
|
-
attachStacktrace: true,
|
|
147
|
-
tracesSampleRate: this.options.environment === "production" ? 0.1 : 1,
|
|
148
|
-
maxBreadcrumbs: 100,
|
|
149
|
-
debug: this.options.environment !== "production"
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
async notify(error, context) {
|
|
153
|
-
Sentry.withScope((scope) => {
|
|
154
|
-
scope.setLevel("error");
|
|
155
|
-
if (context?.env)
|
|
156
|
-
scope.setTag("env", context.env);
|
|
157
|
-
if (context?.user) {
|
|
158
|
-
scope.setUser({
|
|
159
|
-
id: context.user.id,
|
|
160
|
-
username: context.user.name,
|
|
161
|
-
email: context.user.email
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
|
-
if (context?.request) {
|
|
165
|
-
const { body, query, params, headers, method, url, requestId } = context.request;
|
|
166
|
-
scope.setContext("http", {
|
|
167
|
-
method,
|
|
168
|
-
requestId,
|
|
169
|
-
url,
|
|
170
|
-
headers,
|
|
171
|
-
query,
|
|
172
|
-
body,
|
|
173
|
-
params
|
|
174
|
-
});
|
|
175
|
-
}
|
|
176
|
-
Sentry.captureException(error);
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
};
|
|
180
|
-
SentryNotifier = _ts_decorate2([
|
|
181
|
-
_ts_param2(0, Inject("SentryConfig")),
|
|
182
|
-
_ts_metadata2("design:type", Function),
|
|
183
|
-
_ts_metadata2("design:paramtypes", [
|
|
184
|
-
typeof SentryOptions === "undefined" ? Object : SentryOptions
|
|
185
|
-
])
|
|
186
|
-
], SentryNotifier);
|
|
187
|
-
|
|
188
|
-
// src/infra/adapters/notifications/notification-factory.ts
|
|
189
|
-
var NotificationFactory = class {
|
|
190
|
-
static {
|
|
191
|
-
__name(this, "NotificationFactory");
|
|
192
|
-
}
|
|
193
|
-
static define(env, definitions) {
|
|
194
|
-
const defaultDefinition = {
|
|
195
|
-
test: this.defineProvider(definitions?.local ?? "console"),
|
|
196
|
-
development: this.defineProvider(definitions?.local ?? "console"),
|
|
197
|
-
staging: this.defineProvider(definitions?.local ?? "discord"),
|
|
198
|
-
production: this.defineProvider(definitions?.local ?? "sentry")
|
|
199
|
-
};
|
|
200
|
-
return defaultDefinition[env];
|
|
201
|
-
}
|
|
202
|
-
static defineProvider(provider) {
|
|
203
|
-
switch (provider) {
|
|
204
|
-
case "console":
|
|
205
|
-
return NotificationErrorInMemory;
|
|
206
|
-
case "discord":
|
|
207
|
-
return DiscordNotifier;
|
|
208
|
-
case "sentry":
|
|
209
|
-
return SentryNotifier;
|
|
210
|
-
default:
|
|
211
|
-
return NotificationErrorInMemory;
|
|
212
|
-
}
|
|
213
|
-
}
|
|
214
|
-
};
|
|
215
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
216
|
-
0 && (module.exports = {
|
|
217
|
-
NotificationFactory
|
|
218
|
-
});
|
|
219
|
-
//# sourceMappingURL=notification-factory.cjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../src/infra/adapters/notifications/notification-factory.ts","../../../../src/core/decorators/dependency-container.ts","../../../../src/infra/adapters/notifications/discord.ts","../../../../src/infra/adapters/notifications/in-memory.ts","../../../../src/infra/adapters/notifications/sentry.ts"],"sourcesContent":["import type { z } from 'zod'\n\nimport type { baseEnvSchema } from '../../env'\n\nimport { DiscordNotifier } from './discord'\nimport { NotificationErrorInMemory } from './in-memory'\nimport { SentryNotifier } from './sentry'\n\ntype OptionsNotifications = 'console' | 'discord' | 'sentry'\ntype EnvironmentEnum = z.infer<typeof baseEnvSchema>['ENVIRONMENT']\n\ntype Props = {\n local?: OptionsNotifications\n test?: OptionsNotifications\n development?: OptionsNotifications\n staging?: OptionsNotifications\n production?: OptionsNotifications\n}\n\nexport class NotificationFactory {\n static define(env: EnvironmentEnum, definitions?: Props): any {\n const defaultDefinition = {\n test: this.defineProvider(definitions?.local ?? 'console'),\n development: this.defineProvider(definitions?.local ?? 'console'),\n staging: this.defineProvider(definitions?.local ?? 'discord'),\n production: this.defineProvider(definitions?.local ?? 'sentry'),\n }\n\n return defaultDefinition[env]\n }\n\n private static defineProvider(provider: OptionsNotifications) {\n switch (provider) {\n case 'console':\n return NotificationErrorInMemory\n case 'discord':\n return DiscordNotifier\n case 'sentry':\n return SentryNotifier\n default:\n return NotificationErrorInMemory\n }\n }\n}\n","import 'reflect-metadata'\n\ntype Class<T = any> = new (...args: any[]) => T\n\ntype Registration =\n | { type: 'class'; myClass: Class; singleton: boolean }\n | { type: 'value'; value: any }\n\nexport class DependencyContainer {\n static registry = new Map<string, Registration>()\n static singletons = new Map<string, any>()\n\n static register<T>(\n token: string,\n myClass: Class<T>,\n options: { singleton: boolean }\n ) {\n this.registry.set(token, {\n type: 'class',\n myClass,\n singleton: options.singleton,\n })\n }\n\n static registerValue<T>(token: string, value: T) {\n this.registry.set(token, { type: 'value', value })\n }\n\n static resolve<T>(target: Class<T>): T {\n const injectMetadata: Record<number, string> =\n Reflect.getOwnMetadata('inject:params', target) || {}\n\n const paramCount = Object.keys(injectMetadata).length\n\n const params = Array.from({ length: paramCount }, (_, index) => {\n const token = injectMetadata[index]\n if (!token) {\n throw new Error(\n `Missing @Inject token for parameter index ${index} in ${target.name}`\n )\n }\n return this.resolveToken(token)\n })\n\n return new target(...params)\n }\n\n static resolveToken(token: string): any {\n const registration = this.registry.get(token)\n\n if (!registration) {\n throw new Error(\n `\"${token}\" not registered. Please register it in the container.`\n )\n }\n\n if (registration.type === 'value') {\n return registration.value\n }\n\n const { myClass, singleton } = registration\n\n if (singleton) {\n if (!this.singletons.has(token)) {\n const instance = this.resolve(myClass)\n this.singletons.set(token, instance)\n }\n return this.singletons.get(token)\n }\n\n return this.resolve(myClass)\n }\n}\n\nexport function Inject(token: string): ParameterDecorator {\n return (\n target: object,\n _propertyKey: string | symbol | undefined,\n parameterIndex: number\n ): void => {\n const constructor =\n typeof target === 'function' ? target : target.constructor\n\n const existingInjectedParams: Record<number, string> =\n Reflect.getOwnMetadata('inject:params', constructor) || {}\n\n existingInjectedParams[parameterIndex] = token\n\n Reflect.defineMetadata('inject:params', existingInjectedParams, constructor)\n }\n}\n","import { Inject } from 'core/decorators/dependency-container'\nimport { MessageBuilder, Webhook } from 'discord-webhook-node'\n\nimport type { ContextError } from '../../../core/http/base-controller'\nimport type { IErrorNotifier } from '../../../core/http/error-notifier'\n\ntype DiscordOptions = {\n url: string\n env: string\n}\n\nexport class DiscordNotifier implements IErrorNotifier {\n private webhook: Webhook\n\n constructor(\n @Inject('DiscordConfig') private readonly options: DiscordOptions\n ) {\n this.webhook = new Webhook(this.options.url)\n }\n\n async notify(error: Error, context: ContextError): Promise<void> {\n const embed = new MessageBuilder()\n .setTitle('🚨 Error')\n .addField('Message', `\\`\\`\\`${error.message.slice(0, 300)}\\`\\`\\``)\n .addField(\n 'Route:',\n `\\`[${context?.request?.method}] ${context?.request?.url}\\``,\n true\n )\n .addField(\n 'Params:',\n '```json\\n' +\n JSON.stringify(context?.request?.params, null, 2) +\n '\\n```',\n true\n )\n .addField(\n 'Query:',\n '```json\\n' +\n JSON.stringify(context?.request?.query, null, 2) +\n '\\n```',\n true\n )\n .addField(\n 'Headers:',\n '```json\\n' +\n JSON.stringify(context?.request?.headers, null, 2) +\n '\\n```',\n true\n )\n .addField(\n 'Body:',\n '```json\\n' + JSON.stringify(context?.request?.body, null, 2) + '\\n```'\n )\n .addField(\n 'Stack Trace:',\n '```' + (error.stack || 'No stack provided').slice(0, 900) + '```'\n )\n .setFooter(`Env: ${this.options.env || 'development'}`)\n .setTimestamp()\n\n await this.webhook.send(embed)\n }\n}\n","import type { ContextError } from '../../../core/http/base-controller'\nimport type { IErrorNotifier } from '../../../core/http/error-notifier'\n\nexport class NotificationErrorInMemory implements IErrorNotifier {\n public errors: any[] = []\n\n async notify(error: Error, context?: ContextError): Promise<void> {\n console.log('NOTIFICATION ERROR: ', error)\n\n this.errors.push({\n error: error.message,\n context,\n })\n }\n}\n","import * as Sentry from '@sentry/node'\nimport type { ContextError } from 'core/http/base-controller'\n\nimport { Inject } from '../../../core/decorators/dependency-container'\nimport { IErrorNotifier } from '../../../core/http/error-notifier'\n\ntype SentryOptions = {\n dsn: string\n environment: string\n}\n\nexport class SentryNotifier implements IErrorNotifier {\n constructor(@Inject('SentryConfig') private readonly options: SentryOptions) {\n Sentry.init({\n dsn: this.options.dsn,\n environment: this.options.environment,\n attachStacktrace: true,\n tracesSampleRate: this.options.environment === 'production' ? 0.1 : 1.0,\n maxBreadcrumbs: 100,\n debug: this.options.environment !== 'production',\n })\n }\n\n async notify(error: Error, context: ContextError): Promise<void> {\n Sentry.withScope((scope) => {\n scope.setLevel('error')\n\n if (context?.env) scope.setTag('env', context.env)\n\n if (context?.user) {\n scope.setUser({\n id: context.user.id,\n username: context.user.name,\n email: context.user.email,\n })\n }\n\n if (context?.request) {\n const { body, query, params, headers, method, url, requestId } =\n context.request\n\n scope.setContext('http', {\n method,\n requestId,\n url,\n headers,\n query,\n body,\n params,\n })\n }\n\n Sentry.captureException(error)\n })\n }\n}\n"],"mappings":"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","names":["Inject","token","target","_propertyKey","parameterIndex","constructor","existingInjectedParams","Reflect","getOwnMetadata","defineMetadata","DiscordNotifier","webhook","constructor","options","Webhook","url","notify","error","context","embed","MessageBuilder","setTitle","addField","message","slice","request","method","JSON","stringify","params","query","headers","body","stack","setFooter","env","setTimestamp","send","NotificationErrorInMemory","errors","notify","error","context","console","log","push","message","SentryNotifier","constructor","options","Sentry","init","dsn","environment","attachStacktrace","tracesSampleRate","maxBreadcrumbs","debug","notify","error","context","withScope","scope","setLevel","env","setTag","user","setUser","id","username","name","email","request","body","query","params","headers","method","url","requestId","setContext","captureException","NotificationFactory","define","env","definitions","defaultDefinition","test","defineProvider","local","development","staging","production","provider","NotificationErrorInMemory","DiscordNotifier","SentryNotifier"]}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { baseEnvSchema } from '../../env/index.cjs';
|
|
3
|
-
|
|
4
|
-
type OptionsNotifications = 'console' | 'discord' | 'sentry';
|
|
5
|
-
type EnvironmentEnum = z.infer<typeof baseEnvSchema>['ENVIRONMENT'];
|
|
6
|
-
type Props = {
|
|
7
|
-
local?: OptionsNotifications;
|
|
8
|
-
test?: OptionsNotifications;
|
|
9
|
-
development?: OptionsNotifications;
|
|
10
|
-
staging?: OptionsNotifications;
|
|
11
|
-
production?: OptionsNotifications;
|
|
12
|
-
};
|
|
13
|
-
declare class NotificationFactory {
|
|
14
|
-
static define(env: EnvironmentEnum, definitions?: Props): any;
|
|
15
|
-
private static defineProvider;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { NotificationFactory };
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { z } from 'zod';
|
|
2
|
-
import { baseEnvSchema } from '../../env/index.js';
|
|
3
|
-
|
|
4
|
-
type OptionsNotifications = 'console' | 'discord' | 'sentry';
|
|
5
|
-
type EnvironmentEnum = z.infer<typeof baseEnvSchema>['ENVIRONMENT'];
|
|
6
|
-
type Props = {
|
|
7
|
-
local?: OptionsNotifications;
|
|
8
|
-
test?: OptionsNotifications;
|
|
9
|
-
development?: OptionsNotifications;
|
|
10
|
-
staging?: OptionsNotifications;
|
|
11
|
-
production?: OptionsNotifications;
|
|
12
|
-
};
|
|
13
|
-
declare class NotificationFactory {
|
|
14
|
-
static define(env: EnvironmentEnum, definitions?: Props): any;
|
|
15
|
-
private static defineProvider;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
export { NotificationFactory };
|