feat: tools to do some automate prepare

This commit is contained in:
Methapon2001 2023-11-27 15:06:01 +07:00
parent 51817c91f5
commit ca5be0042d
No known key found for this signature in database
GPG key ID: 849924FEF46BD132

View file

@ -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);
});