@meghjs/core 0.6.0 → 0.6.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/README.md +62 -15
- package/dist/core/application.d.ts +50 -0
- package/dist/core/application.js +105 -0
- package/dist/core/application.js.map +1 -1
- package/dist/core/interfaces.d.ts +10 -0
- package/dist/core/router.d.ts +28 -0
- package/dist/core/router.js +26 -1
- package/dist/core/router.js.map +1 -1
- package/dist/core/types.d.ts +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/mail/config.d.ts +141 -0
- package/dist/mail/config.js +199 -0
- package/dist/mail/config.js.map +1 -0
- package/dist/mail/errors.d.ts +4 -0
- package/dist/mail/errors.js +12 -0
- package/dist/mail/errors.js.map +1 -0
- package/dist/mail/http-transports.d.ts +44 -0
- package/dist/mail/http-transports.js +319 -0
- package/dist/mail/http-transports.js.map +1 -0
- package/dist/mail/index.d.ts +8 -0
- package/dist/mail/index.js +46 -0
- package/dist/mail/index.js.map +1 -0
- package/dist/mail/mailable.d.ts +34 -0
- package/dist/mail/mailable.js +38 -0
- package/dist/mail/mailable.js.map +1 -0
- package/dist/mail/mailer.d.ts +208 -0
- package/dist/mail/mailer.js +502 -0
- package/dist/mail/mailer.js.map +1 -0
- package/dist/mail/queue.d.ts +32 -0
- package/dist/mail/queue.js +59 -0
- package/dist/mail/queue.js.map +1 -0
- package/dist/mail/transports.d.ts +37 -0
- package/dist/mail/transports.js +152 -0
- package/dist/mail/transports.js.map +1 -0
- package/dist/mail/types.d.ts +95 -0
- package/dist/mail/types.js +3 -0
- package/dist/mail/types.js.map +1 -0
- package/dist/security/headers.d.ts +65 -0
- package/dist/security/headers.js +148 -0
- package/dist/security/headers.js.map +1 -0
- package/dist/security/index.d.ts +3 -0
- package/dist/security/index.js +5 -0
- package/dist/security/index.js.map +1 -1
- package/dist/security/rate-limit.d.ts +129 -0
- package/dist/security/rate-limit.js +260 -0
- package/dist/security/rate-limit.js.map +1 -0
- package/package.json +10 -13
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.RedisRateLimitStore = exports.MemoryRateLimitStore = exports.RATE_LIMIT_META_KEY = exports.RATE_LIMIT_CONFIG_KEY = void 0;
|
|
4
|
+
exports.parseWindow = parseWindow;
|
|
5
|
+
exports.RateLimit = RateLimit;
|
|
6
|
+
exports.assertRouteRateLimit = assertRouteRateLimit;
|
|
7
|
+
exports.getDeclaredRateLimit = getDeclaredRateLimit;
|
|
8
|
+
exports.installRateLimit = installRateLimit;
|
|
9
|
+
const http_exceptions_1 = require("../errors/http-exceptions");
|
|
10
|
+
const health_1 = require("../observability/health");
|
|
11
|
+
const internal_logger_1 = require("../observability/internal-logger");
|
|
12
|
+
/** Route config key holding a route's own limit, or `false` to skip limiting. */
|
|
13
|
+
exports.RATE_LIMIT_CONFIG_KEY = "meghRateLimit";
|
|
14
|
+
/** Metadata key for `@RateLimit()`. */
|
|
15
|
+
exports.RATE_LIMIT_META_KEY = "megh:rate-limit";
|
|
16
|
+
const DEFAULT_MAX = 100;
|
|
17
|
+
const DEFAULT_WINDOW_MS = 60_000;
|
|
18
|
+
const DEFAULT_MESSAGE = "Too many requests, please try again later.";
|
|
19
|
+
const UNITS = {
|
|
20
|
+
ms: 1,
|
|
21
|
+
millisecond: 1,
|
|
22
|
+
s: 1000,
|
|
23
|
+
sec: 1000,
|
|
24
|
+
second: 1000,
|
|
25
|
+
m: 60_000,
|
|
26
|
+
min: 60_000,
|
|
27
|
+
minute: 60_000,
|
|
28
|
+
h: 3_600_000,
|
|
29
|
+
hour: 3_600_000,
|
|
30
|
+
d: 86_400_000,
|
|
31
|
+
day: 86_400_000,
|
|
32
|
+
};
|
|
33
|
+
/** Milliseconds in a window given as a number or a duration string. */
|
|
34
|
+
function parseWindow(window) {
|
|
35
|
+
let ms;
|
|
36
|
+
if (typeof window === "number") {
|
|
37
|
+
ms = window;
|
|
38
|
+
}
|
|
39
|
+
else {
|
|
40
|
+
const match = /^\s*(\d+(?:\.\d+)?)\s*([a-z]+)\s*$/i.exec(window);
|
|
41
|
+
const name = match?.[2].toLowerCase() ?? "";
|
|
42
|
+
// "ms" and "s" are units; otherwise allow a plural ("minutes").
|
|
43
|
+
const unit = UNITS[name] ?? UNITS[name.replace(/s$/, "")];
|
|
44
|
+
ms = match && unit ? Number(match[1]) * unit : NaN;
|
|
45
|
+
}
|
|
46
|
+
if (!Number.isFinite(ms) || ms < 1) {
|
|
47
|
+
throw new TypeError(`[Megh] Invalid rate limit window ${JSON.stringify(window)}. Use milliseconds or a duration such as '30s', '15m' or '1 hour'.`);
|
|
48
|
+
}
|
|
49
|
+
return Math.round(ms);
|
|
50
|
+
}
|
|
51
|
+
function assertMax(max) {
|
|
52
|
+
if (!Number.isInteger(max) || max < 1) {
|
|
53
|
+
throw new TypeError(`[Megh] Rate limit max must be a whole number of at least 1, got ${max}.`);
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
// ─── Stores ──────────────────────────────────────────────────────────────────
|
|
57
|
+
/**
|
|
58
|
+
* Fixed-window counts in memory. Counts are per process and lost on
|
|
59
|
+
* restart. Expired windows are swept every minute by an `unref`'d timer.
|
|
60
|
+
*/
|
|
61
|
+
class MemoryRateLimitStore {
|
|
62
|
+
sweepIntervalMs;
|
|
63
|
+
windows = new Map();
|
|
64
|
+
timer = null;
|
|
65
|
+
constructor(sweepIntervalMs = 60_000) {
|
|
66
|
+
this.sweepIntervalMs = sweepIntervalMs;
|
|
67
|
+
}
|
|
68
|
+
hit(key, windowMs) {
|
|
69
|
+
const now = Date.now();
|
|
70
|
+
let entry = this.windows.get(key);
|
|
71
|
+
if (!entry || entry.resetAt <= now) {
|
|
72
|
+
entry = { count: 0, resetAt: now + windowMs };
|
|
73
|
+
this.windows.set(key, entry);
|
|
74
|
+
this.startSweep();
|
|
75
|
+
}
|
|
76
|
+
entry.count++;
|
|
77
|
+
return { count: entry.count, resetAt: entry.resetAt };
|
|
78
|
+
}
|
|
79
|
+
reset(key) {
|
|
80
|
+
this.windows.delete(key);
|
|
81
|
+
}
|
|
82
|
+
close() {
|
|
83
|
+
if (this.timer)
|
|
84
|
+
clearInterval(this.timer);
|
|
85
|
+
this.timer = null;
|
|
86
|
+
this.windows.clear();
|
|
87
|
+
}
|
|
88
|
+
startSweep() {
|
|
89
|
+
if (this.timer)
|
|
90
|
+
return;
|
|
91
|
+
this.timer = setInterval(() => {
|
|
92
|
+
const now = Date.now();
|
|
93
|
+
for (const [key, entry] of this.windows) {
|
|
94
|
+
if (entry.resetAt <= now)
|
|
95
|
+
this.windows.delete(key);
|
|
96
|
+
}
|
|
97
|
+
if (this.windows.size === 0)
|
|
98
|
+
this.close();
|
|
99
|
+
}, this.sweepIntervalMs);
|
|
100
|
+
this.timer.unref();
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
exports.MemoryRateLimitStore = MemoryRateLimitStore;
|
|
104
|
+
// Count the hit and start the window on the first one, in one round trip.
|
|
105
|
+
const HIT_SCRIPT = `
|
|
106
|
+
local count = redis.call('INCR', KEYS[1])
|
|
107
|
+
local ttl = redis.call('PTTL', KEYS[1])
|
|
108
|
+
if ttl < 0 then
|
|
109
|
+
redis.call('PEXPIRE', KEYS[1], ARGV[1])
|
|
110
|
+
ttl = tonumber(ARGV[1])
|
|
111
|
+
end
|
|
112
|
+
return { count, ttl }
|
|
113
|
+
`;
|
|
114
|
+
/**
|
|
115
|
+
* Fixed-window counts in Redis, shared by every replica. Pass an ioredis
|
|
116
|
+
* client; Megh does not close it.
|
|
117
|
+
*/
|
|
118
|
+
class RedisRateLimitStore {
|
|
119
|
+
redis;
|
|
120
|
+
prefix;
|
|
121
|
+
constructor(redis, options = {}) {
|
|
122
|
+
this.redis = redis;
|
|
123
|
+
if (!redis || typeof redis.eval !== "function") {
|
|
124
|
+
throw new TypeError("[Megh] RedisRateLimitStore needs an ioredis client, e.g. new RedisRateLimitStore(new Redis()).");
|
|
125
|
+
}
|
|
126
|
+
this.prefix = options.prefix ?? "megh:rate-limit:";
|
|
127
|
+
}
|
|
128
|
+
async hit(key, windowMs) {
|
|
129
|
+
const [count, ttl] = (await this.redis.eval(HIT_SCRIPT, 1, this.prefix + key, windowMs));
|
|
130
|
+
return { count: Number(count), resetAt: Date.now() + Number(ttl) };
|
|
131
|
+
}
|
|
132
|
+
async reset(key) {
|
|
133
|
+
await this.redis.del(this.prefix + key);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
exports.RedisRateLimitStore = RedisRateLimitStore;
|
|
137
|
+
// ─── Decorator ───────────────────────────────────────────────────────────────
|
|
138
|
+
/**
|
|
139
|
+
* Give a controller or route its own limit, in place of the app's, or pass
|
|
140
|
+
* `false` to leave it unlimited. Works without `app.useRateLimit()` too.
|
|
141
|
+
*
|
|
142
|
+
* @Post('/login')
|
|
143
|
+
* @RateLimit({ max: 5, window: '15m' })
|
|
144
|
+
* login() {}
|
|
145
|
+
*/
|
|
146
|
+
function RateLimit(options) {
|
|
147
|
+
assertRouteRateLimit(options);
|
|
148
|
+
return (target, propertyKey) => {
|
|
149
|
+
if (propertyKey === undefined) {
|
|
150
|
+
Reflect.defineMetadata(exports.RATE_LIMIT_META_KEY, options, target);
|
|
151
|
+
}
|
|
152
|
+
else {
|
|
153
|
+
Reflect.defineMetadata(exports.RATE_LIMIT_META_KEY, options, target, propertyKey);
|
|
154
|
+
}
|
|
155
|
+
};
|
|
156
|
+
}
|
|
157
|
+
/** Throw on a bad route limit when it is declared, not on its first request. */
|
|
158
|
+
function assertRouteRateLimit(options) {
|
|
159
|
+
if (options === false)
|
|
160
|
+
return;
|
|
161
|
+
if (options === null || typeof options !== "object") {
|
|
162
|
+
throw new TypeError("[Megh] A route rate limit is an options object, e.g. { max: 5, window: '1m' }, or false.");
|
|
163
|
+
}
|
|
164
|
+
if (options.max !== undefined)
|
|
165
|
+
assertMax(options.max);
|
|
166
|
+
if (options.window !== undefined)
|
|
167
|
+
parseWindow(options.window);
|
|
168
|
+
}
|
|
169
|
+
/** The `@RateLimit()` for a route: the method's, else the controller's. */
|
|
170
|
+
function getDeclaredRateLimit(controller, method) {
|
|
171
|
+
return (Reflect.getMetadata(exports.RATE_LIMIT_META_KEY, controller.prototype, method) ??
|
|
172
|
+
Reflect.getMetadata(exports.RATE_LIMIT_META_KEY, controller));
|
|
173
|
+
}
|
|
174
|
+
const defaultKey = (request) => request.ip;
|
|
175
|
+
/**
|
|
176
|
+
* Count requests per client and answer 429 over the limit. Returns the
|
|
177
|
+
* store, so the app can close it on shutdown when it created it.
|
|
178
|
+
*/
|
|
179
|
+
function installRateLimit(app, options = {}) {
|
|
180
|
+
const max = options.max ?? DEFAULT_MAX;
|
|
181
|
+
assertMax(max);
|
|
182
|
+
const windowMs = parseWindow(options.window ?? DEFAULT_WINDOW_MS);
|
|
183
|
+
const appLimit = {
|
|
184
|
+
max,
|
|
185
|
+
windowMs,
|
|
186
|
+
key: options.key ?? defaultKey,
|
|
187
|
+
scope: "",
|
|
188
|
+
};
|
|
189
|
+
const ownsStore = !options.store;
|
|
190
|
+
const store = options.store ??
|
|
191
|
+
(options.redis
|
|
192
|
+
? new RedisRateLimitStore(options.redis)
|
|
193
|
+
: new MemoryRateLimitStore());
|
|
194
|
+
const sendHeaders = options.headers ?? true;
|
|
195
|
+
const message = options.message ?? DEFAULT_MESSAGE;
|
|
196
|
+
const limitAll = options.global ?? true;
|
|
197
|
+
// A route's own limit, resolved on its first request.
|
|
198
|
+
const routeLimits = new WeakMap();
|
|
199
|
+
const limitFor = (request) => {
|
|
200
|
+
const config = request.routeOptions?.config;
|
|
201
|
+
if (!config)
|
|
202
|
+
return limitAll ? appLimit : null;
|
|
203
|
+
let limit = routeLimits.get(config);
|
|
204
|
+
if (limit !== undefined)
|
|
205
|
+
return limit;
|
|
206
|
+
const own = config[exports.RATE_LIMIT_CONFIG_KEY];
|
|
207
|
+
if (own === false)
|
|
208
|
+
limit = null;
|
|
209
|
+
else if (own) {
|
|
210
|
+
limit = {
|
|
211
|
+
max: own.max ?? appLimit.max,
|
|
212
|
+
windowMs: own.window !== undefined
|
|
213
|
+
? parseWindow(own.window)
|
|
214
|
+
: appLimit.windowMs,
|
|
215
|
+
key: own.key ?? appLimit.key,
|
|
216
|
+
scope: `${request.method}:${request.routeOptions.url}|`,
|
|
217
|
+
};
|
|
218
|
+
}
|
|
219
|
+
else if (config[health_1.SKIP_GLOBAL_MIDDLEWARE] || !limitAll) {
|
|
220
|
+
// Health probes must answer even when a client is over its limit.
|
|
221
|
+
limit = null;
|
|
222
|
+
}
|
|
223
|
+
else
|
|
224
|
+
limit = appLimit;
|
|
225
|
+
routeLimits.set(config, limit);
|
|
226
|
+
return limit;
|
|
227
|
+
};
|
|
228
|
+
app.addHook("onRequest", async (request, reply) => {
|
|
229
|
+
const limit = limitFor(request);
|
|
230
|
+
if (!limit)
|
|
231
|
+
return;
|
|
232
|
+
const req = request;
|
|
233
|
+
if (options.skip && (await options.skip(req)))
|
|
234
|
+
return;
|
|
235
|
+
let hit;
|
|
236
|
+
try {
|
|
237
|
+
const key = String(await limit.key(req));
|
|
238
|
+
hit = await store.hit(limit.scope + key, limit.windowMs);
|
|
239
|
+
}
|
|
240
|
+
catch (err) {
|
|
241
|
+
if (!options.failOpen)
|
|
242
|
+
throw err;
|
|
243
|
+
(0, internal_logger_1.internalLogger)("rate-limit").error({ err }, "Rate limit store failed; letting the request through");
|
|
244
|
+
return;
|
|
245
|
+
}
|
|
246
|
+
const resetSeconds = Math.max(0, Math.ceil((hit.resetAt - Date.now()) / 1000));
|
|
247
|
+
if (sendHeaders) {
|
|
248
|
+
reply.header("RateLimit-Limit", limit.max);
|
|
249
|
+
reply.header("RateLimit-Remaining", Math.max(0, limit.max - hit.count));
|
|
250
|
+
reply.header("RateLimit-Reset", resetSeconds);
|
|
251
|
+
}
|
|
252
|
+
if (hit.count > limit.max) {
|
|
253
|
+
throw new http_exceptions_1.TooManyRequestsException(message, {
|
|
254
|
+
headers: { "Retry-After": resetSeconds },
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
return { store, ownsStore };
|
|
259
|
+
}
|
|
260
|
+
//# sourceMappingURL=rate-limit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"rate-limit.js","sourceRoot":"","sources":["../../src/security/rate-limit.ts"],"names":[],"mappings":";;;AAwGA,kCAiBC;AA0HD,8BAWC;AAGD,oDASC;AAGD,oDAQC;AAmBD,4CA4FC;AA5XD,+DAAqE;AACrE,oDAAiE;AACjE,sEAAkE;AAqElE,iFAAiF;AACpE,QAAA,qBAAqB,GAAG,eAAe,CAAC;AACrD,uCAAuC;AAC1B,QAAA,mBAAmB,GAAG,iBAAiB,CAAC;AAErD,MAAM,WAAW,GAAG,GAAG,CAAC;AACxB,MAAM,iBAAiB,GAAG,MAAM,CAAC;AACjC,MAAM,eAAe,GAAG,4CAA4C,CAAC;AAErE,MAAM,KAAK,GAA2B;IACpC,EAAE,EAAE,CAAC;IACL,WAAW,EAAE,CAAC;IACd,CAAC,EAAE,IAAI;IACP,GAAG,EAAE,IAAI;IACT,MAAM,EAAE,IAAI;IACZ,CAAC,EAAE,MAAM;IACT,GAAG,EAAE,MAAM;IACX,MAAM,EAAE,MAAM;IACd,CAAC,EAAE,SAAS;IACZ,IAAI,EAAE,SAAS;IACf,CAAC,EAAE,UAAU;IACb,GAAG,EAAE,UAAU;CAChB,CAAC;AAEF,uEAAuE;AACvE,SAAgB,WAAW,CAAC,MAAuB;IACjD,IAAI,EAAU,CAAC;IACf,IAAI,OAAO,MAAM,KAAK,QAAQ,EAAE,CAAC;QAC/B,EAAE,GAAG,MAAM,CAAC;IACd,CAAC;SAAM,CAAC;QACN,MAAM,KAAK,GAAG,qCAAqC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;QACjE,MAAM,IAAI,GAAG,KAAK,EAAE,CAAC,CA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AAM,YAAY,GAAG,IAAI,CAAC,GAAG,CAC3B,CAAC,EACD,IAAI,CAAC,IAAI,CAAC,CAAC,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC,GAAG,IAAI,CAAC,CAC7C,CAAC;QACF,IAAI,WAAW,EAAE,CAAC;YAChB,KAAK,CAAC,MAAM,CAAC,iBAAiB,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;YAC3C,KAAK,CAAC,MAAM,CAAC,qBAAqB,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,CAAC,CAAC;YACxE,KAAK,CAAC,MAAM,CAAC,iBAAiB,EAAE,YAAY,CAAC,CAAC;QAChD,CAAC;QACD,IAAI,GAAG,CAAC,KAAK,GAAG,KAAK,CAAC,GAAG,EAAE,CAAC;YAC1B,MAAM,IAAI,0CAAwB,CAAC,OAAO,EAAE;gBAC1C,OAAO,EAAE,EAAE,aAAa,EAAE,YAAY,EAAE;aACzC,CAAC,CAAC;QACL,CAAC;IACH,CAAC,CACF,CAAC;IAEF,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,CAAC;AAC9B,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@meghjs/core",
|
|
3
|
-
"version": "0.6.
|
|
3
|
+
"version": "0.6.1",
|
|
4
4
|
"description": "TypeScript-first web framework built on Fastify",
|
|
5
5
|
"author": "Tareq Hossain",
|
|
6
6
|
"license": "MIT",
|
|
@@ -39,7 +39,9 @@
|
|
|
39
39
|
"openapi",
|
|
40
40
|
"swagger",
|
|
41
41
|
"orm",
|
|
42
|
-
"migrations"
|
|
42
|
+
"migrations",
|
|
43
|
+
"mail",
|
|
44
|
+
"email"
|
|
43
45
|
],
|
|
44
46
|
"scripts": {
|
|
45
47
|
"build": "node -e \"require('fs').rmSync('dist',{recursive:true,force:true})\" && tsc -p tsconfig.json",
|
|
@@ -66,9 +68,7 @@
|
|
|
66
68
|
"@faker-js/faker": ">=9.0.0",
|
|
67
69
|
"@fastify/compress": "^9.0.0",
|
|
68
70
|
"@fastify/cors": "^11.0.0",
|
|
69
|
-
"@fastify/helmet": "^13.0.0",
|
|
70
71
|
"@fastify/multipart": "^9.0.0",
|
|
71
|
-
"@fastify/rate-limit": "^11.0.0",
|
|
72
72
|
"@fastify/static": "^10.1.2",
|
|
73
73
|
"@fastify/swagger": "^9.0.0",
|
|
74
74
|
"@fastify/swagger-ui": "^6.1.2",
|
|
@@ -81,6 +81,7 @@
|
|
|
81
81
|
"ioredis": ">=5.0.0",
|
|
82
82
|
"kafkajs": ">=2.0.0",
|
|
83
83
|
"kysely": ">=0.27.0",
|
|
84
|
+
"nodemailer": ">=6.9.0",
|
|
84
85
|
"pino-pretty": "^13.0.0",
|
|
85
86
|
"sharp": ">=0.33.0",
|
|
86
87
|
"socket.io": ">=4.0.0",
|
|
@@ -96,15 +97,9 @@
|
|
|
96
97
|
"@fastify/cors": {
|
|
97
98
|
"optional": true
|
|
98
99
|
},
|
|
99
|
-
"@fastify/helmet": {
|
|
100
|
-
"optional": true
|
|
101
|
-
},
|
|
102
100
|
"@fastify/multipart": {
|
|
103
101
|
"optional": true
|
|
104
102
|
},
|
|
105
|
-
"@fastify/rate-limit": {
|
|
106
|
-
"optional": true
|
|
107
|
-
},
|
|
108
103
|
"@fastify/static": {
|
|
109
104
|
"optional": true
|
|
110
105
|
},
|
|
@@ -135,6 +130,9 @@
|
|
|
135
130
|
"kysely": {
|
|
136
131
|
"optional": true
|
|
137
132
|
},
|
|
133
|
+
"nodemailer": {
|
|
134
|
+
"optional": true
|
|
135
|
+
},
|
|
138
136
|
"pino-pretty": {
|
|
139
137
|
"optional": true
|
|
140
138
|
},
|
|
@@ -152,9 +150,7 @@
|
|
|
152
150
|
"@faker-js/faker": "^10.6.0",
|
|
153
151
|
"@fastify/compress": "^9.3.0",
|
|
154
152
|
"@fastify/cors": "^11.0.0",
|
|
155
|
-
"@fastify/helmet": "^13.2.0",
|
|
156
153
|
"@fastify/multipart": "^9.0.3",
|
|
157
|
-
"@fastify/rate-limit": "^11.2.1",
|
|
158
154
|
"@fastify/static": "^10.1.8",
|
|
159
155
|
"@fastify/swagger": "^9.7.0",
|
|
160
156
|
"@fastify/swagger-ui": "^6.1.2",
|
|
@@ -177,6 +173,7 @@
|
|
|
177
173
|
"ioredis": "^5.10.1",
|
|
178
174
|
"kafkajs": "^2.2.4",
|
|
179
175
|
"mysql2": "^3.24.6",
|
|
176
|
+
"nodemailer": "^10.5.0",
|
|
180
177
|
"pg": "^8.23.1",
|
|
181
178
|
"pino-pretty": "^13.1.3",
|
|
182
179
|
"prettier": "^3.6.2",
|
|
@@ -206,5 +203,5 @@
|
|
|
206
203
|
"publishConfig": {
|
|
207
204
|
"access": "public"
|
|
208
205
|
},
|
|
209
|
-
"gitHead": "
|
|
206
|
+
"gitHead": "7fff07fe185c332d74e223a30260b51218c9a60d"
|
|
210
207
|
}
|