Skip to content

Commit

Permalink
Feature/redis (#37)
Browse files Browse the repository at this point in the history
  • Loading branch information
hebertzin authored Jun 23, 2024
1 parent 42f3e43 commit ad2f096
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
13 changes: 7 additions & 6 deletions .env.exemple
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
ACCESS_KEY='your_aws_access_key'
SECRET_KEY='your_aws_acess_key'
REGION='your_aws_region'
PORT=3000

ACCESS_KEY='AKIARTHMAEH7HDOPCZNB'
SECRET_KEY='I180VmpZXL78aB94uzcvC'
REGION='us-east-2'
PORT=53821
REDIS_PORT=53821
REDIS_HOST="redis_host"
REDIS_PASSWORD="redis_password"
REDIS_HOST="roundhouse.proxy.rlwy.net"
REDIS_PASSWORD="QFvhQhJZguIxezirtwsxHMhEovYYMBmb"
4 changes: 4 additions & 0 deletions src/controllers/upload-file-controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,10 @@ export class UploadController {

const data = await this.uploadService.invoke(file)

if (data) {
return response.json({ msg: 'file already exist' })
}

return response.status(HttpStatusCode.Created).json(data)
} catch (error) {
return response
Expand Down
3 changes: 2 additions & 1 deletion src/routes/upload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@ import { listFilesControllerHandler } from '../controllers/list-all-files-contro
import { listFileByIdControllerHandler } from '../controllers/list-file-by-id-controller'
import { fileValidatorMiddleware } from '../middleware/validate-files'
import { Request, Response } from 'express'
import { uploadFileControllerHandler } from '../controllers/upload-file-controller'
export const upload = Router()

upload.post(
'/files/upload',
storage.single('file'),
fileValidatorMiddleware.validateFile.bind(fileValidatorMiddleware),
async (req: Request, res: Response) => {
uploadFilesControllerHandler.handle(req, res)
uploadFileControllerHandler.handle(req, res)
},
)

Expand Down

0 comments on commit ad2f096

Please sign in to comment.