UNPKG

@nestjs-mod/files

Version:

Files module with an error filter, controller and rest-sdk for work with module from other nodejs appliaction

144 lines 6.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.FilesConfiguration = exports.FilesDefaultBucketNames = void 0; const tslib_1 = require("tslib"); const common_1 = require("@nestjs-mod/common"); var FilesDefaultBucketNames; (function (FilesDefaultBucketNames) { FilesDefaultBucketNames["images"] = "images"; FilesDefaultBucketNames["video"] = "video"; FilesDefaultBucketNames["documents"] = "documents"; })(FilesDefaultBucketNames || (exports.FilesDefaultBucketNames = FilesDefaultBucketNames = {})); let FilesConfiguration = class FilesConfiguration { }; exports.FilesConfiguration = FilesConfiguration; tslib_1.__decorate([ (0, common_1.ConfigModelProperty)({ description: 'Function for get from download url without bucket names', }), tslib_1.__metadata("design:type", Function) ], FilesConfiguration.prototype, "getFromDownloadUrlWithoutBucketNames", void 0); tslib_1.__decorate([ (0, common_1.ConfigModelProperty)({ description: 'Function for get presigned urls', }), tslib_1.__metadata("design:type", Function) ], FilesConfiguration.prototype, "getPresignedUrls", void 0); tslib_1.__decorate([ (0, common_1.ConfigModelProperty)({ description: 'Function for delete file', }), tslib_1.__metadata("design:type", Function) ], FilesConfiguration.prototype, "deleteFile", void 0); tslib_1.__decorate([ (0, common_1.ConfigModelProperty)({ description: 'Buckets with policy', default: { [FilesDefaultBucketNames.images]: { policy: { Version: '2012-10-17', Statement: [ /*{ Effect: 'Allow', Principal: { AWS: ['*'], }, Action: ['s3:ListBucketMultipartUploads' , 's3:GetBucketLocation', 's3:ListBucket'], Resource: [`arn:aws:s3:::${bucketName}`], },*/ { Effect: 'Allow', Principal: { AWS: ['*'], }, Action: [ 's3:PutObject', 's3:AbortMultipartUpload', 's3:DeleteObject', 's3:GetObject' /*, 's3:ListMultipartUploadParts'*/, ], Resource: ['jpg', 'jpeg', 'png', 'gif'].map((ext) => `arn:aws:s3:::images/*.${ext}`), }, ], Conditions: [['content-length-range', 1024 * 1024 * 5]], }, ext: ['jpg', 'jpeg', 'png', 'gif'], }, [FilesDefaultBucketNames.video]: { policy: { Version: '2012-10-17', Statement: [ /*{ Effect: 'Allow', Principal: { AWS: ['*'], }, Action: ['s3:ListBucketMultipartUploads' , 's3:GetBucketLocation', 's3:ListBucket'], Resource: [`arn:aws:s3:::${bucketName}`], },*/ { Effect: 'Allow', Principal: { AWS: ['*'], }, Action: [ 's3:PutObject', 's3:AbortMultipartUpload', 's3:DeleteObject', 's3:GetObject' /*, 's3:ListMultipartUploadParts'*/, ], Resource: ['mp4'].map((ext) => `arn:aws:s3:::video/*.${ext}`), }, ], Conditions: [['content-length-range', 1024 * 1024 * 50]], }, ext: ['mp4'], }, [FilesDefaultBucketNames.documents]: { policy: { Version: '2012-10-17', Statement: [ /*{ Effect: 'Allow', Principal: { AWS: ['*'], }, Action: ['s3:ListBucketMultipartUploads' , 's3:GetBucketLocation', 's3:ListBucket'], Resource: [`arn:aws:s3:::${bucketName}`], },*/ { Effect: 'Allow', Principal: { AWS: ['*'], }, Action: [ 's3:PutObject', 's3:AbortMultipartUpload', 's3:DeleteObject', 's3:GetObject' /*, 's3:ListMultipartUploadParts'*/, ], Resource: [ 'doc', 'docx', 'xls', 'md', 'odt', 'txt', 'xml', 'rtf', 'csv', ].map((ext) => `arn:aws:s3:::documents/*.${ext}`), }, ], Conditions: [['content-length-range', 1024 * 1024 * 10]], }, ext: ['doc', 'docx', 'xls', 'md', 'odt', 'txt', 'xml', 'rtf', 'csv'], }, }, }), tslib_1.__metadata("design:type", Object) ], FilesConfiguration.prototype, "buckets", void 0); exports.FilesConfiguration = FilesConfiguration = tslib_1.__decorate([ (0, common_1.ConfigModel)() ], FilesConfiguration); //# sourceMappingURL=files.configuration.js.map