nestjs-minio-backend
Version:
NestJS module for MinIO integration
45 lines • 1.48 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.FileSchemaField = FileSchemaField;
const common_1 = require("@nestjs/common");
const file_column_decorator_1 = require("./file-column.decorator");
let cachedPropDecorator;
const optionalRequire = (() => {
try {
return Function('return typeof require !== "undefined" ? require : null')();
}
catch {
return null;
}
})();
function getMongoosePropDecorator() {
if (cachedPropDecorator !== undefined) {
return cachedPropDecorator;
}
try {
if (!optionalRequire) {
cachedPropDecorator = null;
return cachedPropDecorator;
}
const mongooseModule = optionalRequire('@nestjs/mongoose');
const prop = mongooseModule?.Prop;
cachedPropDecorator = typeof prop === 'function' ? prop : null;
}
catch {
cachedPropDecorator = null;
}
return cachedPropDecorator;
}
function FileSchemaField(options = {}) {
const fileOptions = {
...options,
isFileField: true,
bucketName: options.bucketName || 'media-files-bucket',
};
const propDecorator = getMongoosePropDecorator();
if (!propDecorator) {
return (0, file_column_decorator_1.FileColumn)(options);
}
return (0, common_1.applyDecorators)((0, file_column_decorator_1.FileColumn)(options), propDecorator(fileOptions));
}
//# sourceMappingURL=file-schema-field.decorator.js.map