Refactor S3 argument parsing

master
Lauri Võsandi 5 months ago
parent ec59a423bb
commit 2908a0bed0
  1. 21
      backend/server.js

@ -8,8 +8,12 @@ const mongoCollection = process.env.MONGO_COLLECTION || 'eventlog';
const mongoUri = process.env.MONGO_URI || 'mongodb://127.0.0.1:27017/default?replicaSet=rs0';
// Minio set-up variables
const minioURI = new URL(process.env.MINIO_URI || 'http://kspace-mugshot:2mSI6HdbJ8@127.0.0.1:9000/kspace-mugshot');
const minioBucket = minioURI.pathname.substring(1);
const minioAccessKey = process.env.MINIO_ACCESS_KEY || 'kspace-mugshot';
const minioSecretKey = process.env.MINIO_SECRET_KEY || '2mSI6HdbJ8';
const minioHostname = process.env.MINIO_HOSTNAME || '127.0.0.1';
const minioPort = process.env.MINIO_PORT || 9000;
const minioScheme = process.env.MINIO_SCHEME || 'http';
const minioBucket = process.env.MINIO_BUCKET || 'kspace-mugshot';
console.info("Using bucket:", minioBucket);
const historyNumber = parseInt(process.env.HISTORY_AMOUNT) || 10;
@ -34,15 +38,18 @@ async function run() {
changeStream = collection.watch(pipeline, options);
console.log("Started watching changes in database");
console.log("Minio hostname:", minioHostname);
console.log("Minio port:", minioPort);
console.log("Minio protocol:", minioScheme);
// Triggers on GET at /event route
app.get('/events', async function (request, response) {
let minioClient = new minio.Client({
endPoint: minioURI.hostname,
port: parseInt(minioURI.port) || (minioURI.protocol == 'https:' ? 443 : 80),
useSSL: minioURI.protocol == 'https:',
accessKey: minioURI.username,
secretKey: minioURI.password
endPoint: minioHostname,
port: parseInt(minioPort),
useSSL: minioScheme == 'https',
accessKey: minioAccessKey,
secretKey: minioSecretKey
});
async function wrapEvent(doc) {

Loading…
Cancel
Save