feat: Split v1 and v2 apis

This commit is contained in:
Josepablo C
2024-08-05 15:33:23 -06:00
parent 49ee7d7b5a
commit c3f0b08cb7
149 changed files with 284 additions and 33 deletions

View File

@@ -0,0 +1,22 @@
"use strict";
const { ROOT_PATH, LIB_PATH, MODELS_PATH, API_CONFIG } = process.env;
const { downloadFile } = require(`${ROOT_PATH}/${LIB_PATH}/Misc`);
const apiConfig = require( `${ROOT_PATH}/${API_CONFIG}` );
const s3Bucket = apiConfig.S3.bucket;
const s3BucketKey = apiConfig.S3.load_attachments_key;
const getAttachmentFile = async(req, res) => {
try{
const attachmentId = req.params.id;
const file = await downloadFile( s3Bucket, s3BucketKey, attachmentId );
res.attachment( attachmentId );
res.setHeader('Content-Type', file.ContentType );
res.send( file.Body );
}catch( error ){
console.error( error );
res.status(500).send({ error });
}
}
module.exports = { getAttachmentFile };