From 50fec1000eb392e67261249662d99daea21f9332 Mon Sep 17 00:00:00 2001 From: Mohamed Ashraf <55748253+dager-mohamed@users.noreply.github.com> Date: Tue, 13 Aug 2024 08:52:57 +0000 Subject: [PATCH] fix: fixning error in dirS3Sync app --- README.md | 15 ++-- apps/dirS3Sync/src/utils/aws/deleteFromS3.ts | 2 +- apps/dirS3Sync/src/utils/aws/uploadToS3.ts | 10 +-- package-lock.json | 74 ++++++++++++++++++++ package.json | 5 +- 5 files changed, 86 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 72d9481..0b576bf 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,7 @@ - Install packages
```npm install``` +- Make sure docker & docker-compose installed ## Setup @@ -11,13 +12,9 @@ - Setup an AWS account: 1. Fill in the aws crednetials inside the env file. - 2. Create an S3 bucket. + 2. Create an S3 bucket then fill the bucket name inside the .env file. 3. Create a cloudfront distribution. - 4. IMPORTANT: if this error occured (`Your account must be verified before you can add new CloudFront resources`) while create a cloudfront distribution, please see [this](https://maxrohde.com/2022/06/10/solving-error-creating-cloudfront-distribution-accessdenied-your-account-must-be-verified/). -- Run the backend app in development mode
- ```npm run dev:backend``` -- Run the frontend app in development mode
- ```npm run dev:web``` -- Run the RTMP Server & HLS transcoder [important]:
- 1. ```docker-compose build```
- 2. ```docker-compose up``` \ No newline at end of file + 4. IMPORTANT: if this error occured (`Your account must be verified before you can add new CloudFront resources`) while creating a cloudfront distribution, please see [this](https://maxrohde.com/2022/06/10/solving-error-creating-cloudfront-distribution-accessdenied-your-account-must-be-verified/). +- Run ```npm run dev``` +- Run the RTMP Server, HLS transcoder and the S3 directory sync [important]:
+ - ```npm run docker``` \ No newline at end of file diff --git a/apps/dirS3Sync/src/utils/aws/deleteFromS3.ts b/apps/dirS3Sync/src/utils/aws/deleteFromS3.ts index b31d3a4..cacbb6c 100644 --- a/apps/dirS3Sync/src/utils/aws/deleteFromS3.ts +++ b/apps/dirS3Sync/src/utils/aws/deleteFromS3.ts @@ -10,5 +10,5 @@ export function deleteFromS3(filePath: string) { Key: path.basename(filePath), }) ) - .catch((err) => console.log(err)); + .catch((err) => console.error(err)); } diff --git a/apps/dirS3Sync/src/utils/aws/uploadToS3.ts b/apps/dirS3Sync/src/utils/aws/uploadToS3.ts index a0708bf..0a0178c 100644 --- a/apps/dirS3Sync/src/utils/aws/uploadToS3.ts +++ b/apps/dirS3Sync/src/utils/aws/uploadToS3.ts @@ -9,14 +9,6 @@ export function uploadToS3(filePath: string) { const fileContent = fs.readFileSync(filePath); - awsS3Client - .send( - new CreateBucketCommand({ - Bucket: process.env.AWS_S3_BUCKET, - }) - ) - .catch((err) => console.log(err)); - awsS3Client .send( new PutObjectCommand({ @@ -25,5 +17,5 @@ export function uploadToS3(filePath: string) { Body: fileContent, }) ) - .catch((err) => console.log(err)); + .catch((err) => console.error(err)); } diff --git a/package-lock.json b/package-lock.json index c2a2d94..5f3e3fd 100644 --- a/package-lock.json +++ b/package-lock.json @@ -63,6 +63,7 @@ "@typescript-eslint/parser": "^7.16.0", "autoprefixer": "10.4.13", "babel-jest": "^29.4.1", + "concurrently": "^8.2.2", "esbuild": "^0.19.2", "eslint": "~8.57.0", "eslint-config-next": "14.2.3", @@ -10621,6 +10622,48 @@ "safe-buffer": "~5.1.0" } }, + "node_modules/concurrently": { + "version": "8.2.2", + "resolved": "https://registry.npmjs.org/concurrently/-/concurrently-8.2.2.tgz", + "integrity": "sha512-1dP4gpXFhei8IOtlXRE/T/4H88ElHgTiUzh71YUmtjTEHMSRS2Z/fgOxHSxxusGHogsRfxNq1vyAwxSC+EVyDg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.2", + "date-fns": "^2.30.0", + "lodash": "^4.17.21", + "rxjs": "^7.8.1", + "shell-quote": "^1.8.1", + "spawn-command": "0.0.2", + "supports-color": "^8.1.1", + "tree-kill": "^1.2.2", + "yargs": "^17.7.2" + }, + "bin": { + "conc": "dist/bin/concurrently.js", + "concurrently": "dist/bin/concurrently.js" + }, + "engines": { + "node": "^14.13.0 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/open-cli-tools/concurrently?sponsor=1" + } + }, + "node_modules/concurrently/node_modules/supports-color": { + "version": "8.1.1", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz", + "integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/supports-color?sponsor=1" + } + }, "node_modules/confusing-browser-globals": { "version": "1.0.11", "resolved": "https://registry.npmjs.org/confusing-browser-globals/-/confusing-browser-globals-1.0.11.tgz", @@ -11280,6 +11323,22 @@ "url": "https://github.com/sponsors/ljharb" } }, + "node_modules/date-fns": { + "version": "2.30.0", + "resolved": "https://registry.npmjs.org/date-fns/-/date-fns-2.30.0.tgz", + "integrity": "sha512-fnULvOpxnC5/Vg3NCiWelDsLiUc9bRwAPs/+LfTLNvetFCtCTN+yQz15C/fs4AwX1R9K5GLtLfn8QW+dWisaAw==", + "dev": true, + "dependencies": { + "@babel/runtime": "^7.21.0" + }, + "engines": { + "node": ">=0.11" + }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/date-fns" + } + }, "node_modules/date-format": { "version": "4.0.14", "resolved": "https://registry.npmjs.org/date-format/-/date-format-4.0.14.tgz", @@ -21104,6 +21163,12 @@ "source-map": "^0.6.0" } }, + "node_modules/spawn-command": { + "version": "0.0.2", + "resolved": "https://registry.npmjs.org/spawn-command/-/spawn-command-0.0.2.tgz", + "integrity": "sha512-zC8zGoGkmc8J9ndvml8Xksr1Amk9qBujgbF0JAIWO7kXr43w0h/0GJNM/Vustixu+YE8N/MTrQ7N31FvHUACxQ==", + "dev": true + }, "node_modules/spdy": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/spdy/-/spdy-4.0.2.tgz", @@ -22300,6 +22365,15 @@ "node": ">=12" } }, + "node_modules/tree-kill": { + "version": "1.2.2", + "resolved": "https://registry.npmjs.org/tree-kill/-/tree-kill-1.2.2.tgz", + "integrity": "sha512-L0Orpi8qGpRG//Nd+H90vFB+3iHnue1zSSGmNOOCh1GLJ7rUKVwV2HvijphGQS2UmhUZewS9VgvxYIdgr+fG1A==", + "dev": true, + "bin": { + "tree-kill": "cli.js" + } + }, "node_modules/trim-repeated": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/trim-repeated/-/trim-repeated-2.0.0.tgz", diff --git a/package.json b/package.json index f971a66..9692119 100644 --- a/package.json +++ b/package.json @@ -5,7 +5,9 @@ "scripts": { "dev:web": "npx nx run web:dev", "dev:backend": "npx nx serve backend", - "dev:watcher": "npx nx run dirS3Sync:serve" + "dev:watcher": "npx nx run dirS3Sync:serve", + "dev": "concurrently \"npm run dev:web\" \"npm run dev:backend\" \"npm run dev:watcher\"", + "docker": "docker-compose up --build" }, "private": true, "dependencies": { @@ -63,6 +65,7 @@ "@typescript-eslint/parser": "^7.16.0", "autoprefixer": "10.4.13", "babel-jest": "^29.4.1", + "concurrently": "^8.2.2", "esbuild": "^0.19.2", "eslint": "~8.57.0", "eslint-config-next": "14.2.3",