diff --git a/README.md b/README.md index d43f402..3c11cb8 100644 --- a/README.md +++ b/README.md @@ -29,10 +29,8 @@ DESAFIO: ● Telefone - phone ● Data de nascimento - birthday - - ● Foto - picture - - ● Foto caminho - picturePath (adicionado por mim) + + ● Foto - picturePath ● Data de criação do registro - createdAt diff --git a/db/migrate/migration.js b/db/migrate/migration.js index e935c6e..f5b034f 100644 --- a/db/migrate/migration.js +++ b/db/migrate/migration.js @@ -10,7 +10,6 @@ module.exports = function createTable() { phone VARCHAR NOT NULL, gender CHAR(1) NOT NULL, birthday DATE NOT NULL, - picture VARCHAR NOT NULL, picturePath VARCHAR NOT NULL, createdAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, updatedAt TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP diff --git a/docker-compose.yml b/docker-compose.yml index 168c125..f258051 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -12,8 +12,8 @@ services: POSTGRES_DB: contacts_app PG_DATA: /var/lib/postgresql/data/db-data/ PORT: 3000 - AWS_ACCESS_KEY_ID: - AWS_SECRET_ACCESS_KEY: + AWS_ACCESS_KEY_ID: AKIATD2VUQXJZMQUXCP2 + AWS_SECRET_ACCESS_KEY: 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 AWS_DEFAULT_REGION: sa-east-1 command: yarn start ports: diff --git a/src/app/controllers/ContactController.js b/src/app/controllers/ContactController.js index 3f94a5e..73c900c 100644 --- a/src/app/controllers/ContactController.js +++ b/src/app/controllers/ContactController.js @@ -32,9 +32,7 @@ class ContactsController { } async store(req,res) { const {name, email, gender, birthday, phone} = req.body; - const picture = req.file.originalname; const picturePath = req.file.location; - console.log(req.file); if(!name && !email && !gender && !birthday && !phone && !picture) { return res.status(400).json({ error: 'All fields are required'}); @@ -49,7 +47,7 @@ class ContactsController { if(contactExists) { return res.status(400).json({ error: 'This e-mail is already in use'}); } - const contact = await ContactsRepository.create({name,email,gender,birthday,phone,picture,picturePath});; + const contact = await ContactsRepository.create({name,email,gender,birthday,phone,picturePath});; res.json(contact); } diff --git a/src/app/repositories/ContactsRepository.js b/src/app/repositories/ContactsRepository.js index ec3162e..fb97a53 100644 --- a/src/app/repositories/ContactsRepository.js +++ b/src/app/repositories/ContactsRepository.js @@ -2,8 +2,8 @@ const db = require('../../../db/db'); class ContactsRepository { - async create({name, email, phone, gender, picture, picturePath,birthday,}) { - const row = await db.query('INSERT INTO contacts(name,email,phone,gender,picture,birthday,picturePath) VALUES($1,$2,$3,$4,$5,$6,$7) RETURNING *',[name,email,phone,gender,picturePath,birthday,picturePath]); + async create({name, email, phone, gender, picturePath,birthday,}) { + const row = await db.query('INSERT INTO contacts(name,email,phone,gender,birthday,picturePath) VALUES($1,$2,$3,$4,$5,$6) RETURNING *',[name,email,phone,gender,birthday,picturePath]); return row[0]; }