REFACTOR: Belonging → Property system migration + utilities update
Property system: - Rename belonging → property throughout (model, controller, routes, service) - Add property sub-models: buildingModel, landModel, belongingModel - Add property lifecycle events: createProperty, deleteProperty - Add propertyStatus component (model, controller, routes, service, seeder) - Add commodity and commodityTransaction model stubs Infrastructure: - Update transactionModel and transactionService - Update events/index.js for new property events - Update seeder (seederDBConnection, seederRunner) - Update typesense client configuration - Update upload utilities (bucket, minio) - Update featureModel and featureSeeder - Update categorySeeder - Update TsApiFeatures utility - Remove docker-compose.yml (moved to root) - Remove legacy belonging component files
This commit is contained in:
@@ -166,8 +166,9 @@ class TsApiFeatures {
|
||||
per_page: this.queryOptions.per_page,
|
||||
})
|
||||
})
|
||||
const tsProtocol = process.env.TYPE_SENSE_PROTOCOL || 'http'
|
||||
const config = {
|
||||
url: 'https://' + process.env.TYPE_SENSE_URL + '/multi_search?x-typesense-api-key=' + process.env.TYPE_SENSE_API_KEY,
|
||||
url: tsProtocol + '://' + process.env.TYPE_SENSE_URL + '/multi_search?x-typesense-api-key=' + process.env.TYPE_SENSE_API_KEY,
|
||||
method: 'POST',
|
||||
data: {
|
||||
searches,
|
||||
|
||||
@@ -4,11 +4,18 @@ const fs = require('fs')
|
||||
|
||||
// Upload File to s3 bucket
|
||||
exports.uploadObject = async (file, bucketName) => {
|
||||
const bucketExists = await minioClient.bucketExists(bucketName).catch(() => false)
|
||||
if (!bucketExists) {
|
||||
await minioClient.makeBucket(bucketName, process.env.AWS_REGION || 'us-east-1')
|
||||
}
|
||||
|
||||
const fileStream = fs.createReadStream(file.path)
|
||||
|
||||
const uploadedFile = await minioClient.putObject(bucketName, `${file.filename}-${file.originalName}`, fileStream)
|
||||
|
||||
uploadedFile.fileURL = 'https://' + process.env.AWS_ENDPOINT + '/' + bucketName + '/' + file.filename + '-' + file.originalName
|
||||
const protocol = process.env.AWS_USE_SSL === 'true' ? 'https://' : 'http://'
|
||||
const hostPort = process.env.AWS_PORT ? `${process.env.AWS_ENDPOINT}:${process.env.AWS_PORT}` : process.env.AWS_ENDPOINT
|
||||
uploadedFile.fileURL = protocol + hostPort + '/' + bucketName + '/' + file.filename + '-' + file.originalName
|
||||
|
||||
uploadedFile.fileName = file.filename + '-' + file.originalName
|
||||
|
||||
|
||||
+16
-22
@@ -1,30 +1,24 @@
|
||||
const Minio = require('minio')
|
||||
|
||||
const endPoint = process.env.AWS_ENDPOINT
|
||||
const endPoint = process.env.AWS_ENDPOINT || 'localhost'
|
||||
const accessKey = process.env.AWS_ACCESS_KEY
|
||||
const secretKey = process.env.AWS_SECRET_KEY
|
||||
const region = process.env.AWS_REGION
|
||||
const port = parseInt(process.env.AWS_PORT)
|
||||
const region = process.env.AWS_REGION || 'us-east-1'
|
||||
const port = parseInt(process.env.AWS_PORT) || 9000
|
||||
const useSSL = process.env.AWS_USE_SSL === 'true'
|
||||
|
||||
let client
|
||||
|
||||
if (process.env.NODE_ENV === 'test') {
|
||||
client = new Minio.Client({
|
||||
endPoint,
|
||||
useSSL: true,
|
||||
accessKey,
|
||||
port,
|
||||
secretKey,
|
||||
region,
|
||||
})
|
||||
} else {
|
||||
client = new Minio.Client({
|
||||
endPoint,
|
||||
useSSL: true,
|
||||
accessKey,
|
||||
secretKey,
|
||||
region,
|
||||
})
|
||||
const clientOptions = {
|
||||
endPoint,
|
||||
useSSL,
|
||||
accessKey,
|
||||
secretKey,
|
||||
region,
|
||||
}
|
||||
|
||||
if (port) {
|
||||
clientOptions.port = port
|
||||
}
|
||||
|
||||
const client = new Minio.Client(clientOptions)
|
||||
|
||||
module.exports = client
|
||||
|
||||
Reference in New Issue
Block a user