Fix id spreadng order bug and consistency in use
This commit is contained in:
parent
3490f71fc3
commit
ac2b6c2b88
@ -8,8 +8,8 @@ const { validateAccountID } = require('../../middlewares/validateAccountID');
|
||||
|
||||
const Account = require('../models/accountModel');
|
||||
|
||||
// TODO : remove if unused
|
||||
router.post('/', async (req, res) => {
|
||||
// TODO : remove if unused
|
||||
const data = { ...req.body };
|
||||
const hash = bcrypt.hashSync(data.password, saltingRounds);
|
||||
data.password = hash;
|
||||
@ -24,7 +24,7 @@ router.post('/', async (req, res) => {
|
||||
|
||||
router.put('/:id', authenticate, validateAccountID, async (req, res) => {
|
||||
const data = { ...req.body };
|
||||
const id = req.params.id;
|
||||
const { id } = req.params;
|
||||
|
||||
if (data.password) {
|
||||
const hash = bcrypt.hashSync(data.password, 10);
|
||||
@ -43,7 +43,7 @@ router.put('/:id', authenticate, validateAccountID, async (req, res) => {
|
||||
});
|
||||
|
||||
router.delete('/:id', authenticate, validateAccountID, async (req, res) => {
|
||||
const id = req.params.id;
|
||||
const { id } = req.params;
|
||||
|
||||
try {
|
||||
const account = await Account.deleteAccount(id);
|
||||
@ -84,7 +84,7 @@ router.get(
|
||||
);
|
||||
|
||||
router.get('/:id', authenticate, async (req, res) => {
|
||||
const id = req.params.id;
|
||||
const { id } = req.params;
|
||||
|
||||
try {
|
||||
const account = await Account.getAccountById(id);
|
||||
|
@ -19,7 +19,7 @@ router.post('/', authenticate, async (req, res) => {
|
||||
});
|
||||
|
||||
router.delete('/:id', authenticate, async (req, res) => {
|
||||
const id = req.params.id;
|
||||
const { id } = req.params;
|
||||
|
||||
try {
|
||||
const availability = await Availability.deleteAvailability(id);
|
||||
|
@ -9,7 +9,8 @@ const Meeting = require('../models/meetingModel');
|
||||
|
||||
router.post('/', authenticate, async (req, res) => {
|
||||
id = uuidv4();
|
||||
data = { id, ...req.body };
|
||||
|
||||
data = { ...req.body, id };
|
||||
|
||||
if (data.password) {
|
||||
const hash = bcrypt.hashSync(data.password, 14);
|
||||
@ -20,13 +21,14 @@ router.post('/', authenticate, async (req, res) => {
|
||||
const [meeting] = await Meeting.addMeeting(data);
|
||||
res.status(201).json(meeting);
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
res.status(500).json({ message: 'Failed to add new meeting.', error });
|
||||
}
|
||||
});
|
||||
|
||||
router.put('/:id', authenticate, validateMeetingID, async (req, res) => {
|
||||
const data = { ...req.body };
|
||||
const id = req.params.id;
|
||||
const { id } = req.params;
|
||||
|
||||
if (data.password) {
|
||||
const hash = bcrypt.hashSync(data.password, 14);
|
||||
@ -45,7 +47,7 @@ router.put('/:id', authenticate, validateMeetingID, async (req, res) => {
|
||||
});
|
||||
|
||||
router.delete('/:id', authenticate, validateMeetingID, async (req, res) => {
|
||||
const id = req.params.id;
|
||||
const { id } = req.params;
|
||||
|
||||
try {
|
||||
const meeting = await Meeting.deleteMeeting(id);
|
||||
@ -61,7 +63,7 @@ router.delete('/:id', authenticate, validateMeetingID, async (req, res) => {
|
||||
});
|
||||
|
||||
router.get('/:id', authenticate, async (req, res) => {
|
||||
const id = req.params.id;
|
||||
const { id } = req.params;
|
||||
|
||||
try {
|
||||
const meeting = await Meeting.getMeetingById(id);
|
||||
@ -85,7 +87,7 @@ router.get(
|
||||
authenticate,
|
||||
validateMeetingID,
|
||||
async (req, res) => {
|
||||
const id = req.params.id;
|
||||
const { id } = req.params;
|
||||
|
||||
try {
|
||||
const participants = await Meeting.getParticipantsByMeetingId(id);
|
||||
@ -110,7 +112,7 @@ router.get(
|
||||
authenticate,
|
||||
validateMeetingID,
|
||||
async (req, res) => {
|
||||
const id = req.params.id;
|
||||
const { id } = req.params;
|
||||
|
||||
try {
|
||||
const possibleDates = await Meeting.getPossibleDatesByMeetingId(id);
|
||||
@ -135,7 +137,7 @@ router.get(
|
||||
authenticate,
|
||||
validateMeetingID,
|
||||
async (req, res) => {
|
||||
const id = req.params.id;
|
||||
const { id } = req.params;
|
||||
|
||||
try {
|
||||
const availability = await Meeting.getAvailabilityByMeetingId(id);
|
||||
|
@ -10,7 +10,7 @@ const Participant = require('../models/participantModel');
|
||||
|
||||
router.post('/', authenticate, async (req, res) => {
|
||||
id = uuidv4();
|
||||
const data = { id, ...req.body };
|
||||
const data = { ...req.body, id };
|
||||
|
||||
try {
|
||||
const [participant] = await Participant.addParticipant(data);
|
||||
|
@ -19,7 +19,7 @@ router.post('/', authenticate, async (req, res) => {
|
||||
});
|
||||
|
||||
router.delete('/:id', authenticate, async (req, res) => {
|
||||
const id = req.params.id;
|
||||
const { id } = req.params;
|
||||
|
||||
try {
|
||||
const possibleDate = await PossibleDate.deletePossibleDate(id);
|
||||
|
Loading…
Reference in New Issue
Block a user