feat: tools to do some automate prepare
This commit is contained in:
parent
51817c91f5
commit
ca5be0042d
1 changed files with 44 additions and 0 deletions
44
Services/server/tools/prepare.ts
Normal file
44
Services/server/tools/prepare.ts
Normal 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);
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue