From b4a1e4ca7994e48936cca485dff9af4437b13864 Mon Sep 17 00:00:00 2001 From: Clifton Campbell Date: Thu, 3 Sep 2020 10:46:21 -0700 Subject: [PATCH] revert commas, rmv log --- server/server.js | 45 ++++++++++++++++++++++----------------------- 1 file changed, 22 insertions(+), 23 deletions(-) diff --git a/server/server.js b/server/server.js index d95b996..1e279e5 100644 --- a/server/server.js +++ b/server/server.js @@ -15,13 +15,13 @@ const makeFileLocation = (file) => `${config.AWS_BUCKET_URL}/${file.Key}`; const s3 = new AWS.S3({ accessKeyId: config.AWS_ACCESS_KEY_ID, secretAccessKey: config.AWS_SECRET_ACCESS_KEY, - region: config.AWS_REGION, + region: config.AWS_REGION }); const auth = basicAuth({ users: { - [config.AUTH_USERNAME]: config.AUTH_PASSWORD, - }, + [config.AUTH_USERNAME]: config.AUTH_PASSWORD + } }); const app = express(); @@ -39,7 +39,7 @@ const storage = multer.diskStorage({ filename = `${Date.now()}.webm`; } cb(null, filename); - }, + } }); const upload = multer({ storage }); @@ -50,7 +50,7 @@ const listGifs = async () => { try { const params = { Bucket: config.AWS_BUCKET_NAME, - Prefix: GREETING_PREFIX, + Prefix: GREETING_PREFIX }; const getAllContents = async (PrevContents = [], NextContinuationToken) => { @@ -59,7 +59,7 @@ const listGifs = async () => { ...params, ...(NextContinuationToken ? { ContinuationToken: NextContinuationToken } - : {}), + : {}) }) .promise(); const Contents = [...PrevContents, ...result.Contents]; @@ -72,7 +72,7 @@ const listGifs = async () => { const OrderedContents = Contents.map((file) => ({ ...file, - Location: makeFileLocation(file), + Location: makeFileLocation(file) })).reverse(); return OrderedContents; @@ -91,12 +91,12 @@ const groupPhotoPath = 'public/group_photo.jpeg'; app.post('/getGroupPhoto', async (_, res) => { const params = { Bucket: config.AWS_BUCKET_NAME, - Prefix: groupPhotoPath, + Prefix: groupPhotoPath }; const result = await s3.listObjects(params).promise(); result.Contents = result.Contents.map((file) => ({ ...file, - Location: makeFileLocation(file), + Location: makeFileLocation(file) })); res.send(result); }); @@ -111,7 +111,7 @@ app.post('/createGroupPhoto', async (_, res) => { Bucket: config.AWS_BUCKET_NAME, Body: stream, ContentType: 'image/png', - ACL: 'public-read', + ACL: 'public-read' }; s3.upload(params, (err, data) => { if (err) { @@ -119,7 +119,6 @@ app.post('/createGroupPhoto', async (_, res) => { } else { console.log(`Group Photo Uploaded to s3: ${groupPhotoPath}`); data.LastModified = Date.now(); - console.log(data) res.send(data); } }); @@ -137,7 +136,7 @@ const uploadGIF = async (res, filename, folderName, onSuccess) => { Bucket: config.AWS_BUCKET_NAME, Body: fileStream, ContentType: 'image/gif', - ACL: 'public-read', + ACL: 'public-read' }; await s3 @@ -160,7 +159,7 @@ app.post('/uploadUserGIF', upload.single('gif'), async (req, res) => { if (!gif) { res.status(400).send({ status: false, - data: 'No file is selected.', + data: 'No file is selected.' }); } else { const filename = gif.filename.replace('.gif', ''); @@ -172,10 +171,10 @@ app.post('/uploadGIF', ({ body }, res) => { const { filename } = body; uploadGIF(res, filename, 'temp', () => { fs.unlink(`uploads/${filename}.webm`, () => - console.log('.webm file was deleted'), + console.log('.webm file was deleted') ); fs.unlink(`uploads/${filename}.png`, () => - console.log('.png file was deleted'), + console.log('.png file was deleted') ); }); }); @@ -199,10 +198,10 @@ app.post('/video2gif', upload.none(), ({ body }, res) => { y: '(h-text_h)*.95', shadowcolor: 'black', shadowx: 2, - shadowy: 2, + shadowy: 2 }, - inputs: 'c', - }, + inputs: 'c' + } ]) .on('end', () => { res.send(body); @@ -220,7 +219,7 @@ app.post('/uploadBlob', upload.single('video'), ({ file }, res) => { .screenshots({ timestamps: [0], filename, - size: '320x240', + size: '320x240' }) .on('end', () => { res.send(file); @@ -235,7 +234,7 @@ app.get('/img', (req, res) => { const ext = filename.split('/').pop(); const head = { 'Content-Length': fileSize, - 'Content-Type': `image/${ext}`, + 'Content-Type': `image/${ext}` }; res.writeHead(200, head); fs.createReadStream(path).pipe(res); @@ -254,7 +253,7 @@ app.get('/s3-download', async (req, res) => { const { filename } = req.query; const params = { Bucket: config.AWS_BUCKET_NAME, - Key: filename, + Key: filename }; s3.getObject(params, (err, data) => { if (err) console.log(err, err.stack); @@ -268,7 +267,7 @@ app.delete('/deleteObj', auth, ({ body }, res) => { const { filename } = body; const params = { Bucket: config.AWS_BUCKET_NAME, - Key: filename, + Key: filename }; s3.deleteObject(params, (err, data) => { if (err) console.log(err, err.stack); @@ -278,7 +277,7 @@ app.delete('/deleteObj', auth, ({ body }, res) => { app.use(express.static(path.join(__dirname, '../client/build'))); app.get('/*', (req, res) => - res.sendFile(path.join(__dirname, '../client/build', 'index.html')), + res.sendFile(path.join(__dirname, '../client/build', 'index.html')) ); app.listen(app.get('port'), () => {