Correct typo: "availibility" => "availability
This commit is contained in:
parent
ca0bd47ed8
commit
3f6ff08e6c
@ -1,12 +1,12 @@
|
||||
const db = require('../../data/db');
|
||||
|
||||
module.exports = {
|
||||
addAvailibility,
|
||||
deleteAvailibility,
|
||||
addAvailability,
|
||||
deleteAvailability,
|
||||
};
|
||||
|
||||
function addAvailibility(data) {
|
||||
return db('availibility')
|
||||
function addAvailability(data) {
|
||||
return db('availability')
|
||||
.insert(data)
|
||||
.returning([
|
||||
'id',
|
||||
@ -20,6 +20,6 @@ function addAvailibility(data) {
|
||||
]);
|
||||
}
|
||||
|
||||
function deleteAvailibility(id) {
|
||||
return db('availibility').where({ id }).del();
|
||||
function deleteAvailability(id) {
|
||||
return db('availability').where({ id }).del();
|
||||
}
|
@ -7,7 +7,7 @@ module.exports = {
|
||||
deleteMeeting,
|
||||
getParticipantsByMeetingId,
|
||||
getPossibleDatesByMeetingId,
|
||||
getAvailibilityByMeetingId,
|
||||
getAvailabilityByMeetingId,
|
||||
};
|
||||
|
||||
function addMeeting(data) {
|
||||
@ -82,8 +82,8 @@ function getPossibleDatesByMeetingId(meeting_id) {
|
||||
.where({ meeting_id });
|
||||
}
|
||||
|
||||
function getAvailibilityByMeetingId(meeting_id) {
|
||||
return db('availibility as a')
|
||||
function getAvailabilityByMeetingId(meeting_id) {
|
||||
return db('availability as a')
|
||||
.select(
|
||||
'a.id',
|
||||
'a.meeting_id',
|
||||
|
@ -2,17 +2,17 @@ const express = require('express');
|
||||
const router = express.Router();
|
||||
|
||||
const { authenticate } = require('../../middlewares/authenticate');
|
||||
const Availibility = require('../models/availibilityModel');
|
||||
const Availability = require('../models/availabilityModel');
|
||||
|
||||
router.post('/', authenticate, async (req, res) => {
|
||||
const data = { ...req.body };
|
||||
|
||||
try {
|
||||
const [availibility] = await Availibility.addAvailibility(data);
|
||||
res.status(201).json(availibility);
|
||||
const [availability] = await Availability.addAvailability(data);
|
||||
res.status(201).json(availability);
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: 'Failed to add a new availibility.',
|
||||
message: 'Failed to add a new availability.',
|
||||
error,
|
||||
});
|
||||
}
|
||||
@ -22,13 +22,13 @@ router.delete('/:id', authenticate, async (req, res) => {
|
||||
const id = req.params.id;
|
||||
|
||||
try {
|
||||
const availibility = await Availibility.deleteAvailibility(id);
|
||||
const availability = await Availability.deleteAvailability(id);
|
||||
res.status(200).json({
|
||||
message: `Availibility with id ${id} successfully deleted.`,
|
||||
message: `Availability with id ${id} successfully deleted.`,
|
||||
});
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: `Failed to delete availibility with id ${id}.`,
|
||||
message: `Failed to delete availability with id ${id}.`,
|
||||
error,
|
||||
});
|
||||
}
|
@ -130,24 +130,29 @@ router.get(
|
||||
},
|
||||
);
|
||||
|
||||
router.get('/:id/availibility', authenticate, validateMeetingID, async (req, res) => {
|
||||
router.get(
|
||||
'/:id/availability',
|
||||
authenticate,
|
||||
validateMeetingID,
|
||||
async (req, res) => {
|
||||
const id = req.params.id;
|
||||
|
||||
try {
|
||||
const availibility = await Meeting.getAvailibilityByMeetingId(id);
|
||||
if (availibility.length == 0) {
|
||||
const availability = await Meeting.getAvailabilityByMeetingId(id);
|
||||
if (availability.length == 0) {
|
||||
res.status(200).json({
|
||||
message: `There are no possibles dates for meeting with id ${id}.`,
|
||||
});
|
||||
} else {
|
||||
res.status(200).json(availibility);
|
||||
res.status(200).json(availability);
|
||||
}
|
||||
} catch (error) {
|
||||
res.status(500).json({
|
||||
message: `Failed to fetch availibility for meeting with id ${id}`,
|
||||
message: `Failed to fetch availability for meeting with id ${id}`,
|
||||
error,
|
||||
});
|
||||
}
|
||||
});
|
||||
},
|
||||
);
|
||||
|
||||
module.exports = router;
|
||||
|
@ -8,7 +8,7 @@ const accountsRoute = require('./routes/accountRoute');
|
||||
const meetingsRoute = require('./routes/meetingRoute');
|
||||
const participantsRoute = require('./routes/participantRoute');
|
||||
const possibleDatesRoute = require('./routes/possibleDateRoute');
|
||||
const availibilityRoute = require('./routes/availibilityRoute');
|
||||
const availabilityRoute = require('./routes/availabilityRoute');
|
||||
const authRoute = require('./routes/authRoute');
|
||||
|
||||
const server = express();
|
||||
@ -31,7 +31,7 @@ server.use('/api/accounts', accountsRoute);
|
||||
server.use('/api/meetings', meetingsRoute);
|
||||
server.use('/api/participants', participantsRoute);
|
||||
server.use('/api/possible-dates', possibleDatesRoute);
|
||||
server.use('/api/availibility', availibilityRoute);
|
||||
server.use('/api/availability', availabilityRoute);
|
||||
server.use('/api/auth', authRoute);
|
||||
|
||||
server.get('/', (req, res) =>
|
||||
|
@ -1,5 +1,5 @@
|
||||
exports.up = (knex) => {
|
||||
return knex.schema.createTable('availibility', (table) => {
|
||||
return knex.schema.createTable('availability', (table) => {
|
||||
table.increments('id').primary();
|
||||
|
||||
// Reference to participant composite primary key
|
||||
@ -25,5 +25,5 @@ exports.up = (knex) => {
|
||||
};
|
||||
|
||||
exports.down = (knex) => {
|
||||
return knex.schema.dropTable('availibility');
|
||||
return knex.schema.dropTable('availability');
|
||||
};
|
@ -1,10 +1,10 @@
|
||||
exports.seed = function (knex) {
|
||||
// Deletes ALL existing entries
|
||||
return knex('availibility')
|
||||
return knex('availability')
|
||||
.del()
|
||||
.then(function () {
|
||||
// Inserts seed entries
|
||||
return knex('availibility').insert([
|
||||
return knex('availability').insert([
|
||||
// Meeting 1 - Day 1
|
||||
{
|
||||
account_id: 1,
|
Loading…
Reference in New Issue
Block a user