/**
 * Minified by jsDelivr using Terser v5.39.0.
 * Original file: /npm/node-video-crime-miner@1.0.0/out/index.js
 *
 * Do NOT use SRI with dynamically generated files! More information: https://www.jsdelivr.com/using-sri-with-dynamic-files
 */
import*as envConfig from"./envConfig.js";import{Readable}from"stream";envConfig.default;import express from"express";const app=express();import{listObjects,getObjectFromS3,uploadWithFile}from"./src/AWS Layer/s3Connector.js";import{startLabelDetection,getLabelDetectionResults}from"./src/AWS Layer/Rekognition/videoLabelUtils.js";import{getAllCases,createNewCase}from"./postgres/db.cases.js";import{createNewLabels,getResultsForFile,getResultsForJob,updateJobResults}from"./postgres/db.labels.js";app.use(express.json()),app.use(express.urlencoded({extended:!1})),app.use((function(e,s,t){s.header("Access-Control-Allow-Origin","*"),s.header("Access-Control-Allow-Headers","Origin, X-Requested-With, Content-Type, Accept"),t()})),app.get("/",((e,s)=>{s.send("Video Crime Miner Express + TypeScript Server")})),app.get("/labels/job/:jobId",(async(e,s)=>{try{var t=await getResultsForJob(e.params.jobId);null==t.result&&(t.result=await getLabelDetectionResults(e.params.jobId),updateJobResults(e.params.jobId,t.result)),s.status(200).json({status:t.result.JobStatus,result:t})}catch(t){console.log("app.get('/labels/:jobId') errored out"),s.status(500).send({errormsg:t.message,params:e.params})}})),app.get("/labels/:fileName",(async(e,s)=>{try{var t=await getResultsForFile(e.params.fileName);s.status(200).json({result:t})}catch(t){console.log("app.get('/labels/:fileName') errored out"),s.status(500).send({errormsg:t.message,params:e.params})}})),app.post("/labels/:fileName",(async(e,s)=>{try{const t=await startLabelDetection("video-crime-miner-video-test-bucket",e.params.fileName),a=e.body.input.trim().split(","),o=await createNewLabels(t,a,e.params.fileName);s.status(200).json({jobid:t,created:o})}catch(t){console.log("app.post('/labels/:fileName') errored out"),console.log(e.body),s.status(500).send({errormsg:t.message,params:e.params,query:e.query})}})),app.get("/cases",(async(e,s)=>{try{var t=await getAllCases();console.log(t),s.status(200).json(t)}catch(t){console.log("app.get('/cases') errored out"),console.log(e.body),s.status(500).send({errormsg:t.message,params:e.params,query:e.query})}})),app.get("/cases/:caseId",(async(e,s)=>{try{s.status(200).json("")}catch(t){console.log("app.get('/cases') errored out"),console.log(e.body),s.status(500).send({errormsg:t.message,params:e.params,query:e.query})}})),app.post("/cases",(async(e,s)=>{try{const t=await createNewCase(e.body.name,e.body.description,e.body.tags);s.status(200).json(t)}catch(t){console.log("app.post('/cases') errored out"),console.log(e.body),s.status(500).send({errormsg:t.message,params:e.params,query:e.query})}})),app.get("/files",(async(e,s)=>{const t=await listObjects("video-crime-miner-video-test-bucket");try{return s.status(200).json(t)}catch(e){console.log("app.get('/files') errored out"),s.status(500).send(e)}})),app.get("/download/:file",(async(e,s)=>{try{var t=await getObjectFromS3("video-crime-miner-video-test-bucket",e.params.file[0]);return t instanceof Readable&&t.pipe(s),s.status(200)}catch(e){s.status(500).send(e)}})),app.post("/upload",(async(e,s)=>{try{const t=await uploadWithFile("video-crime-miner-video-test-bucket",e.body.file);return console.log(t),s.status(200).json({result:t})}catch(t){console.log("app.post('/upload') We have errored out"),console.log(e.body),s.status(500).send({errormsg:t.message,params:e.params,query:e.query})}}));const NODE_PORT=process.env.NODE_PORT||"8000";app.listen(NODE_PORT,(()=>{console.log(`⚡️  [Node Server]: Server is running at http://localhost:${NODE_PORT}  ⚡️`)}));
//# sourceMappingURL=/sm/573976a9806b3272357334e552f046394f9fc332c74a0513b9d694b982fdb27d.map