@adminforth/upload 1.0.20 → 1.0.21
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.js +3 -2
- package/index.ts +5 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -11,7 +11,7 @@ import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
|
11
11
|
import { ExpirationStatus, GetObjectCommand, PutObjectCommand, S3 } from '@aws-sdk/client-s3';
|
|
12
12
|
import { AdminForthPlugin, suggestIfTypo } from "adminforth";
|
|
13
13
|
import { Readable } from "stream";
|
|
14
|
-
import { RateLimiter
|
|
14
|
+
import { RateLimiter } from "adminforth";
|
|
15
15
|
const ADMINFORTH_NOT_YET_USED_TAG = 'adminforth-candidate-for-cleanup';
|
|
16
16
|
export default class UploadPlugin extends AdminForthPlugin {
|
|
17
17
|
constructor(options) {
|
|
@@ -329,6 +329,7 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
329
329
|
});
|
|
330
330
|
}
|
|
331
331
|
validateConfigAfterDiscover(adminforth, resourceConfig) {
|
|
332
|
+
this.adminforth = adminforth;
|
|
332
333
|
// called here because modifyResourceConfig can be called in build time where there is no environment and AWS secrets
|
|
333
334
|
this.setupLifecycleRule();
|
|
334
335
|
}
|
|
@@ -418,7 +419,7 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
418
419
|
}
|
|
419
420
|
if ((_d = this.options.generation.rateLimit) === null || _d === void 0 ? void 0 : _d.limit) {
|
|
420
421
|
// rate limit
|
|
421
|
-
const { error } = RateLimiter.checkRateLimit(this.pluginInstanceId, (_e = this.options.generation.rateLimit) === null || _e === void 0 ? void 0 : _e.limit, getClientIp(headers));
|
|
422
|
+
const { error } = RateLimiter.checkRateLimit(this.pluginInstanceId, (_e = this.options.generation.rateLimit) === null || _e === void 0 ? void 0 : _e.limit, this.adminforth.auth.getClientIp(headers));
|
|
422
423
|
if (error) {
|
|
423
424
|
return { error: this.options.generation.rateLimit.errorMessage };
|
|
424
425
|
}
|
package/index.ts
CHANGED
|
@@ -4,13 +4,15 @@ import { getSignedUrl } from '@aws-sdk/s3-request-presigner';
|
|
|
4
4
|
import { ExpirationStatus, GetObjectCommand, ObjectCannedACL, PutObjectCommand, S3 } from '@aws-sdk/client-s3';
|
|
5
5
|
import { AdminForthPlugin, AdminForthResourceColumn, AdminForthResourcePages, IAdminForth, IHttpServer, suggestIfTypo } from "adminforth";
|
|
6
6
|
import { Readable } from "stream";
|
|
7
|
-
import { RateLimiter
|
|
7
|
+
import { RateLimiter } from "adminforth";
|
|
8
8
|
|
|
9
9
|
const ADMINFORTH_NOT_YET_USED_TAG = 'adminforth-candidate-for-cleanup';
|
|
10
10
|
|
|
11
11
|
export default class UploadPlugin extends AdminForthPlugin {
|
|
12
12
|
options: PluginOptions;
|
|
13
13
|
|
|
14
|
+
adminforth!: IAdminForth;
|
|
15
|
+
|
|
14
16
|
constructor(options: PluginOptions) {
|
|
15
17
|
super(options, import.meta.url);
|
|
16
18
|
this.options = options;
|
|
@@ -363,6 +365,7 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
363
365
|
}
|
|
364
366
|
|
|
365
367
|
validateConfigAfterDiscover(adminforth: IAdminForth, resourceConfig: any) {
|
|
368
|
+
this.adminforth = adminforth;
|
|
366
369
|
// called here because modifyResourceConfig can be called in build time where there is no environment and AWS secrets
|
|
367
370
|
this.setupLifecycleRule();
|
|
368
371
|
}
|
|
@@ -464,7 +467,7 @@ export default class UploadPlugin extends AdminForthPlugin {
|
|
|
464
467
|
const { error } = RateLimiter.checkRateLimit(
|
|
465
468
|
this.pluginInstanceId,
|
|
466
469
|
this.options.generation.rateLimit?.limit,
|
|
467
|
-
getClientIp(headers),
|
|
470
|
+
this.adminforth.auth.getClientIp(headers),
|
|
468
471
|
);
|
|
469
472
|
if (error) {
|
|
470
473
|
return { error: this.options.generation.rateLimit.errorMessage };
|