diff --git a/Services/server/tools/prepare.ts b/Services/server/tools/prepare.ts new file mode 100644 index 0000000..d1394ef --- /dev/null +++ b/Services/server/tools/prepare.ts @@ -0,0 +1,44 @@ +import "dotenv/config"; +import esClient from "../src/elasticsearch"; +import minioClient from "../src/minio"; + +const DEFAULT_BUCKET = process.env.MINIO_BUCKET; +const DEFAULT_INDEX = process.env.ELASTICSEARCH_INDEX; + +if (!DEFAULT_BUCKET) throw Error("Default MinIO bucket must be specified."); +if (!DEFAULT_INDEX) throw Error("Default ElasticSearch index must be specified."); + +esClient.ingest.putPipeline({ + id: "attachment", + body: { + description: "Extract attachment information", + processors: [ + { + attachment: { + field: "data", + }, + }, + { + remove: { + field: "data", + }, + }, + ], + }, +}); + +esClient.indices.putMapping({ + index: DEFAULT_INDEX, + body: { + properties: { + pathname: { + type: "keyword", + }, + }, + }, +}); + +minioClient.makeBucket(DEFAULT_BUCKET!, (e) => { + if (!e) console.log("Configuration needed for Bucket Notification to AMQP"); + console.error(e); +});