47 lines
1 KiB
TypeScript
47 lines
1 KiB
TypeScript
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",
|
|
},
|
|
path: {
|
|
type: "keyword",
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
minioClient.makeBucket(DEFAULT_BUCKET!, (e) => {
|
|
if (!e) console.log("Success. Configuration is needed for Bucket Notification to AMQP.");
|
|
console.error(e);
|
|
});
|