├── .gitattributes ├── .gitignore ├── .idea ├── $PRODUCT_WORKSPACE_FILE$ ├── .gitignore ├── NodeJS-Booking-App.iml ├── jsLibraryMappings.xml ├── misc.xml ├── modules.xml └── vcs.xml ├── JSDoc ├── ReqHandlers_GET-Handlers_days.js.html ├── ReqHandlers_GET-Handlers_timeslots.js.html ├── ReqHandlers_POST-Handlers_book.js.html ├── Utility_appUtil.js.html ├── Utility_gcal.js.html ├── Utility_requirement-validator.js.html ├── fonts │ ├── OpenSans-Bold-webfont.eot │ ├── OpenSans-Bold-webfont.svg │ ├── OpenSans-Bold-webfont.woff │ ├── OpenSans-BoldItalic-webfont.eot │ ├── OpenSans-BoldItalic-webfont.svg │ ├── OpenSans-BoldItalic-webfont.woff │ ├── OpenSans-Italic-webfont.eot │ ├── OpenSans-Italic-webfont.svg │ ├── OpenSans-Italic-webfont.woff │ ├── OpenSans-Light-webfont.eot │ ├── OpenSans-Light-webfont.svg │ ├── OpenSans-Light-webfont.woff │ ├── OpenSans-LightItalic-webfont.eot │ ├── OpenSans-LightItalic-webfont.svg │ ├── OpenSans-LightItalic-webfont.woff │ ├── OpenSans-Regular-webfont.eot │ ├── OpenSans-Regular-webfont.svg │ └── OpenSans-Regular-webfont.woff ├── global.html ├── index.html ├── scripts │ ├── linenumber.js │ └── prettify │ │ ├── Apache-License-2.0.txt │ │ ├── lang-css.js │ │ └── prettify.js ├── server.js.html └── styles │ ├── jsdoc-default.css │ ├── prettify-jsdoc.css │ └── prettify-tomorrow.css ├── LICENSE ├── README.md ├── ReqHandlers ├── GET-Handlers │ ├── days.js │ └── timeslots.js └── POST-Handlers │ └── book.js ├── Utility ├── appUtil.js ├── gcal.js ├── requirement-validator.js └── timeslots.json ├── package-lock.json ├── package.json └── server.js /.gitattributes: -------------------------------------------------------------------------------- 1 | *.html linguist-vendored 2 | *.css linguist-vendored -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /node_modules/ 3 | /Utility/credentials.json 4 | /Utility/token.json -------------------------------------------------------------------------------- /.idea/$PRODUCT_WORKSPACE_FILE$: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 1.8 8 | 9 | 14 | 15 | 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /workspace.xml -------------------------------------------------------------------------------- /.idea/NodeJS-Booking-App.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | -------------------------------------------------------------------------------- /.idea/jsLibraryMappings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 6 | -------------------------------------------------------------------------------- /.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /.idea/vcs.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /JSDoc/ReqHandlers_GET-Handlers_days.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: ReqHandlers/GET-Handlers/days.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: ReqHandlers/GET-Handlers/days.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
const {google} = require('googleapis');
 30 | const reqValidator = require('../../Utility/requirement-validator.js');
 31 | const appUtil = require('../../Utility/appUtil.js');
 32 | 
 33 | /**
 34 |  * Searches through the given events (appointments), sees which appointments span
 35 |  * across a full days timeslots (11). If 11 appointment events are found within a
 36 |  * same day, then the day which those appointments fell on, is added to the bookedDays array.
 37 |  * @param {number} events  Appointment events.
 38 |  * @returns {number[]} bookedDays  An array containing the days that are fully booked.
 39 |  */
 40 | function getBookedDays(events) {
 41 |     let bookedDays = [];
 42 |     let date = null;
 43 |     let prevDate = null;
 44 |     let dayArr = [];
 45 |     for (let event of events) {
 46 |         date = appUtil.getDateFromISO(event.start.dateTime);
 47 |         if (date === prevDate || prevDate === null) {
 48 |             dayArr.push(event);
 49 |         } else {
 50 |             dayArr = []; // Clear array.
 51 |             dayArr.push(event);
 52 |         }
 53 |         prevDate = appUtil.getDateFromISO(event.start.dateTime);
 54 |         if (dayArr.length === 11) {
 55 |             dayArr = []; // Clear array.
 56 |             bookedDays.push(date);
 57 |         }
 58 |     }
 59 |     return bookedDays;
 60 | }
 61 | 
 62 | /**
 63 |  * Uses the bookedDays value returned from getBookedDays() to create an array containing
 64 |  * info on whether the day has any timeslots available or not.
 65 |  * @param {number} endDate  End date of the month.
 66 |  * @param {number[]} bookedDays  An array containing the days that are fully booked.
 67 |  * @returns {object[]} daysArr  An array containing objects which represent the days of
 68 |  * the month, and whether the day has any timeslots available.
 69 |  */
 70 | function makeDaysArr(endDate, bookedDays) {
 71 |     let daysArr = [];
 72 |     for (let i = 1; i <= endDate; i++) {
 73 |         if (bookedDays.includes(i)) {
 74 |             daysArr.push({"day": i, "hasTimeSlots": false});
 75 |         } else {
 76 |             daysArr.push({"day": i, "hasTimeSlots": true});
 77 |         }
 78 |     }
 79 |     return daysArr;
 80 | }
 81 | 
 82 | /**
 83 |  * Returns a promise with data containing objects with information on whether the days in the given
 84 |  * month have any timeslots available. Days with no timeslots are considered fully booked.
 85 |  * @param {object} auth  The oAuth2Client used for authentication for the Google Calendar API.
 86 |  * @param {number} year  Year to search for.
 87 |  * @param {number} month  Month to search for.
 88 |  * @returns {promise}  A promise representing the eventual completion of the getBookableDays() function.
 89 |  */
 90 | function getBookableDays(auth, year, month) {
 91 |     return new Promise(function(resolve, reject) {
 92 |         const isInvalid = reqValidator.validateGetDays(year, month);
 93 |         if (isInvalid) return reject(isInvalid);
 94 | 
 95 |         const startDate = new Date(Date.UTC(year, month-1, appUtil.getCurrDateUTC()));
 96 |         const endDate = new Date((Date.UTC(year, month)));
 97 |         const calendar = google.calendar({version: 'v3', auth});
 98 |         calendar.events.list({
 99 |             calendarId: 'primary',
100 |             timeMin: startDate.toISOString(),
101 |             timeMax: endDate.toISOString(),
102 |             maxResults: 350,
103 |             singleEvents: true,
104 |             orderBy: 'startTime',
105 |             q: 'appointment'
106 |         }, (err, res) => {
107 |             if (err) return reject({success: false,
108 |                 message: 'The API returned an error - ' + err});
109 |             const events = res.data.items;
110 |             const lastDay = appUtil.getLastDayOfMonth(year, month);
111 |             let result = {};
112 |             result.days = makeDaysArr(lastDay, getBookedDays(events));
113 |             const response = Object.assign({success: true}, result);
114 |             resolve(response);
115 |         });
116 |     });
117 | }
118 | 
119 | module.exports = {
120 |     getBookableDays
121 | };
122 |
123 |
124 | 125 | 126 | 127 | 128 |
129 | 130 | 133 | 134 |
135 | 136 | 139 | 140 | 141 | 142 | 143 | 144 | -------------------------------------------------------------------------------- /JSDoc/ReqHandlers_GET-Handlers_timeslots.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: ReqHandlers/GET-Handlers/timeslots.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: ReqHandlers/GET-Handlers/timeslots.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
const fs = require('fs');
 30 | const {google} = require('googleapis');
 31 | const reqValidator = require('../../Utility/requirement-validator.js');
 32 | const appUtil = require('../../Utility/appUtil.js');
 33 | 
 34 | const TIMESLOTS_PATH = './Utility/timeslots.json';
 35 | 
 36 | /**
 37 |  * Returns an array with timeslots; excluding the timeslots that are booked (appointments).
 38 |  * @param {object} appointments  An Object containing info on the appointments booked in the day.
 39 |  * @returns {object[]} resultsArr  An array containing all the available timeslots in the day.
 40 |  */
 41 | function getResult(appointments) {
 42 |     const timeslots = (JSON.parse(fs.readFileSync(TIMESLOTS_PATH))).timeslots;
 43 |     let resultsArr = [];
 44 |     for (let i = 0; i < timeslots.length; i++) {
 45 |         const found = appointments.find(function (element) {
 46 |             const startTime = element.startTime;
 47 |             const finalStartTime = startTime.substring(startTime.indexOf("T"), startTime.indexOf("Z") + 1);
 48 |             return timeslots[i].startTime.includes(finalStartTime);
 49 |         });
 50 |         if (!found) {
 51 |             resultsArr.push(timeslots[i]);
 52 |         }
 53 |     }
 54 |     return resultsArr;
 55 | }
 56 | 
 57 | /**
 58 |  * Returns a promise with data containing objects with information of the timeslots in the given day.
 59 |  * Each object contains the startTime and endTime of the timeslot.
 60 |  * @param {object} auth  The oAuth2Client used for authentication for the Google Calendar API.
 61 |  * @param {number} year  Year to search for.
 62 |  * @param {number} month  Month to search for.
 63 |  * @param {number} day  Day to search for.
 64 |  * @returns {promise}  A promise representing the eventual completion of the getAvailTimeslots() function.
 65 |  */
 66 | function getAvailTimeslots(auth, year, month, day) {
 67 |     return new Promise(function(resolve, reject) {
 68 |         const isInvalid = reqValidator.validateGetTimeslots(year, month, day);
 69 |         if (isInvalid) return reject(isInvalid);
 70 | 
 71 |         const startDate = new Date(Date.UTC(year, month-1, day));
 72 |         const endDate = appUtil.getNextDay(startDate);
 73 |         const calendar = google.calendar({version: 'v3', auth});
 74 |         calendar.events.list({
 75 |             calendarId: 'primary',
 76 |             timeMin: startDate.toISOString(),
 77 |             timeMax: endDate.toISOString(),
 78 |             maxResults: 11,
 79 |             singleEvents: true,
 80 |             orderBy: 'startTime',
 81 |             q: 'appointment'
 82 |         }, (err, res) => {
 83 |             if (err) return reject({response: 'The API returned an error: ' + err});
 84 |             let appointments = res.data.items.map((event, i) => {
 85 |                 return {startTime: event.start.dateTime, endTime: event.end.dateTime};
 86 |             });
 87 |             const result = {};
 88 |             result.timeslots = getResult(appointments);
 89 |             if (result.timeslots[0]) {
 90 |                 const response = Object.assign({success: true}, result);
 91 |                 return resolve(response);
 92 |             } else {
 93 |                 const response = Object.assign({success: false}, result);
 94 |                 return reject(response);
 95 |             }
 96 |         });
 97 |     });
 98 | }
 99 | 
100 | module.exports = {
101 |     getAvailTimeslots
102 | };
103 |
104 |
105 | 106 | 107 | 108 | 109 |
110 | 111 | 114 | 115 |
116 | 117 | 120 | 121 | 122 | 123 | 124 | 125 | -------------------------------------------------------------------------------- /JSDoc/ReqHandlers_POST-Handlers_book.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: ReqHandlers/POST-Handlers/book.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: ReqHandlers/POST-Handlers/book.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
const fs = require('fs');
 30 | const {google} = require('googleapis');
 31 | const reqValidator = require('../../Utility/requirement-validator.js');
 32 | const appUtil = require('../../Utility/appUtil.js');
 33 | 
 34 | const TIMESLOTS_PATH = './Utility/timeslots.json';
 35 | /**
 36 |  * Searches using the provided date for a timeslot matching the hour and minute specified.
 37 |  * @param {object} timeslots  Object containing info on each timeslot for the day.
 38 |  * @param {number} year  Year of the timeslot to search for.
 39 |  * @param {number} month  Month of the timeslot to search for.
 40 |  * @param {number} day  Day of the timeslot to search for.
 41 |  * @param {number} hour  Hour of the timeslot to search for.
 42 |  * @param {number} minute  Minute of the timeslot to search for.
 43 |  * @returns {object}  The timeslot object that was found. If nothing was found, returns undefined.
 44 |  */
 45 | function findMatchingTimeslot(timeslots, year, month, day, hour, minute) {
 46 |     const timeslotDate = new Date(Date.UTC(year, month-1, day, hour, minute)).toISOString();
 47 |     const foundTimeslot = timeslots.find(function (element) {
 48 |         //const elementDate = new Date(element.startTime).toISOString(); // Ensure matching ISO format.
 49 |         return element.startTime.includes(hour + ':' + minute  + ':00');
 50 |     });
 51 |     if (!foundTimeslot) return false;
 52 |     return {time: foundTimeslot, date: timeslotDate};
 53 | }
 54 | 
 55 | /**
 56 |  * Books an appointment using the given date and time information.
 57 |  * @param {object} auth  The oAuth2Client used for authentication for the Google Calendar API.
 58 |  * @param {number} year  Year of the timeslot to book.
 59 |  * @param {number} month  Month of the timeslot to book.
 60 |  * @param {number} day  Day of the timeslot to book.
 61 |  * @param {number} hour  Hour of the timeslot to book.
 62 |  * @param {number} minute  Minute of the timeslot to book.
 63 |  * @returns {promise}  A promise representing the eventual completion of the bookAppointment() function.
 64 |  */
 65 | function bookAppointment(auth, year, month, day, hour, minute) {
 66 |     return new Promise(function(resolve, reject) {
 67 |         const isInvalid = reqValidator.validateBooking(year, month, day, hour, minute);
 68 |         if (isInvalid) return reject(isInvalid);
 69 | 
 70 |         const timeslots = (JSON.parse(fs.readFileSync(TIMESLOTS_PATH))).timeslots;
 71 |         const timeslot = findMatchingTimeslot(timeslots, year, month, day, hour, minute);
 72 |         if (!timeslot) return resolve({success: false, message: 'Invalid time slot'});
 73 |         const date = year + '-' + month + '-' + day;
 74 |         const event = appUtil.makeEventResource(date, timeslot.time.startTime, timeslot.time.endTime);
 75 | 
 76 |         const calendar = google.calendar({version: 'v3', auth});
 77 |         calendar.events.insert({
 78 |             auth: auth,
 79 |             calendarId: 'primary',
 80 |             resource: event
 81 |         }, function (err, res) {
 82 |             if (err) return console.log('Error contacting the Calendar service: ' + err);
 83 |             const event = res.data;
 84 |             console.log('Appointment created: ', event.id);
 85 |             const result = {startTime: event.start.dateTime, endTime: event.end.dateTime};
 86 |             const response = Object.assign({success: true}, result);
 87 |             resolve(response);
 88 |         });
 89 |     });
 90 | }
 91 | 
 92 | module.exports = {
 93 |     bookAppointment
 94 | };
95 |
96 |
97 | 98 | 99 | 100 | 101 |
102 | 103 | 106 | 107 |
108 | 109 | 112 | 113 | 114 | 115 | 116 | 117 | -------------------------------------------------------------------------------- /JSDoc/Utility_appUtil.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: Utility/appUtil.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: Utility/appUtil.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Returns the last day of the month.
 31 |  * @param {number} year  The year.
 32 |  * @param {number} month  The month.
 33 |  * @returns {number}  The last day of the month.
 34 |  */
 35 | function getLastDayOfMonth(year, month) {
 36 |     return (new Date(Date.UTC(year, month, 0))).getUTCDate();
 37 | }
 38 | 
 39 | /**
 40 |  * Returns the current date in the UTC timezone.
 41 |  * @returns {number}
 42 |  */
 43 | function getCurrDateUTC() {
 44 |     const currDate = new Date();
 45 |     return currDate.getUTCDate();
 46 | }
 47 | 
 48 | /**
 49 |  * Returns the date from a given ISOString.
 50 |  * @param {string} dateISOString  The callback for the authorized client.
 51 |  * @returns {number}
 52 |  */
 53 | function getDateFromISO(dateISOString) {
 54 |     const date = new Date(dateISOString);
 55 |     return date.getUTCDate();
 56 | }
 57 | 
 58 | /**
 59 |  * Returns the next date (i.e the day after).
 60 |  * @param {Date} date  The date to get the next day of.
 61 |  * @returns {Date}
 62 |  */
 63 | function getNextDay(date) {
 64 |     let tomorrow = new Date(date);
 65 |     tomorrow.setDate(date.getUTCDate() + 1); // Returns epoch value.
 66 |     return new Date(tomorrow); // Convert from epoch to Date.
 67 | }
 68 | 
 69 | /**
 70 |  * Creates and returns a Google Calendars 'events resource'.
 71 |  * @param {string} date  A string in the following format: 'Year-month-day'.
 72 |  * @param {string} startTime  The start time to associate with the 'start dateTime'.
 73 |  * @param {string} endTime  The end time to associate with the 'end dateTime'.
 74 |  * @returns {object}  A Google Calendars 'events resource'.
 75 |  */
 76 | function makeEventResource(date, startTime, endTime) {
 77 |     return {
 78 |         'summary': 'appointment',
 79 |         'start': {
 80 |             'dateTime': date + startTime,
 81 |             'timeZone': 'UTC',
 82 |         },
 83 |         'end': {
 84 |             'dateTime': date + endTime,
 85 |             'timeZone': 'UTC',
 86 |         }
 87 |     };
 88 | }
 89 | 
 90 | module.exports = {
 91 |     getLastDayOfMonth,
 92 |     getCurrDateUTC,
 93 |     getDateFromISO,
 94 |     getNextDay,
 95 |     makeEventResource
 96 | };
97 |
98 |
99 | 100 | 101 | 102 | 103 |
104 | 105 | 108 | 109 |
110 | 111 | 114 | 115 | 116 | 117 | 118 | 119 | -------------------------------------------------------------------------------- /JSDoc/Utility_gcal.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: Utility/gcal.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: Utility/gcal.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * @license
 31 |  * Copyright Google Inc.
 32 |  *
 33 |  * Licensed under the Apache License, Version 2.0 (the "License");
 34 |  * you may not use this file except in compliance with the License.
 35 |  * You may obtain a copy of the License at
 36 |  *
 37 |  *     https://www.apache.org/licenses/LICENSE-2.0
 38 |  *
 39 |  * Unless required by applicable law or agreed to in writing, software
 40 |  * distributed under the License is distributed on an "AS IS" BASIS,
 41 |  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 42 |  * See the License for the specific language governing permissions and
 43 |  * limitations under the License.
 44 |  */
 45 | 
 46 | const fs = require('fs');
 47 | const readline = require('readline');
 48 | const {google} = require('googleapis');
 49 | 
 50 | // If modifying these scopes, delete token.json.
 51 | const SCOPES = ['https://www.googleapis.com/auth/calendar'];
 52 | // The file token.json stores the user's access and refresh tokens, and is
 53 | // created automatically when the authorization flow completes for the first
 54 | // time.
 55 | const TOKEN_PATH = './Utility/token.json';
 56 | const CREDENTIALS_PATH = './Utility/credentials.json';
 57 | 
 58 | // Load client secrets from a local file.
 59 | function initAuthorize(callback) {
 60 |     fs.readFile(CREDENTIALS_PATH, (err, content) => {
 61 |         if (err) {
 62 |             console.log('The credentials.json file could not be found or was invalid. \n' +
 63 |                 'Please visit: https://developers.google.com/calendar/quickstart/nodejs \n' +
 64 |                 'and generate a credentials.json file from that site. Then, place your \n' +
 65 |                 'credentials file into the "Utility" directory of this application.');
 66 |             process.exit(1);
 67 |         }
 68 |         // Authorize a client with credentials, then call the Google Calendar API.
 69 |         authorize(JSON.parse(content), callback);
 70 |     });
 71 | }
 72 | 
 73 | /**
 74 |  * Create an OAuth2 client with the given credentials, and then execute the
 75 |  * given callback function.
 76 |  * @param {Object} credentials The authorization client credentials.
 77 |  * @param {function} callback The callback to call with the authorized client.
 78 |  */
 79 | function authorize(credentials, callback) {
 80 |     const {client_secret, client_id, redirect_uris} = credentials.installed;
 81 |     const oAuth2Client = new google.auth.OAuth2(
 82 |         client_id, client_secret, redirect_uris[0]);
 83 | 
 84 |     // Check if we have previously stored a token.
 85 |     fs.readFile(TOKEN_PATH, (err, token) => {
 86 |         if (err) return getAccessToken(oAuth2Client, callback);
 87 |         oAuth2Client.setCredentials(JSON.parse(token));
 88 |         callback(oAuth2Client);
 89 |     });
 90 | }
 91 | 
 92 | /**
 93 |  * Get and store new token after prompting for user authorization, and then
 94 |  * execute the given callback with the authorized OAuth2 client.
 95 |  * @param {google.auth.OAuth2} oAuth2Client The OAuth2 client to get token for.
 96 |  * @param {function} callback The callback for the authorized client.
 97 |  */
 98 | function getAccessToken(oAuth2Client, callback) {
 99 |     const authUrl = oAuth2Client.generateAuthUrl({
100 |         access_type: 'offline',
101 |         scope: SCOPES,
102 |     });
103 |     console.log('Authorize this app by visiting this url:', authUrl);
104 |     const rl = readline.createInterface({input: process.stdin, output: process.stdout});
105 |     rl.question('Enter the code from that page here: ', (code) => {
106 |         rl.close();
107 |         oAuth2Client.getToken(code, (err, token) => {
108 |             if (err) return console.error('Error retrieving access token', err);
109 |             oAuth2Client.setCredentials(token);
110 |             // Store the token to disk for later program executions
111 |             fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => {
112 |                 if (err) return console.error(err);
113 |                 console.log('Token stored to', TOKEN_PATH);
114 |             });
115 |             callback(oAuth2Client);
116 |         });
117 |     });
118 | }
119 | 
120 | module.exports = {
121 |     SCOPES,
122 |     initAuthorize
123 | };
124 |
125 |
126 | 127 | 128 | 129 | 130 |
131 | 132 | 135 | 136 |
137 | 138 | 141 | 142 | 143 | 144 | 145 | 146 | -------------------------------------------------------------------------------- /JSDoc/Utility_requirement-validator.js.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Source: Utility/requirement-validator.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: Utility/requirement-validator.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
/**
 30 |  * Used to check whether the booking is in the past.
 31 |  * @param {number} year  Year of booking.
 32 |  * @param {number} month  Month of booking.
 33 |  * @param {number} day  Day of booking.
 34 |  * @param {number} hour  Hour of booking.
 35 |  * @param {number} minute  Minute of booking.
 36 |  * @returns {boolean}  Returns a boolean representing whether the book is in the past.
 37 |  */
 38 | function isInPast(year, month, day, hour, minute) {
 39 |     const todayDate = Date.now();
 40 |     let reqDate = {};
 41 |     if (hour !== undefined) {
 42 |         reqDate = Date.UTC(year, month - 1, day, hour, minute);
 43 |     } else if (day !== undefined) {
 44 |         reqDate = Date.UTC(year, month - 1, day);
 45 |     } else {
 46 |         reqDate = Date.UTC(year, month);
 47 |     }
 48 |     return reqDate < todayDate;
 49 | 
 50 | }
 51 | 
 52 | /**
 53 |  * Used to check whether the booking is at least 24 hours in advance.
 54 |  * @param {number} year  Year of booking.
 55 |  * @param {number} month  Month of booking.
 56 |  * @param {number} day  Day of booking.
 57 |  * @param {number} hour  Hour of booking.
 58 |  * @param {number} minute  Minute of booking.
 59 |  * @returns {boolean}  Returns a boolean representing whether the book is 24 hours in advance.
 60 |  */
 61 | function is24HoursInAdvance(year, month, day, hour, minute) {
 62 |     const todayDate = new Date(Date.now());
 63 |     const plus24Hours = todayDate.setUTCHours(todayDate.getUTCHours() + 24);
 64 |     const reqDate = Date.UTC(year, month-1, day, hour, minute);
 65 |     return reqDate > plus24Hours;
 66 | }
 67 | 
 68 | /**
 69 |  * Used to check whether the booking is in the bookable time frame (on a weekday between 9 am and 5 pm).
 70 |  * @param {number} year  Year of booking.
 71 |  * @param {number} month  Month of booking.
 72 |  * @param {number} day  Day of booking.
 73 |  * @param {number} hour  Hour of booking.
 74 |  * @param {number} minute  Minute of booking.
 75 |  * @returns {boolean}  Returns a boolean representing whether the booking is in the bookable time frame.
 76 |  */
 77 | function isInBookableTimeframe(year, month, day, hour, minute) {
 78 |     if (hour !== undefined) {
 79 |         const reqDate = new Date(Date.UTC(year, month-1, day, hour, minute));
 80 |         const reqDay = reqDate.getUTCDay();
 81 |         if (reqDay === 6 || reqDay === 0) return false; // 6 is Saturday, 0 is Sunday.
 82 |         const reqHour = reqDate.getUTCHours();
 83 |         if (reqHour < 9 || reqHour > 17) return false;
 84 |     } else {
 85 |         const reqDate = new Date(Date.UTC(year, month-1, day));
 86 |         const reqDay = reqDate.getUTCDay();
 87 |         if (reqDay === 6 || reqDay === 0) return false; // 6 is Saturday, 0 is Sunday.
 88 |     }
 89 |     return true;
 90 | }
 91 | 
 92 | /**
 93 |  * Used to check for missing REST parameters inputs before proceeding with the request.
 94 |  * @param {number} year  Year value to check. Denote with '0' if not checking for this variable.
 95 |  * @param {number} month  Month value to check Denote with '0' if not checking for this variable.
 96 |  * @param {number} day  Day value to check Denote with '0' if not checking for this variable.
 97 |  * @param {number} hour  Hour value to check. Denote with '0' if not checking for this variable.
 98 |  * @param {number} minute  Minute value to check. Denote with '0' if not checking for this variable.
 99 |  * @returns {object}  Returns an object with info on what parameter was missing.
100 |  */
101 | function checkMissingInputs(year, month, day, hour, minute) {
102 |     if (!year) return {success: false, message: 'Request is missing parameter: year'};
103 |     if (!month) return {success: false, message: 'Request is missing parameter: month'};
104 |     if (!day) return {success: false, message: 'Request is missing parameter: day'};
105 |     if (!hour) return {success: false, message: 'Request is missing parameter: hour'};
106 |     if (!minute) return {success: false, message: 'Request is missing parameter: minute'};
107 | }
108 | 
109 | /**
110 |  * Used to validate bookings.
111 |  * @param {number} year  Year of booking to check.
112 |  * @param {number} month  Month of booking to check.
113 |  * @param {number} day  Day of booking to check.
114 |  * @param {number} hour  Hour of booking to check.
115 |  * @param {number} minute  Minute of booking to check.
116 |  * @returns {object}  Returns an object with info on why the booking was invalid.
117 |  */
118 | function validateBooking(year, month, day, hour, minute) {
119 |     const missingInputs = checkMissingInputs(year, month, day, hour, minute);
120 |     if (missingInputs) return missingInputs;
121 |     if (isInPast(year, month, day, hour, minute))
122 |         return {success: false, message: 'Cannot book time in the past'};
123 |     if (!isInBookableTimeframe(year, month, day, hour, minute))
124 |         return {success: false, message: 'Cannot book outside bookable timeframe'};
125 |     if (!is24HoursInAdvance(year, month, day, hour, minute))
126 |         return {success: false, message: 'Cannot book with less than 24 hours in advance'};
127 | }
128 | 
129 | /**
130 |  * Used to validate GET Timeslot requests.
131 |  * @param {number} year  Year parameter to check.
132 |  * @param {number} month  Month parameter to check.
133 |  * @param {number} day  Day parameter to check.
134 |  * @returns {object}  Returns an object with info on why the request was invalid.
135 |  */
136 | function validateGetTimeslots(year, month, day) {
137 |     const missingInputs = checkMissingInputs(year, month, day, '0', '0');
138 |     if (missingInputs) return missingInputs;
139 |     if (isInPast(year, month, day, undefined, undefined))
140 |         return {success: false, message: 'No timeslots are available in the past'};
141 |     if (!isInBookableTimeframe(year, month, day, undefined, undefined))
142 |         return {success: false, message: 'No timeslots exist outside bookable timeframe'};
143 | }
144 | 
145 | /**
146 |  * Used to validate GET Days requests.
147 |  * @param {number} year  Year parameter to check.
148 |  * @param {number} month  Month parameter to check.
149 |  * @returns {object}  Returns an object with info on why the request was invalid.
150 |  */
151 | function validateGetDays(year, month) {
152 |     const missingInputs = checkMissingInputs(year, month, '0', '0', '0');
153 |     if (missingInputs) return missingInputs;
154 |     if (isInPast(year, month, undefined, undefined, undefined))
155 |         return {success: false, message: 'No timeslots are available in the past'};
156 | }
157 | 
158 | module.exports = {
159 |     checkMissingInputs,
160 |     validateBooking,
161 |     validateGetTimeslots,
162 |     validateGetDays
163 | };
164 |
165 |
166 | 167 | 168 | 169 | 170 |
171 | 172 | 175 | 176 |
177 | 178 | 181 | 182 | 183 | 184 | 185 | 186 | -------------------------------------------------------------------------------- /JSDoc/fonts/OpenSans-Bold-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arytek/NodeJS-Booking-App/10cda43b6a6e657abd206f463481e0aa0a076e8e/JSDoc/fonts/OpenSans-Bold-webfont.eot -------------------------------------------------------------------------------- /JSDoc/fonts/OpenSans-Bold-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arytek/NodeJS-Booking-App/10cda43b6a6e657abd206f463481e0aa0a076e8e/JSDoc/fonts/OpenSans-Bold-webfont.woff -------------------------------------------------------------------------------- /JSDoc/fonts/OpenSans-BoldItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arytek/NodeJS-Booking-App/10cda43b6a6e657abd206f463481e0aa0a076e8e/JSDoc/fonts/OpenSans-BoldItalic-webfont.eot -------------------------------------------------------------------------------- /JSDoc/fonts/OpenSans-BoldItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arytek/NodeJS-Booking-App/10cda43b6a6e657abd206f463481e0aa0a076e8e/JSDoc/fonts/OpenSans-BoldItalic-webfont.woff -------------------------------------------------------------------------------- /JSDoc/fonts/OpenSans-Italic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arytek/NodeJS-Booking-App/10cda43b6a6e657abd206f463481e0aa0a076e8e/JSDoc/fonts/OpenSans-Italic-webfont.eot -------------------------------------------------------------------------------- /JSDoc/fonts/OpenSans-Italic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arytek/NodeJS-Booking-App/10cda43b6a6e657abd206f463481e0aa0a076e8e/JSDoc/fonts/OpenSans-Italic-webfont.woff -------------------------------------------------------------------------------- /JSDoc/fonts/OpenSans-Light-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arytek/NodeJS-Booking-App/10cda43b6a6e657abd206f463481e0aa0a076e8e/JSDoc/fonts/OpenSans-Light-webfont.eot -------------------------------------------------------------------------------- /JSDoc/fonts/OpenSans-Light-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arytek/NodeJS-Booking-App/10cda43b6a6e657abd206f463481e0aa0a076e8e/JSDoc/fonts/OpenSans-Light-webfont.woff -------------------------------------------------------------------------------- /JSDoc/fonts/OpenSans-LightItalic-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arytek/NodeJS-Booking-App/10cda43b6a6e657abd206f463481e0aa0a076e8e/JSDoc/fonts/OpenSans-LightItalic-webfont.eot -------------------------------------------------------------------------------- /JSDoc/fonts/OpenSans-LightItalic-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arytek/NodeJS-Booking-App/10cda43b6a6e657abd206f463481e0aa0a076e8e/JSDoc/fonts/OpenSans-LightItalic-webfont.woff -------------------------------------------------------------------------------- /JSDoc/fonts/OpenSans-Regular-webfont.eot: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arytek/NodeJS-Booking-App/10cda43b6a6e657abd206f463481e0aa0a076e8e/JSDoc/fonts/OpenSans-Regular-webfont.eot -------------------------------------------------------------------------------- /JSDoc/fonts/OpenSans-Regular-webfont.woff: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/arytek/NodeJS-Booking-App/10cda43b6a6e657abd206f463481e0aa0a076e8e/JSDoc/fonts/OpenSans-Regular-webfont.woff -------------------------------------------------------------------------------- /JSDoc/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | JSDoc: Home 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Home

21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 |

nodejs-booking-app 1.0.0

30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | 44 | 45 |
46 |

NodeJS Booking App

47 |

An appointment booking server application made using Node JS. This application makes use of the Google Calendar API to create appointment timeslots on Google Calender. The appointment timeslots are 40 minutes in length, and a 5 minute break between each timeslot exists. The timeslots are defined from Monday to Friday, 9AM to 6PM.

48 |

The full application requirements are given below.

49 |

For a video demonstration of the web app, see this video: https://youtu.be/Wamlp6TsO-E

50 |

Requirements:

51 |
    52 |
  • All appointments are 40 minutes long and have fixed times, starting from 9–9:40 am. :heavy_check_mark:
  • 53 |
  • Ensure there is always a 5 minute break in between each appointment. :heavy_check_mark:
  • 54 |
  • Appointments can only be booked during weekdays from 9 am to 6 pm. :heavy_check_mark:
  • 55 |
  • Bookings can only be made at least 24 hours in advance. :heavy_check_mark:
  • 56 |
  • Appointments cannot be booked in the past. :heavy_check_mark:
  • 57 |
  • For simplicity, use UTC time for all bookings and days. :heavy_check_mark:
  • 58 |
59 |

Application contents:

60 |

ReqHandlers Directory

61 |
    62 |
  • GET-Handlers - A folder containing the GET handlers used in the app.
  • 63 |
  • POST-Handlers - A folder containing the POST handlers used in the app.
  • 64 |
65 |

Utility Directory

66 |
    67 |
  • appUtil.js - Provides functionality used throughout the code base, such as date calculation functions.
  • 68 |
  • gcal.js - Utilises the credentials.json file to generate a token.json file. If a token.json file already exists, then an oAuth2 Client is generated and returned.
  • 69 |
  • requirements-validator.js - Used to validate requests sent to the server.
  • 70 |
  • credentials.json - Your credentials.json file used to authenticate the Google Calendar API used by this app.
  • 71 |
  • token.json - The token file generated by gcal.js after authenticating your credentials.json file.
  • 72 |
73 |

App Working Directory

74 |
    75 |
  • Node-Modules - Generated when running 'npm-install'. A folder containing the npm modules used throughout the app.
  • 76 |
  • server.js - The main server file that utilises express to start a web server.
  • 77 |
  • package.json - Package.json file used with npm.
  • 78 |
  • package-lock.json - Package-lock.json file used with npm.
  • 79 |
80 |

Installation and Usage

81 |

Instructions:

82 |
    83 |
  1. Clone this repository.
  2. 84 |
  3. Visit https://developers.google.com/calendar/quickstart/nodejs to activate Google Calander on your Google Account and to generate a credentials.json file if you haven't already done so. Place your credentials.json file into the 'Utility' directory of this application.
  4. 85 |
  5. In the newly cloned repository, open your command line and run the 'npm install' command to download the required modules.
  6. 86 |
  7. Run the 'node .' command to run the server.
  8. 87 |
  9. The booking app is now ready. Try out the following REST requests below.
  10. 88 |
89 |

REST Routes:

90 |
GET  /days?year=yyyy&month=mm
 91 | 
 92 | GET  /timeslots?year=yyyy&month=mm&day=dd
 93 | 
 94 | POST /book?year=yyyy&month=MM&day=dd&hour=hh&minute=mm
 95 | 
96 |

License

97 |

NodeJS-Booking-App is copyright (c) 2019, Aryan Nateghnia 38933061+aryannateq@users.noreply.github.com.

98 |

NodeJS-Booking-App is free software, licensed under the GPL, Version 3.0. See the 99 | LICENSE file for more details.

100 |
101 | 102 | 103 | 104 | 105 | 106 | 107 |
108 | 109 | 112 | 113 |
114 | 115 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /JSDoc/scripts/linenumber.js: -------------------------------------------------------------------------------- 1 | /*global document */ 2 | (() => { 3 | const source = document.getElementsByClassName('prettyprint source linenums'); 4 | let i = 0; 5 | let lineNumber = 0; 6 | let lineId; 7 | let lines; 8 | let totalLines; 9 | let anchorHash; 10 | 11 | if (source && source[0]) { 12 | anchorHash = document.location.hash.substring(1); 13 | lines = source[0].getElementsByTagName('li'); 14 | totalLines = lines.length; 15 | 16 | for (; i < totalLines; i++) { 17 | lineNumber++; 18 | lineId = `line${lineNumber}`; 19 | lines[i].id = lineId; 20 | if (lineId === anchorHash) { 21 | lines[i].className += ' selected'; 22 | } 23 | } 24 | } 25 | })(); 26 | -------------------------------------------------------------------------------- /JSDoc/scripts/prettify/Apache-License-2.0.txt: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | -------------------------------------------------------------------------------- /JSDoc/scripts/prettify/lang-css.js: -------------------------------------------------------------------------------- 1 | PR.registerLangHandler(PR.createSimpleLexer([["pln",/^[\t\n\f\r ]+/,null," \t\r\n "]],[["str",/^"(?:[^\n\f\r"\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*"/,null],["str",/^'(?:[^\n\f\r'\\]|\\(?:\r\n?|\n|\f)|\\[\S\s])*'/,null],["lang-css-str",/^url\(([^"')]*)\)/i],["kwd",/^(?:url|rgb|!important|@import|@page|@media|@charset|inherit)(?=[^\w-]|$)/i,null],["lang-css-kw",/^(-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*)\s*:/i],["com",/^\/\*[^*]*\*+(?:[^*/][^*]*\*+)*\//],["com", 2 | /^(?:<\!--|--\>)/],["lit",/^(?:\d+|\d*\.\d+)(?:%|[a-z]+)?/i],["lit",/^#[\da-f]{3,6}/i],["pln",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i],["pun",/^[^\s\w"']+/]]),["css"]);PR.registerLangHandler(PR.createSimpleLexer([],[["kwd",/^-?(?:[_a-z]|\\[\da-f]+ ?)(?:[\w-]|\\\\[\da-f]+ ?)*/i]]),["css-kw"]);PR.registerLangHandler(PR.createSimpleLexer([],[["str",/^[^"')]+/]]),["css-str"]); 3 | -------------------------------------------------------------------------------- /JSDoc/scripts/prettify/prettify.js: -------------------------------------------------------------------------------- 1 | var q=null;window.PR_SHOULD_USE_CONTINUATION=!0; 2 | (function(){function L(a){function m(a){var f=a.charCodeAt(0);if(f!==92)return f;var b=a.charAt(1);return(f=r[b])?f:"0"<=b&&b<="7"?parseInt(a.substring(1),8):b==="u"||b==="x"?parseInt(a.substring(2),16):a.charCodeAt(1)}function e(a){if(a<32)return(a<16?"\\x0":"\\x")+a.toString(16);a=String.fromCharCode(a);if(a==="\\"||a==="-"||a==="["||a==="]")a="\\"+a;return a}function h(a){for(var f=a.substring(1,a.length-1).match(/\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\[0-3][0-7]{0,2}|\\[0-7]{1,2}|\\[\S\s]|[^\\]/g),a= 3 | [],b=[],o=f[0]==="^",c=o?1:0,i=f.length;c122||(d<65||j>90||b.push([Math.max(65,j)|32,Math.min(d,90)|32]),d<97||j>122||b.push([Math.max(97,j)&-33,Math.min(d,122)&-33]))}}b.sort(function(a,f){return a[0]-f[0]||f[1]-a[1]});f=[];j=[NaN,NaN];for(c=0;ci[0]&&(i[1]+1>i[0]&&b.push("-"),b.push(e(i[1])));b.push("]");return b.join("")}function y(a){for(var f=a.source.match(/\[(?:[^\\\]]|\\[\S\s])*]|\\u[\dA-Fa-f]{4}|\\x[\dA-Fa-f]{2}|\\\d+|\\[^\dux]|\(\?[!:=]|[()^]|[^()[\\^]+/g),b=f.length,d=[],c=0,i=0;c=2&&a==="["?f[c]=h(j):a!=="\\"&&(f[c]=j.replace(/[A-Za-z]/g,function(a){a=a.charCodeAt(0);return"["+String.fromCharCode(a&-33,a|32)+"]"}));return f.join("")}for(var t=0,s=!1,l=!1,p=0,d=a.length;p=5&&"lang-"===b.substring(0,5))&&!(o&&typeof o[1]==="string"))c=!1,b="src";c||(r[f]=b)}i=d;d+=f.length;if(c){c=o[1];var j=f.indexOf(c),k=j+c.length;o[2]&&(k=f.length-o[2].length,j=k-c.length);b=b.substring(5);B(l+i,f.substring(0,j),e,p);B(l+i+j,c,C(b,c),p);B(l+i+k,f.substring(k),e,p)}else p.push(l+i,b)}a.e=p}var h={},y;(function(){for(var e=a.concat(m), 9 | l=[],p={},d=0,g=e.length;d=0;)h[n.charAt(k)]=r;r=r[1];n=""+r;p.hasOwnProperty(n)||(l.push(r),p[n]=q)}l.push(/[\S\s]/);y=L(l)})();var t=m.length;return e}function u(a){var m=[],e=[];a.tripleQuotedStrings?m.push(["str",/^(?:'''(?:[^'\\]|\\[\S\s]|''?(?=[^']))*(?:'''|$)|"""(?:[^"\\]|\\[\S\s]|""?(?=[^"]))*(?:"""|$)|'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$))/,q,"'\""]):a.multiLineStrings?m.push(["str",/^(?:'(?:[^'\\]|\\[\S\s])*(?:'|$)|"(?:[^"\\]|\\[\S\s])*(?:"|$)|`(?:[^\\`]|\\[\S\s])*(?:`|$))/, 10 | q,"'\"`"]):m.push(["str",/^(?:'(?:[^\n\r'\\]|\\.)*(?:'|$)|"(?:[^\n\r"\\]|\\.)*(?:"|$))/,q,"\"'"]);a.verbatimStrings&&e.push(["str",/^@"(?:[^"]|"")*(?:"|$)/,q]);var h=a.hashComments;h&&(a.cStyleComments?(h>1?m.push(["com",/^#(?:##(?:[^#]|#(?!##))*(?:###|$)|.*)/,q,"#"]):m.push(["com",/^#(?:(?:define|elif|else|endif|error|ifdef|include|ifndef|line|pragma|undef|warning)\b|[^\n\r]*)/,q,"#"]),e.push(["str",/^<(?:(?:(?:\.\.\/)*|\/?)(?:[\w-]+(?:\/[\w-]+)+)?[\w-]+\.h|[a-z]\w*)>/,q])):m.push(["com",/^#[^\n\r]*/, 11 | q,"#"]));a.cStyleComments&&(e.push(["com",/^\/\/[^\n\r]*/,q]),e.push(["com",/^\/\*[\S\s]*?(?:\*\/|$)/,q]));a.regexLiterals&&e.push(["lang-regex",/^(?:^^\.?|[!+-]|!=|!==|#|%|%=|&|&&|&&=|&=|\(|\*|\*=|\+=|,|-=|->|\/|\/=|:|::|;|<|<<|<<=|<=|=|==|===|>|>=|>>|>>=|>>>|>>>=|[?@[^]|\^=|\^\^|\^\^=|{|\||\|=|\|\||\|\|=|~|break|case|continue|delete|do|else|finally|instanceof|return|throw|try|typeof)\s*(\/(?=[^*/])(?:[^/[\\]|\\[\S\s]|\[(?:[^\\\]]|\\[\S\s])*(?:]|$))+\/)/]);(h=a.types)&&e.push(["typ",h]);a=(""+a.keywords).replace(/^ | $/g, 12 | "");a.length&&e.push(["kwd",RegExp("^(?:"+a.replace(/[\s,]+/g,"|")+")\\b"),q]);m.push(["pln",/^\s+/,q," \r\n\t\xa0"]);e.push(["lit",/^@[$_a-z][\w$@]*/i,q],["typ",/^(?:[@_]?[A-Z]+[a-z][\w$@]*|\w+_t\b)/,q],["pln",/^[$_a-z][\w$@]*/i,q],["lit",/^(?:0x[\da-f]+|(?:\d(?:_\d+)*\d*(?:\.\d*)?|\.\d\+)(?:e[+-]?\d+)?)[a-z]*/i,q,"0123456789"],["pln",/^\\[\S\s]?/,q],["pun",/^.[^\s\w"-$'./@\\`]*/,q]);return x(m,e)}function D(a,m){function e(a){switch(a.nodeType){case 1:if(k.test(a.className))break;if("BR"===a.nodeName)h(a), 13 | a.parentNode&&a.parentNode.removeChild(a);else for(a=a.firstChild;a;a=a.nextSibling)e(a);break;case 3:case 4:if(p){var b=a.nodeValue,d=b.match(t);if(d){var c=b.substring(0,d.index);a.nodeValue=c;(b=b.substring(d.index+d[0].length))&&a.parentNode.insertBefore(s.createTextNode(b),a.nextSibling);h(a);c||a.parentNode.removeChild(a)}}}}function h(a){function b(a,d){var e=d?a.cloneNode(!1):a,f=a.parentNode;if(f){var f=b(f,1),g=a.nextSibling;f.appendChild(e);for(var h=g;h;h=g)g=h.nextSibling,f.appendChild(h)}return e} 14 | for(;!a.nextSibling;)if(a=a.parentNode,!a)return;for(var a=b(a.nextSibling,0),e;(e=a.parentNode)&&e.nodeType===1;)a=e;d.push(a)}var k=/(?:^|\s)nocode(?:\s|$)/,t=/\r\n?|\n/,s=a.ownerDocument,l;a.currentStyle?l=a.currentStyle.whiteSpace:window.getComputedStyle&&(l=s.defaultView.getComputedStyle(a,q).getPropertyValue("white-space"));var p=l&&"pre"===l.substring(0,3);for(l=s.createElement("LI");a.firstChild;)l.appendChild(a.firstChild);for(var d=[l],g=0;g=0;){var h=m[e];A.hasOwnProperty(h)?window.console&&console.warn("cannot override language handler %s",h):A[h]=a}}function C(a,m){if(!a||!A.hasOwnProperty(a))a=/^\s*=o&&(h+=2);e>=c&&(a+=2)}}catch(w){"console"in window&&console.log(w&&w.stack?w.stack:w)}}var v=["break,continue,do,else,for,if,return,while"],w=[[v,"auto,case,char,const,default,double,enum,extern,float,goto,int,long,register,short,signed,sizeof,static,struct,switch,typedef,union,unsigned,void,volatile"], 18 | "catch,class,delete,false,import,new,operator,private,protected,public,this,throw,true,try,typeof"],F=[w,"alignof,align_union,asm,axiom,bool,concept,concept_map,const_cast,constexpr,decltype,dynamic_cast,explicit,export,friend,inline,late_check,mutable,namespace,nullptr,reinterpret_cast,static_assert,static_cast,template,typeid,typename,using,virtual,where"],G=[w,"abstract,boolean,byte,extends,final,finally,implements,import,instanceof,null,native,package,strictfp,super,synchronized,throws,transient"], 19 | H=[G,"as,base,by,checked,decimal,delegate,descending,dynamic,event,fixed,foreach,from,group,implicit,in,interface,internal,into,is,lock,object,out,override,orderby,params,partial,readonly,ref,sbyte,sealed,stackalloc,string,select,uint,ulong,unchecked,unsafe,ushort,var"],w=[w,"debugger,eval,export,function,get,null,set,undefined,var,with,Infinity,NaN"],I=[v,"and,as,assert,class,def,del,elif,except,exec,finally,from,global,import,in,is,lambda,nonlocal,not,or,pass,print,raise,try,with,yield,False,True,None"], 20 | J=[v,"alias,and,begin,case,class,def,defined,elsif,end,ensure,false,in,module,next,nil,not,or,redo,rescue,retry,self,super,then,true,undef,unless,until,when,yield,BEGIN,END"],v=[v,"case,done,elif,esac,eval,fi,function,in,local,set,then,until"],K=/^(DIR|FILE|vector|(de|priority_)?queue|list|stack|(const_)?iterator|(multi)?(set|map)|bitset|u?(int|float)\d*)/,N=/\S/,O=u({keywords:[F,H,w,"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END"+ 21 | I,J,v],hashComments:!0,cStyleComments:!0,multiLineStrings:!0,regexLiterals:!0}),A={};k(O,["default-code"]);k(x([],[["pln",/^[^]*(?:>|$)/],["com",/^<\!--[\S\s]*?(?:--\>|$)/],["lang-",/^<\?([\S\s]+?)(?:\?>|$)/],["lang-",/^<%([\S\s]+?)(?:%>|$)/],["pun",/^(?:<[%?]|[%?]>)/],["lang-",/^]*>([\S\s]+?)<\/xmp\b[^>]*>/i],["lang-js",/^]*>([\S\s]*?)(<\/script\b[^>]*>)/i],["lang-css",/^]*>([\S\s]*?)(<\/style\b[^>]*>)/i],["lang-in.tag",/^(<\/?[a-z][^<>]*>)/i]]), 22 | ["default-markup","htm","html","mxml","xhtml","xml","xsl"]);k(x([["pln",/^\s+/,q," \t\r\n"],["atv",/^(?:"[^"]*"?|'[^']*'?)/,q,"\"'"]],[["tag",/^^<\/?[a-z](?:[\w-.:]*\w)?|\/?>$/i],["atn",/^(?!style[\s=]|on)[a-z](?:[\w:-]*\w)?/i],["lang-uq.val",/^=\s*([^\s"'>]*(?:[^\s"'/>]|\/(?=\s)))/],["pun",/^[/<->]+/],["lang-js",/^on\w+\s*=\s*"([^"]+)"/i],["lang-js",/^on\w+\s*=\s*'([^']+)'/i],["lang-js",/^on\w+\s*=\s*([^\s"'>]+)/i],["lang-css",/^style\s*=\s*"([^"]+)"/i],["lang-css",/^style\s*=\s*'([^']+)'/i],["lang-css", 23 | /^style\s*=\s*([^\s"'>]+)/i]]),["in.tag"]);k(x([],[["atv",/^[\S\s]+/]]),["uq.val"]);k(u({keywords:F,hashComments:!0,cStyleComments:!0,types:K}),["c","cc","cpp","cxx","cyc","m"]);k(u({keywords:"null,true,false"}),["json"]);k(u({keywords:H,hashComments:!0,cStyleComments:!0,verbatimStrings:!0,types:K}),["cs"]);k(u({keywords:G,cStyleComments:!0}),["java"]);k(u({keywords:v,hashComments:!0,multiLineStrings:!0}),["bsh","csh","sh"]);k(u({keywords:I,hashComments:!0,multiLineStrings:!0,tripleQuotedStrings:!0}), 24 | ["cv","py"]);k(u({keywords:"caller,delete,die,do,dump,elsif,eval,exit,foreach,for,goto,if,import,last,local,my,next,no,our,print,package,redo,require,sub,undef,unless,until,use,wantarray,while,BEGIN,END",hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["perl","pl","pm"]);k(u({keywords:J,hashComments:!0,multiLineStrings:!0,regexLiterals:!0}),["rb"]);k(u({keywords:w,cStyleComments:!0,regexLiterals:!0}),["js"]);k(u({keywords:"all,and,by,catch,class,else,extends,false,finally,for,if,in,is,isnt,loop,new,no,not,null,of,off,on,or,return,super,then,true,try,unless,until,when,while,yes", 25 | hashComments:3,cStyleComments:!0,multilineStrings:!0,tripleQuotedStrings:!0,regexLiterals:!0}),["coffee"]);k(x([],[["str",/^[\S\s]+/]]),["regex"]);window.prettyPrintOne=function(a,m,e){var h=document.createElement("PRE");h.innerHTML=a;e&&D(h,e);E({g:m,i:e,h:h});return h.innerHTML};window.prettyPrint=function(a){function m(){for(var e=window.PR_SHOULD_USE_CONTINUATION?l.now()+250:Infinity;p=0){var k=k.match(g),f,b;if(b= 26 | !k){b=n;for(var o=void 0,c=b.firstChild;c;c=c.nextSibling)var i=c.nodeType,o=i===1?o?b:c:i===3?N.test(c.nodeValue)?b:o:o;b=(f=o===b?void 0:o)&&"CODE"===f.tagName}b&&(k=f.className.match(g));k&&(k=k[1]);b=!1;for(o=n.parentNode;o;o=o.parentNode)if((o.tagName==="pre"||o.tagName==="code"||o.tagName==="xmp")&&o.className&&o.className.indexOf("prettyprint")>=0){b=!0;break}b||((b=(b=n.className.match(/\blinenums\b(?::(\d+))?/))?b[1]&&b[1].length?+b[1]:!0:!1)&&D(n,b),d={g:k,h:n,i:b},E(d))}}p 2 | 3 | 4 | 5 | JSDoc: Source: server.js 6 | 7 | 8 | 9 | 12 | 13 | 14 | 15 | 16 | 17 | 18 |
19 | 20 |

Source: server.js

21 | 22 | 23 | 24 | 25 | 26 | 27 |
28 |
29 |
const express = require('express');
 30 | const gcal = require('./Utility/gcal.js');
 31 | 
 32 | const days = require('./ReqHandlers/GET-Handlers/days.js');
 33 | const timeslots = require('./ReqHandlers/GET-Handlers/timeslots.js');
 34 | const book = require('./ReqHandlers/POST-Handlers/book.js');
 35 | 
 36 | const app = express();
 37 | const auth = {};
 38 | 
 39 | // Get the OAuth2 client for making Google Calendar API requests.
 40 | gcal.initAuthorize(setAuth);
 41 | 
 42 | function setAuth(auth) {
 43 |     this.auth = auth;
 44 |     console.log('\nServer is now running... Ctrl+C to end');
 45 | }
 46 | 
 47 | /**
 48 |  * Handles 'days' GET requests.
 49 |  * @param {object} req  The requests object provided by Express. See Express doc.
 50 |  * @param {object} res  The results object provided by Express. See Express doc.
 51 |  */
 52 | function handleGetDays(req, res) {
 53 |     const year = req.query.year;
 54 |     const month = req.query.month;
 55 |     days.getBookableDays(this.auth, year, month)
 56 |     .then(function(data) {
 57 |         res.send(data);
 58 |     })
 59 |     .catch(function(data) {
 60 |         res.send(data);
 61 |     });
 62 | }
 63 | 
 64 | /**
 65 |  * Handles 'timeslots' GET requests.
 66 |  * @param {object} req  The requests object provided by Express. See Express doc.
 67 |  * @param {object} res  The results object provided by Express. See Express doc.
 68 |  */
 69 | function handleGetTimeslots(req, res) {
 70 |     const year = req.query.year;
 71 |     const month = req.query.month;
 72 |     const day = req.query.day;
 73 |     timeslots.getAvailTimeslots(this.auth, year, month, day)
 74 |         .then(function(data) {
 75 |             res.send(data);
 76 |         })
 77 |         .catch(function(data) {
 78 |             res.send(data);
 79 |         });
 80 | }
 81 | 
 82 | /**
 83 |  * Handles 'book' POST requests.
 84 |  * @param {object} req  The requests object provided by Express. See Express doc.
 85 |  * @param {object} res  The results object provided by Express. See Express doc.
 86 |  */
 87 | function handleBookAppointment(req, res) {
 88 |     const year = req.query.year;
 89 |     const month = req.query.month;
 90 |     const day = req.query.day;
 91 |     const hour = req.query.hour;
 92 |     const minute = req.query.minute;
 93 |     book.bookAppointment(this.auth, year, month, day, hour, minute)
 94 |         .then(function(data) {
 95 |             res.send(data);
 96 |         })
 97 |         .catch(function(data) {
 98 |             res.send(data);
 99 |         });
100 | }
101 | 
102 | // Routes.
103 | app.get('/days', handleGetDays);
104 | app.get('/timeslots', handleGetTimeslots);
105 | app.post('/book', handleBookAppointment);
106 | 
107 | // Listen on port 8080 for incoming requests to the server.
108 | const server = app.listen(8080, function() {});
109 |
110 |
111 | 112 | 113 | 114 | 115 |
116 | 117 | 120 | 121 |
122 | 123 |
124 | Documentation generated by JSDoc 3.6.3 on Mon Oct 14 2019 11:51:21 GMT+1100 (Australian Eastern Daylight Time) 125 |
126 | 127 | 128 | 129 | 130 | 131 | -------------------------------------------------------------------------------- /JSDoc/styles/jsdoc-default.css: -------------------------------------------------------------------------------- 1 | @font-face { 2 | font-family: 'Open Sans'; 3 | font-weight: normal; 4 | font-style: normal; 5 | src: url('../fonts/OpenSans-Regular-webfont.eot'); 6 | src: 7 | local('Open Sans'), 8 | local('OpenSans'), 9 | url('../fonts/OpenSans-Regular-webfont.eot?#iefix') format('embedded-opentype'), 10 | url('../fonts/OpenSans-Regular-webfont.woff') format('woff'), 11 | url('../fonts/OpenSans-Regular-webfont.svg#open_sansregular') format('svg'); 12 | } 13 | 14 | @font-face { 15 | font-family: 'Open Sans Light'; 16 | font-weight: normal; 17 | font-style: normal; 18 | src: url('../fonts/OpenSans-Light-webfont.eot'); 19 | src: 20 | local('Open Sans Light'), 21 | local('OpenSans Light'), 22 | url('../fonts/OpenSans-Light-webfont.eot?#iefix') format('embedded-opentype'), 23 | url('../fonts/OpenSans-Light-webfont.woff') format('woff'), 24 | url('../fonts/OpenSans-Light-webfont.svg#open_sanslight') format('svg'); 25 | } 26 | 27 | html 28 | { 29 | overflow: auto; 30 | background-color: #fff; 31 | font-size: 14px; 32 | } 33 | 34 | body 35 | { 36 | font-family: 'Open Sans', sans-serif; 37 | line-height: 1.5; 38 | color: #4d4e53; 39 | background-color: white; 40 | } 41 | 42 | a, a:visited, a:active { 43 | color: #0095dd; 44 | text-decoration: none; 45 | } 46 | 47 | a:hover { 48 | text-decoration: underline; 49 | } 50 | 51 | header 52 | { 53 | display: block; 54 | padding: 0px 4px; 55 | } 56 | 57 | tt, code, kbd, samp { 58 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 59 | } 60 | 61 | .class-description { 62 | font-size: 130%; 63 | line-height: 140%; 64 | margin-bottom: 1em; 65 | margin-top: 1em; 66 | } 67 | 68 | .class-description:empty { 69 | margin: 0; 70 | } 71 | 72 | #main { 73 | float: left; 74 | width: 70%; 75 | } 76 | 77 | article dl { 78 | margin-bottom: 40px; 79 | } 80 | 81 | article img { 82 | max-width: 100%; 83 | } 84 | 85 | section 86 | { 87 | display: block; 88 | background-color: #fff; 89 | padding: 12px 24px; 90 | border-bottom: 1px solid #ccc; 91 | margin-right: 30px; 92 | } 93 | 94 | .variation { 95 | display: none; 96 | } 97 | 98 | .signature-attributes { 99 | font-size: 60%; 100 | color: #aaa; 101 | font-style: italic; 102 | font-weight: lighter; 103 | } 104 | 105 | nav 106 | { 107 | display: block; 108 | float: right; 109 | margin-top: 28px; 110 | width: 30%; 111 | box-sizing: border-box; 112 | border-left: 1px solid #ccc; 113 | padding-left: 16px; 114 | } 115 | 116 | nav ul { 117 | font-family: 'Lucida Grande', 'Lucida Sans Unicode', arial, sans-serif; 118 | font-size: 100%; 119 | line-height: 17px; 120 | padding: 0; 121 | margin: 0; 122 | list-style-type: none; 123 | } 124 | 125 | nav ul a, nav ul a:visited, nav ul a:active { 126 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 127 | line-height: 18px; 128 | color: #4D4E53; 129 | } 130 | 131 | nav h3 { 132 | margin-top: 12px; 133 | } 134 | 135 | nav li { 136 | margin-top: 6px; 137 | } 138 | 139 | footer { 140 | display: block; 141 | padding: 6px; 142 | margin-top: 12px; 143 | font-style: italic; 144 | font-size: 90%; 145 | } 146 | 147 | h1, h2, h3, h4 { 148 | font-weight: 200; 149 | margin: 0; 150 | } 151 | 152 | h1 153 | { 154 | font-family: 'Open Sans Light', sans-serif; 155 | font-size: 48px; 156 | letter-spacing: -2px; 157 | margin: 12px 24px 20px; 158 | } 159 | 160 | h2, h3.subsection-title 161 | { 162 | font-size: 30px; 163 | font-weight: 700; 164 | letter-spacing: -1px; 165 | margin-bottom: 12px; 166 | } 167 | 168 | h3 169 | { 170 | font-size: 24px; 171 | letter-spacing: -0.5px; 172 | margin-bottom: 12px; 173 | } 174 | 175 | h4 176 | { 177 | font-size: 18px; 178 | letter-spacing: -0.33px; 179 | margin-bottom: 12px; 180 | color: #4d4e53; 181 | } 182 | 183 | h5, .container-overview .subsection-title 184 | { 185 | font-size: 120%; 186 | font-weight: bold; 187 | letter-spacing: -0.01em; 188 | margin: 8px 0 3px 0; 189 | } 190 | 191 | h6 192 | { 193 | font-size: 100%; 194 | letter-spacing: -0.01em; 195 | margin: 6px 0 3px 0; 196 | font-style: italic; 197 | } 198 | 199 | table 200 | { 201 | border-spacing: 0; 202 | border: 0; 203 | border-collapse: collapse; 204 | } 205 | 206 | td, th 207 | { 208 | border: 1px solid #ddd; 209 | margin: 0px; 210 | text-align: left; 211 | vertical-align: top; 212 | padding: 4px 6px; 213 | display: table-cell; 214 | } 215 | 216 | thead tr 217 | { 218 | background-color: #ddd; 219 | font-weight: bold; 220 | } 221 | 222 | th { border-right: 1px solid #aaa; } 223 | tr > th:last-child { border-right: 1px solid #ddd; } 224 | 225 | .ancestors, .attribs { color: #999; } 226 | .ancestors a, .attribs a 227 | { 228 | color: #999 !important; 229 | text-decoration: none; 230 | } 231 | 232 | .clear 233 | { 234 | clear: both; 235 | } 236 | 237 | .important 238 | { 239 | font-weight: bold; 240 | color: #950B02; 241 | } 242 | 243 | .yes-def { 244 | text-indent: -1000px; 245 | } 246 | 247 | .type-signature { 248 | color: #aaa; 249 | } 250 | 251 | .name, .signature { 252 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 253 | } 254 | 255 | .details { margin-top: 14px; border-left: 2px solid #DDD; } 256 | .details dt { width: 120px; float: left; padding-left: 10px; padding-top: 6px; } 257 | .details dd { margin-left: 70px; } 258 | .details ul { margin: 0; } 259 | .details ul { list-style-type: none; } 260 | .details li { margin-left: 30px; padding-top: 6px; } 261 | .details pre.prettyprint { margin: 0 } 262 | .details .object-value { padding-top: 0; } 263 | 264 | .description { 265 | margin-bottom: 1em; 266 | margin-top: 1em; 267 | } 268 | 269 | .code-caption 270 | { 271 | font-style: italic; 272 | font-size: 107%; 273 | margin: 0; 274 | } 275 | 276 | .source 277 | { 278 | border: 1px solid #ddd; 279 | width: 80%; 280 | overflow: auto; 281 | } 282 | 283 | .prettyprint.source { 284 | width: inherit; 285 | } 286 | 287 | .source code 288 | { 289 | font-size: 100%; 290 | line-height: 18px; 291 | display: block; 292 | padding: 4px 12px; 293 | margin: 0; 294 | background-color: #fff; 295 | color: #4D4E53; 296 | } 297 | 298 | .prettyprint code span.line 299 | { 300 | display: inline-block; 301 | } 302 | 303 | .prettyprint.linenums 304 | { 305 | padding-left: 70px; 306 | -webkit-user-select: none; 307 | -moz-user-select: none; 308 | -ms-user-select: none; 309 | user-select: none; 310 | } 311 | 312 | .prettyprint.linenums ol 313 | { 314 | padding-left: 0; 315 | } 316 | 317 | .prettyprint.linenums li 318 | { 319 | border-left: 3px #ddd solid; 320 | } 321 | 322 | .prettyprint.linenums li.selected, 323 | .prettyprint.linenums li.selected * 324 | { 325 | background-color: lightyellow; 326 | } 327 | 328 | .prettyprint.linenums li * 329 | { 330 | -webkit-user-select: text; 331 | -moz-user-select: text; 332 | -ms-user-select: text; 333 | user-select: text; 334 | } 335 | 336 | .params .name, .props .name, .name code { 337 | color: #4D4E53; 338 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 339 | font-size: 100%; 340 | } 341 | 342 | .params td.description > p:first-child, 343 | .props td.description > p:first-child 344 | { 345 | margin-top: 0; 346 | padding-top: 0; 347 | } 348 | 349 | .params td.description > p:last-child, 350 | .props td.description > p:last-child 351 | { 352 | margin-bottom: 0; 353 | padding-bottom: 0; 354 | } 355 | 356 | .disabled { 357 | color: #454545; 358 | } 359 | -------------------------------------------------------------------------------- /JSDoc/styles/prettify-jsdoc.css: -------------------------------------------------------------------------------- 1 | /* JSDoc prettify.js theme */ 2 | 3 | /* plain text */ 4 | .pln { 5 | color: #000000; 6 | font-weight: normal; 7 | font-style: normal; 8 | } 9 | 10 | /* string content */ 11 | .str { 12 | color: #006400; 13 | font-weight: normal; 14 | font-style: normal; 15 | } 16 | 17 | /* a keyword */ 18 | .kwd { 19 | color: #000000; 20 | font-weight: bold; 21 | font-style: normal; 22 | } 23 | 24 | /* a comment */ 25 | .com { 26 | font-weight: normal; 27 | font-style: italic; 28 | } 29 | 30 | /* a type name */ 31 | .typ { 32 | color: #000000; 33 | font-weight: normal; 34 | font-style: normal; 35 | } 36 | 37 | /* a literal value */ 38 | .lit { 39 | color: #006400; 40 | font-weight: normal; 41 | font-style: normal; 42 | } 43 | 44 | /* punctuation */ 45 | .pun { 46 | color: #000000; 47 | font-weight: bold; 48 | font-style: normal; 49 | } 50 | 51 | /* lisp open bracket */ 52 | .opn { 53 | color: #000000; 54 | font-weight: bold; 55 | font-style: normal; 56 | } 57 | 58 | /* lisp close bracket */ 59 | .clo { 60 | color: #000000; 61 | font-weight: bold; 62 | font-style: normal; 63 | } 64 | 65 | /* a markup tag name */ 66 | .tag { 67 | color: #006400; 68 | font-weight: normal; 69 | font-style: normal; 70 | } 71 | 72 | /* a markup attribute name */ 73 | .atn { 74 | color: #006400; 75 | font-weight: normal; 76 | font-style: normal; 77 | } 78 | 79 | /* a markup attribute value */ 80 | .atv { 81 | color: #006400; 82 | font-weight: normal; 83 | font-style: normal; 84 | } 85 | 86 | /* a declaration */ 87 | .dec { 88 | color: #000000; 89 | font-weight: bold; 90 | font-style: normal; 91 | } 92 | 93 | /* a variable name */ 94 | .var { 95 | color: #000000; 96 | font-weight: normal; 97 | font-style: normal; 98 | } 99 | 100 | /* a function name */ 101 | .fun { 102 | color: #000000; 103 | font-weight: bold; 104 | font-style: normal; 105 | } 106 | 107 | /* Specify class=linenums on a pre to get line numbering */ 108 | ol.linenums { 109 | margin-top: 0; 110 | margin-bottom: 0; 111 | } 112 | -------------------------------------------------------------------------------- /JSDoc/styles/prettify-tomorrow.css: -------------------------------------------------------------------------------- 1 | /* Tomorrow Theme */ 2 | /* Original theme - https://github.com/chriskempson/tomorrow-theme */ 3 | /* Pretty printing styles. Used with prettify.js. */ 4 | /* SPAN elements with the classes below are added by prettyprint. */ 5 | /* plain text */ 6 | .pln { 7 | color: #4d4d4c; } 8 | 9 | @media screen { 10 | /* string content */ 11 | .str { 12 | color: #718c00; } 13 | 14 | /* a keyword */ 15 | .kwd { 16 | color: #8959a8; } 17 | 18 | /* a comment */ 19 | .com { 20 | color: #8e908c; } 21 | 22 | /* a type name */ 23 | .typ { 24 | color: #4271ae; } 25 | 26 | /* a literal value */ 27 | .lit { 28 | color: #f5871f; } 29 | 30 | /* punctuation */ 31 | .pun { 32 | color: #4d4d4c; } 33 | 34 | /* lisp open bracket */ 35 | .opn { 36 | color: #4d4d4c; } 37 | 38 | /* lisp close bracket */ 39 | .clo { 40 | color: #4d4d4c; } 41 | 42 | /* a markup tag name */ 43 | .tag { 44 | color: #c82829; } 45 | 46 | /* a markup attribute name */ 47 | .atn { 48 | color: #f5871f; } 49 | 50 | /* a markup attribute value */ 51 | .atv { 52 | color: #3e999f; } 53 | 54 | /* a declaration */ 55 | .dec { 56 | color: #f5871f; } 57 | 58 | /* a variable name */ 59 | .var { 60 | color: #c82829; } 61 | 62 | /* a function name */ 63 | .fun { 64 | color: #4271ae; } } 65 | /* Use higher contrast and text-weight for printable form. */ 66 | @media print, projection { 67 | .str { 68 | color: #060; } 69 | 70 | .kwd { 71 | color: #006; 72 | font-weight: bold; } 73 | 74 | .com { 75 | color: #600; 76 | font-style: italic; } 77 | 78 | .typ { 79 | color: #404; 80 | font-weight: bold; } 81 | 82 | .lit { 83 | color: #044; } 84 | 85 | .pun, .opn, .clo { 86 | color: #440; } 87 | 88 | .tag { 89 | color: #006; 90 | font-weight: bold; } 91 | 92 | .atn { 93 | color: #404; } 94 | 95 | .atv { 96 | color: #060; } } 97 | /* Style */ 98 | /* 99 | pre.prettyprint { 100 | background: white; 101 | font-family: Consolas, Monaco, 'Andale Mono', monospace; 102 | font-size: 12px; 103 | line-height: 1.5; 104 | border: 1px solid #ccc; 105 | padding: 10px; } 106 | */ 107 | 108 | /* Specify class=linenums on a pre to get line numbering */ 109 | ol.linenums { 110 | margin-top: 0; 111 | margin-bottom: 0; } 112 | 113 | /* IE indents via margin-left */ 114 | li.L0, 115 | li.L1, 116 | li.L2, 117 | li.L3, 118 | li.L4, 119 | li.L5, 120 | li.L6, 121 | li.L7, 122 | li.L8, 123 | li.L9 { 124 | /* */ } 125 | 126 | /* Alternate shading for lines */ 127 | li.L1, 128 | li.L3, 129 | li.L5, 130 | li.L7, 131 | li.L9 { 132 | /* */ } 133 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # NodeJS Booking App 2 | An appointment booking server application made using Node JS. This application makes use of the Google Calendar API to create appointment timeslots on Google Calender. The appointment timeslots are 40 minutes in length, and a 5 minute break between each timeslot exists. The timeslots are defined from Monday to Friday, 9AM to 6PM. This application meets all of the requirements listed below. The requirements defined in this booking server are easily customizable. For example, if you would like to define your own timeslots, simply edit the timeslots within timeslots.json. 3 | 4 | For a video tutorial on how to setup this application, see this video: https://youtu.be/dWip8MLvEWw
5 | For a video demonstration of this application, see this video: https://youtu.be/IS-V0Xmv1mw 6 | 7 |

Requirements:

8 |
    9 |
  • All appointments are 40 minutes long and have fixed times, starting from 9–9:40 am. :heavy_check_mark:
  • 10 |
  • Ensure there is always a 5 minute break in between each appointment. :heavy_check_mark:
  • 11 |
  • Appointments can only be booked during weekdays from 9 am to 6 pm. :heavy_check_mark:
  • 12 |
  • Bookings can only be made at least 24 hours in advance. :heavy_check_mark:
  • 13 |
  • Appointments cannot be booked in the past. :heavy_check_mark:
  • 14 |
15 | 16 |

Application contents:

17 | 18 |

ReqHandlers Directory

19 |
    20 |
  • GET-Handlers - A folder containing the GET handlers used in the app.
  • 21 |
  • POST-Handlers - A folder containing the POST handlers used in the app.
  • 22 |
23 | 24 |

Utility Directory

25 |
    26 |
  • appUtil.js - Provides functionality used throughout the code base, such as date calculation functions.
  • 27 |
  • gcal.js - Utilises the credentials.json file to generate a token.json file. If a token.json file already exists, then an oAuth2 Client is generated and returned.
  • 28 |
  • requirements-validator.js - Used to validate requests sent to the server.
  • 29 |
  • credentials.json - Your credentials.json file used to authenticate the Google Calendar API used by this app.
  • 30 |
  • token.json - The token file generated by gcal.js after authenticating your credentials.json file.
  • 31 |
32 | 33 |

App Working Directory

34 |
    35 |
  • Node-Modules - Generated when running 'npm-install'. A folder containing the npm modules used throughout the app.
  • 36 |
  • server.js - The main server file that utilizes express to start a web server.
  • 37 |
  • package.json - Package.json file used with npm.
  • 38 |
  • package-lock.json - Package-lock.json file used with npm.
  • 39 |
40 | 41 | Installation and Usage 42 | ---------------------- 43 |

Instructions:

44 |
    45 |
  1. Clone this repository.
  2. 46 |
  3. Visit https://developers.google.com/calendar/quickstart/nodejs to activate Google Calander on your Google Account and to generate a credentials.json file if you haven't already done so. Place your credentials.json file into the 'Utility' directory of this application.
  4. 47 |
  5. In the newly cloned repository, open your command line and run the 'npm install' command to download the required modules.
  6. 48 |
  7. Run the 'node .' command to run the server.
  8. 49 |
  9. The booking app is now ready. Try out the following REST requests below.
  10. 50 |
51 | 52 |

HTTP REST Routes:

53 | 54 | GET /days?year=yyyy&month=mm 55 | 56 | GET /timeslots?year=yyyy&month=mm&day=dd 57 | 58 | POST /book?year=yyyy&month=MM&day=dd&hour=hh&minute=mm 59 | 60 | ## License 61 | 62 | NodeJS-Booking-App is copyright (c) 2019, Aryan Nateghnia <38933061+aryannateq@users.noreply.github.com>. 63 | 64 | NodeJS-Booking-App is free software, licensed under the GPL, Version 3.0. See the 65 | `LICENSE` file for more details. 66 | -------------------------------------------------------------------------------- /ReqHandlers/GET-Handlers/days.js: -------------------------------------------------------------------------------- 1 | const {google} = require('googleapis'); 2 | const reqValidator = require('../../Utility/requirement-validator.js'); 3 | const appUtil = require('../../Utility/appUtil.js'); 4 | 5 | /** 6 | * Searches through the given events (appointments), sees which appointments span 7 | * across a full days timeslots (11). If 11 appointment events are found within a 8 | * same day, then the day which those appointments fell on, is added to the bookedDays array. 9 | * @param {number} events Appointment events. 10 | * @returns {number[]} bookedDays An array containing the days that are fully booked. 11 | */ 12 | function getBookedDays(events) { 13 | let bookedDays = []; 14 | let date = null; 15 | let prevDate = null; 16 | let dayArr = []; 17 | for (let event of events) { 18 | date = appUtil.getDateFromISO(event.start.dateTime); 19 | if (date === prevDate || prevDate === null) { 20 | dayArr.push(event); 21 | } else { 22 | dayArr = []; // Clear array. 23 | dayArr.push(event); 24 | } 25 | prevDate = appUtil.getDateFromISO(event.start.dateTime); 26 | if (dayArr.length === 11) { 27 | dayArr = []; // Clear array. 28 | bookedDays.push(date); 29 | } 30 | } 31 | return bookedDays; 32 | } 33 | 34 | /** 35 | * Uses the bookedDays value returned from getBookedDays() to create an array containing 36 | * info on whether the day has any timeslots available or not. 37 | * @param {number} endDate End date of the month. 38 | * @param {number[]} bookedDays An array containing the days that are fully booked. 39 | * @returns {object[]} daysArr An array containing objects which represent the days of 40 | * the month, and whether the day has any timeslots available. 41 | */ 42 | function makeDaysArr(endDate, bookedDays) { 43 | let daysArr = []; 44 | for (let i = 1; i <= endDate; i++) { 45 | if (bookedDays.includes(i)) { 46 | daysArr.push({"day": i, "hasTimeSlots": false}); 47 | } else { 48 | daysArr.push({"day": i, "hasTimeSlots": true}); 49 | } 50 | } 51 | return daysArr; 52 | } 53 | 54 | /** 55 | * Returns a promise with data containing objects with information on whether the days in the given 56 | * month have any timeslots available. Days with no timeslots are considered fully booked. 57 | * @param {object} auth The oAuth2Client used for authentication for the Google Calendar API. 58 | * @param {number} year Year to search for. 59 | * @param {number} month Month to search for. 60 | * @returns {promise} A promise representing the eventual completion of the getBookableDays() function. 61 | */ 62 | function getBookableDays(auth, year, month) { 63 | return new Promise(function(resolve, reject) { 64 | const isInvalid = reqValidator.validateGetDays(year, month); 65 | if (isInvalid) return reject(isInvalid); 66 | 67 | const startDate = new Date(Date.UTC(year, month-1, appUtil.getCurrDateUTC())); 68 | const endDate = new Date((Date.UTC(year, month))); 69 | const calendar = google.calendar({version: 'v3', auth}); 70 | calendar.events.list({ 71 | calendarId: 'primary', 72 | timeMin: startDate.toISOString(), 73 | timeMax: endDate.toISOString(), 74 | maxResults: 350, 75 | singleEvents: true, 76 | orderBy: 'startTime', 77 | q: 'appointment' 78 | }, (err, res) => { 79 | if (err) return reject({success: false, 80 | message: 'The API returned an error - ' + err}); 81 | const events = res.data.items; 82 | const lastDay = appUtil.getLastDayOfMonth(year, month); 83 | let result = {}; 84 | result.days = makeDaysArr(lastDay, getBookedDays(events)); 85 | const response = Object.assign({success: true}, result); 86 | resolve(response); 87 | }); 88 | }); 89 | } 90 | 91 | module.exports = { 92 | getBookableDays 93 | }; -------------------------------------------------------------------------------- /ReqHandlers/GET-Handlers/timeslots.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const {google} = require('googleapis'); 3 | const reqValidator = require('../../Utility/requirement-validator.js'); 4 | const appUtil = require('../../Utility/appUtil.js'); 5 | 6 | const TIMESLOTS_PATH = './Utility/timeslots.json'; 7 | 8 | /** 9 | * Returns an array with timeslots; excluding the timeslots that are booked (appointments). 10 | * @param {object} appointments An Object containing info on the appointments booked in the day. 11 | * @returns {object[]} resultsArr An array containing all the available timeslots in the day. 12 | */ 13 | function getResult(appointments) { 14 | const timeslots = (JSON.parse(fs.readFileSync(TIMESLOTS_PATH))).timeslots; 15 | let resultsArr = []; 16 | for (let i = 0; i < timeslots.length; i++) { 17 | const found = appointments.find(function (element) { 18 | const startTime = element.startTime; 19 | const finalStartTime = startTime.substring(startTime.indexOf("T"), startTime.indexOf("Z") + 1); 20 | return timeslots[i].startTime.includes(finalStartTime); 21 | }); 22 | if (!found) { 23 | resultsArr.push(timeslots[i]); 24 | } 25 | } 26 | return resultsArr; 27 | } 28 | 29 | /** 30 | * Returns a promise with data containing objects with information of the timeslots in the given day. 31 | * Each object contains the startTime and endTime of the timeslot. 32 | * @param {object} auth The oAuth2Client used for authentication for the Google Calendar API. 33 | * @param {number} year Year to search for. 34 | * @param {number} month Month to search for. 35 | * @param {number} day Day to search for. 36 | * @returns {promise} A promise representing the eventual completion of the getAvailTimeslots() function. 37 | */ 38 | function getAvailTimeslots(auth, year, month, day) { 39 | return new Promise(function(resolve, reject) { 40 | const isInvalid = reqValidator.validateGetTimeslots(year, month, day); 41 | if (isInvalid) return reject(isInvalid); 42 | 43 | const startDate = new Date(Date.UTC(year, month-1, day)); 44 | const endDate = appUtil.getNextDay(startDate); 45 | const calendar = google.calendar({version: 'v3', auth}); 46 | calendar.events.list({ 47 | calendarId: 'primary', 48 | timeMin: startDate.toISOString(), 49 | timeMax: endDate.toISOString(), 50 | maxResults: 11, 51 | singleEvents: true, 52 | orderBy: 'startTime', 53 | q: 'appointment' 54 | }, (err, res) => { 55 | if (err) return reject({response: 'The API returned an error: ' + err}); 56 | let appointments = res.data.items.map((event, i) => { 57 | return {startTime: event.start.dateTime, endTime: event.end.dateTime}; 58 | }); 59 | const result = {}; 60 | result.timeslots = getResult(appointments); 61 | if (result.timeslots[0]) { 62 | const response = Object.assign({success: true}, result); 63 | return resolve(response); 64 | } else { 65 | const response = Object.assign({success: false}, result); 66 | return reject(response); 67 | } 68 | }); 69 | }); 70 | } 71 | 72 | module.exports = { 73 | getAvailTimeslots 74 | }; -------------------------------------------------------------------------------- /ReqHandlers/POST-Handlers/book.js: -------------------------------------------------------------------------------- 1 | const fs = require('fs'); 2 | const {google} = require('googleapis'); 3 | const reqValidator = require('../../Utility/requirement-validator.js'); 4 | const appUtil = require('../../Utility/appUtil.js'); 5 | 6 | const TIMESLOTS_PATH = './Utility/timeslots.json'; 7 | /** 8 | * Searches using the provided date for a timeslot matching the hour and minute specified. 9 | * @param {object} timeslots Object containing info on each timeslot for the day. 10 | * @param {number} year Year of the timeslot to search for. 11 | * @param {number} month Month of the timeslot to search for. 12 | * @param {number} day Day of the timeslot to search for. 13 | * @param {number} hour Hour of the timeslot to search for. 14 | * @param {number} minute Minute of the timeslot to search for. 15 | * @returns {object} The timeslot object that was found. If nothing was found, returns undefined. 16 | */ 17 | function findMatchingTimeslot(timeslots, year, month, day, hour, minute) { 18 | const timeslotDate = new Date(Date.UTC(year, month-1, day, hour, minute)).toISOString(); 19 | const foundTimeslot = timeslots.find(function (element) { 20 | //const elementDate = new Date(element.startTime).toISOString(); // Ensure matching ISO format. 21 | return element.startTime.includes(hour + ':' + minute + ':00'); 22 | }); 23 | if (!foundTimeslot) return false; 24 | return {time: foundTimeslot, date: timeslotDate}; 25 | } 26 | 27 | /** 28 | * Books an appointment using the given date and time information. 29 | * @param {object} auth The oAuth2Client used for authentication for the Google Calendar API. 30 | * @param {number} year Year of the timeslot to book. 31 | * @param {number} month Month of the timeslot to book. 32 | * @param {number} day Day of the timeslot to book. 33 | * @param {number} hour Hour of the timeslot to book. 34 | * @param {number} minute Minute of the timeslot to book. 35 | * @returns {promise} A promise representing the eventual completion of the bookAppointment() function. 36 | */ 37 | function bookAppointment(auth, year, month, day, hour, minute) { 38 | return new Promise(function(resolve, reject) { 39 | const isInvalid = reqValidator.validateBooking(year, month, day, hour, minute); 40 | if (isInvalid) return reject(isInvalid); 41 | 42 | const timeslots = (JSON.parse(fs.readFileSync(TIMESLOTS_PATH))).timeslots; 43 | const timeslot = findMatchingTimeslot(timeslots, year, month, day, hour, minute); 44 | if (!timeslot) return resolve({success: false, message: 'Invalid time slot'}); 45 | const date = year + '-' + month + '-' + day; 46 | const event = appUtil.makeEventResource(date, timeslot.time.startTime, timeslot.time.endTime); 47 | 48 | const calendar = google.calendar({version: 'v3', auth}); 49 | calendar.events.insert({ 50 | auth: auth, 51 | calendarId: 'primary', 52 | resource: event 53 | }, function (err, res) { 54 | if (err) return console.log('Error contacting the Calendar service: ' + err); 55 | const event = res.data; 56 | console.log('Appointment created: ', event.id); 57 | const result = {startTime: event.start.dateTime, endTime: event.end.dateTime}; 58 | const response = Object.assign({success: true}, result); 59 | return resolve(response); 60 | }); 61 | }); 62 | } 63 | 64 | module.exports = { 65 | bookAppointment 66 | }; -------------------------------------------------------------------------------- /Utility/appUtil.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Returns the last day of the month. 3 | * @param {number} year The year. 4 | * @param {number} month The month. 5 | * @returns {number} The last day of the month. 6 | */ 7 | function getLastDayOfMonth(year, month) { 8 | return (new Date(Date.UTC(year, month, 0))).getUTCDate(); 9 | } 10 | 11 | /** 12 | * Returns the current date in the UTC timezone. 13 | * @returns {number} 14 | */ 15 | function getCurrDateUTC() { 16 | const currDate = new Date(); 17 | return currDate.getUTCDate(); 18 | } 19 | 20 | /** 21 | * Returns the date from a given ISOString. 22 | * @param {string} dateISOString The callback for the authorized client. 23 | * @returns {number} 24 | */ 25 | function getDateFromISO(dateISOString) { 26 | const date = new Date(dateISOString); 27 | return date.getUTCDate(); 28 | } 29 | 30 | /** 31 | * Returns the next date (i.e the day after). 32 | * @param {Date} date The date to get the next day of. 33 | * @returns {Date} 34 | */ 35 | function getNextDay(date) { 36 | let tomorrow = new Date(date); 37 | tomorrow.setDate(date.getUTCDate() + 1); // Returns epoch value. 38 | return new Date(tomorrow); // Convert from epoch to Date. 39 | } 40 | 41 | /** 42 | * Creates and returns a Google Calendars 'events resource'. 43 | * @param {string} date A string in the following format: 'Year-month-day'. 44 | * @param {string} startTime The start time to associate with the 'start dateTime'. 45 | * @param {string} endTime The end time to associate with the 'end dateTime'. 46 | * @returns {object} A Google Calendars 'events resource'. 47 | */ 48 | function makeEventResource(date, startTime, endTime) { 49 | return { 50 | 'summary': 'appointment', 51 | 'start': { 52 | 'dateTime': date + startTime, 53 | 'timeZone': 'UTC', 54 | }, 55 | 'end': { 56 | 'dateTime': date + endTime, 57 | 'timeZone': 'UTC', 58 | } 59 | }; 60 | } 61 | 62 | module.exports = { 63 | getLastDayOfMonth, 64 | getCurrDateUTC, 65 | getDateFromISO, 66 | getNextDay, 67 | makeEventResource 68 | }; -------------------------------------------------------------------------------- /Utility/gcal.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @license 3 | * Copyright Google Inc. 4 | * 5 | * Licensed under the Apache License, Version 2.0 (the "License"); 6 | * you may not use this file except in compliance with the License. 7 | * You may obtain a copy of the License at 8 | * 9 | * https://www.apache.org/licenses/LICENSE-2.0 10 | * 11 | * Unless required by applicable law or agreed to in writing, software 12 | * distributed under the License is distributed on an "AS IS" BASIS, 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 | * See the License for the specific language governing permissions and 15 | * limitations under the License. 16 | */ 17 | 18 | const fs = require('fs'); 19 | const readline = require('readline'); 20 | const {google} = require('googleapis'); 21 | 22 | // If modifying these scopes, delete token.json. 23 | const SCOPES = ['https://www.googleapis.com/auth/calendar']; 24 | // The file token.json stores the user's access and refresh tokens, and is 25 | // created automatically when the authorization flow completes for the first 26 | // time. 27 | const TOKEN_PATH = './Utility/token.json'; 28 | const CREDENTIALS_PATH = './Utility/credentials.json'; 29 | 30 | // Load client secrets from a local file. 31 | function initAuthorize(callback) { 32 | fs.readFile(CREDENTIALS_PATH, (err, content) => { 33 | if (err) { 34 | console.log('The credentials.json file could not be found or was invalid. \n' + 35 | 'Please visit: https://developers.google.com/calendar/quickstart/nodejs \n' + 36 | 'and generate a credentials.json file from that site. Then, place your \n' + 37 | 'credentials file into the "Utility" directory of this application.'); 38 | process.exit(1); 39 | } 40 | // Authorize a client with credentials, then call the Google Calendar API. 41 | authorize(JSON.parse(content), callback); 42 | }); 43 | } 44 | 45 | /** 46 | * Create an OAuth2 client with the given credentials, and then execute the 47 | * given callback function. 48 | * @param {Object} credentials The authorization client credentials. 49 | * @param {function} callback The callback to call with the authorized client. 50 | */ 51 | function authorize(credentials, callback) { 52 | const {client_secret, client_id, redirect_uris} = credentials.installed; 53 | const oAuth2Client = new google.auth.OAuth2( 54 | client_id, client_secret, redirect_uris[0]); 55 | 56 | // Check if we have previously stored a token. 57 | fs.readFile(TOKEN_PATH, (err, token) => { 58 | if (err) return getAccessToken(oAuth2Client, callback); 59 | oAuth2Client.setCredentials(JSON.parse(token)); 60 | callback(oAuth2Client); 61 | }); 62 | } 63 | 64 | /** 65 | * Get and store new token after prompting for user authorization, and then 66 | * execute the given callback with the authorized OAuth2 client. 67 | * @param {google.auth.OAuth2} oAuth2Client The OAuth2 client to get token for. 68 | * @param {function} callback The callback for the authorized client. 69 | */ 70 | function getAccessToken(oAuth2Client, callback) { 71 | const authUrl = oAuth2Client.generateAuthUrl({ 72 | access_type: 'offline', 73 | scope: SCOPES, 74 | }); 75 | console.log('Authorize this app by visiting this url:', authUrl); 76 | const rl = readline.createInterface({input: process.stdin, output: process.stdout}); 77 | rl.question('Enter the code from that page here: ', (code) => { 78 | rl.close(); 79 | oAuth2Client.getToken(code, (err, token) => { 80 | if (err) return console.error('Error retrieving access token', err); 81 | oAuth2Client.setCredentials(token); 82 | // Store the token to disk for later program executions 83 | fs.writeFile(TOKEN_PATH, JSON.stringify(token), (err) => { 84 | if (err) return console.error(err); 85 | console.log('Token stored to', TOKEN_PATH); 86 | }); 87 | callback(oAuth2Client); 88 | }); 89 | }); 90 | } 91 | 92 | module.exports = { 93 | SCOPES, 94 | initAuthorize 95 | }; -------------------------------------------------------------------------------- /Utility/requirement-validator.js: -------------------------------------------------------------------------------- 1 | /** 2 | * Used to check whether the booking is in the past. 3 | * @param {number} year Year of booking. 4 | * @param {number} month Month of booking. 5 | * @param {number} day Day of booking. 6 | * @param {number} hour Hour of booking. 7 | * @param {number} minute Minute of booking. 8 | * @returns {boolean} Returns a boolean representing whether the book is in the past. 9 | */ 10 | function isInPast(year, month, day, hour, minute) { 11 | const todayDate = Date.now(); 12 | let reqDate = {}; 13 | if (hour !== undefined) { 14 | reqDate = Date.UTC(year, month - 1, day, hour, minute); 15 | } else if (day !== undefined) { 16 | reqDate = Date.UTC(year, month - 1, day); 17 | } else { 18 | reqDate = Date.UTC(year, month); 19 | } 20 | return reqDate < todayDate; 21 | 22 | } 23 | 24 | /** 25 | * Used to check whether the booking is at least 24 hours in advance. 26 | * @param {number} year Year of booking. 27 | * @param {number} month Month of booking. 28 | * @param {number} day Day of booking. 29 | * @param {number} hour Hour of booking. 30 | * @param {number} minute Minute of booking. 31 | * @returns {boolean} Returns a boolean representing whether the book is 24 hours in advance. 32 | */ 33 | function is24HoursInAdvance(year, month, day, hour, minute) { 34 | const todayDate = new Date(Date.now()); 35 | const plus24Hours = todayDate.setUTCHours(todayDate.getUTCHours() + 24); 36 | const reqDate = Date.UTC(year, month-1, day, hour, minute); 37 | return reqDate > plus24Hours; 38 | } 39 | 40 | /** 41 | * Used to check whether the booking is in the bookable time frame (on a weekday between 9 am and 5 pm). 42 | * @param {number} year Year of booking. 43 | * @param {number} month Month of booking. 44 | * @param {number} day Day of booking. 45 | * @param {number} hour Hour of booking. 46 | * @param {number} minute Minute of booking. 47 | * @returns {boolean} Returns a boolean representing whether the booking is in the bookable time frame. 48 | */ 49 | function isInBookableTimeframe(year, month, day, hour, minute) { 50 | if (hour !== undefined) { 51 | const reqDate = new Date(Date.UTC(year, month-1, day, hour, minute)); 52 | const reqDay = reqDate.getUTCDay(); 53 | if (reqDay === 6 || reqDay === 0) return false; // 6 is Saturday, 0 is Sunday. 54 | const reqHour = reqDate.getUTCHours(); 55 | if (reqHour < 9 || reqHour > 17) return false; 56 | } else { 57 | const reqDate = new Date(Date.UTC(year, month-1, day)); 58 | const reqDay = reqDate.getUTCDay(); 59 | if (reqDay === 6 || reqDay === 0) return false; // 6 is Saturday, 0 is Sunday. 60 | } 61 | return true; 62 | } 63 | 64 | /** 65 | * Used to check for missing REST parameters inputs before proceeding with the request. 66 | * @param {number} year Year value to check. Denote with '0' if not checking for this variable. 67 | * @param {number} month Month value to check Denote with '0' if not checking for this variable. 68 | * @param {number} day Day value to check Denote with '0' if not checking for this variable. 69 | * @param {number} hour Hour value to check. Denote with '0' if not checking for this variable. 70 | * @param {number} minute Minute value to check. Denote with '0' if not checking for this variable. 71 | * @returns {object} Returns an object with info on what parameter was missing. 72 | */ 73 | function checkMissingInputs(year, month, day, hour, minute) { 74 | if (!year) return {success: false, message: 'Request is missing parameter: year'}; 75 | if (!month) return {success: false, message: 'Request is missing parameter: month'}; 76 | if (!day) return {success: false, message: 'Request is missing parameter: day'}; 77 | if (!hour) return {success: false, message: 'Request is missing parameter: hour'}; 78 | if (!minute) return {success: false, message: 'Request is missing parameter: minute'}; 79 | } 80 | 81 | /** 82 | * Used to validate bookings. 83 | * @param {number} year Year of booking to check. 84 | * @param {number} month Month of booking to check. 85 | * @param {number} day Day of booking to check. 86 | * @param {number} hour Hour of booking to check. 87 | * @param {number} minute Minute of booking to check. 88 | * @returns {object} Returns an object with info on why the booking was invalid. 89 | */ 90 | function validateBooking(year, month, day, hour, minute) { 91 | const missingInputs = checkMissingInputs(year, month, day, hour, minute); 92 | if (missingInputs) return missingInputs; 93 | if (isInPast(year, month, day, hour, minute)) 94 | return {success: false, message: 'Cannot book time in the past'}; 95 | if (!isInBookableTimeframe(year, month, day, hour, minute)) 96 | return {success: false, message: 'Cannot book outside bookable timeframe'}; 97 | if (!is24HoursInAdvance(year, month, day, hour, minute)) 98 | return {success: false, message: 'Cannot book with less than 24 hours in advance'}; 99 | } 100 | 101 | /** 102 | * Used to validate GET Timeslot requests. 103 | * @param {number} year Year parameter to check. 104 | * @param {number} month Month parameter to check. 105 | * @param {number} day Day parameter to check. 106 | * @returns {object} Returns an object with info on why the request was invalid. 107 | */ 108 | function validateGetTimeslots(year, month, day) { 109 | const missingInputs = checkMissingInputs(year, month, day, '0', '0'); 110 | if (missingInputs) return missingInputs; 111 | if (isInPast(year, month, day, undefined, undefined)) 112 | return {success: false, message: 'No timeslots are available in the past'}; 113 | if (!isInBookableTimeframe(year, month, day, undefined, undefined)) 114 | return {success: false, message: 'No timeslots exist outside bookable timeframe'}; 115 | } 116 | 117 | /** 118 | * Used to validate GET Days requests. 119 | * @param {number} year Year parameter to check. 120 | * @param {number} month Month parameter to check. 121 | * @returns {object} Returns an object with info on why the request was invalid. 122 | */ 123 | function validateGetDays(year, month) { 124 | const missingInputs = checkMissingInputs(year, month, '0', '0', '0'); 125 | if (missingInputs) return missingInputs; 126 | if (isInPast(year, month, undefined, undefined, undefined)) 127 | return {success: false, message: 'No timeslots are available in the past'}; 128 | } 129 | 130 | module.exports = { 131 | checkMissingInputs, 132 | validateBooking, 133 | validateGetTimeslots, 134 | validateGetDays 135 | }; -------------------------------------------------------------------------------- /Utility/timeslots.json: -------------------------------------------------------------------------------- 1 | { 2 | "timeslots": [ 3 | { 4 | "startTime": "T09:00:00Z", 5 | "endTime": "T09:40:00Z" 6 | }, 7 | { 8 | "startTime": "T09:45:00Z", 9 | "endTime": "T10:25:00Z" 10 | }, 11 | { 12 | "startTime": "T10:30:00Z", 13 | "endTime": "T11:10:00Z" 14 | }, 15 | { 16 | "startTime": "T11:15:00Z", 17 | "endTime": "T11:55:00Z" 18 | }, 19 | { 20 | "startTime": "T12:00:00Z", 21 | "endTime": "T12:40:00Z" 22 | }, 23 | { 24 | "startTime": "T12:45:00Z", 25 | "endTime": "T13:25:00Z" 26 | }, 27 | { 28 | "startTime": "T13:30:00Z", 29 | "endTime": "T14:10:00Z" 30 | }, 31 | { 32 | "startTime": "T14:15:00Z", 33 | "endTime": "T14:55:00Z" 34 | }, 35 | { 36 | "startTime": "T15:00:00Z", 37 | "endTime": "T15:40:00Z" 38 | }, 39 | { 40 | "startTime": "T15:45:00Z", 41 | "endTime": "T16:25:00Z" 42 | }, 43 | { 44 | "startTime": "T16:30:00Z", 45 | "endTime": "T17:10:00Z" 46 | } 47 | ] 48 | } -------------------------------------------------------------------------------- /package-lock.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-booking-app", 3 | "version": "1.0.0", 4 | "lockfileVersion": 1, 5 | "requires": true, 6 | "dependencies": { 7 | "abort-controller": { 8 | "version": "3.0.0", 9 | "resolved": "https://registry.npmjs.org/abort-controller/-/abort-controller-3.0.0.tgz", 10 | "integrity": "sha512-h8lQ8tacZYnR3vNQTgibj+tODHI5/+l06Au2Pcriv/Gmet0eaj4TwWH41sO9wnHDiQsEj19q0drzdWdeAHtweg==", 11 | "requires": { 12 | "event-target-shim": "^5.0.0" 13 | } 14 | }, 15 | "accepts": { 16 | "version": "1.3.7", 17 | "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", 18 | "integrity": "sha512-Il80Qs2WjYlJIBNzNkK6KYqlVMTbZLXgHx2oT0pU/fjRHyEp+PEfEPY0R3WCwAGVOtauxh1hOxNgIf5bv7dQpA==", 19 | "requires": { 20 | "mime-types": "~2.1.24", 21 | "negotiator": "0.6.2" 22 | } 23 | }, 24 | "agent-base": { 25 | "version": "4.3.0", 26 | "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-4.3.0.tgz", 27 | "integrity": "sha512-salcGninV0nPrwpGNn4VTXBb1SOuXQBiqbrNXoeizJsHrsL6ERFM2Ne3JUSBWRE6aeNJI2ROP/WEEIDUiDe3cg==", 28 | "requires": { 29 | "es6-promisify": "^5.0.0" 30 | } 31 | }, 32 | "array-flatten": { 33 | "version": "1.1.1", 34 | "resolved": "https://registry.npmjs.org/array-flatten/-/array-flatten-1.1.1.tgz", 35 | "integrity": "sha1-ml9pkFGx5wczKPKgCJaLZOopVdI=" 36 | }, 37 | "base64-js": { 38 | "version": "1.3.1", 39 | "resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.3.1.tgz", 40 | "integrity": "sha512-mLQ4i2QO1ytvGWFWmcngKO//JXAQueZvwEKtjgQFM4jIK0kU+ytMfplL8j+n5mspOfjHwoAg+9yhb7BwAHm36g==" 41 | }, 42 | "bignumber.js": { 43 | "version": "7.2.1", 44 | "resolved": "https://registry.npmjs.org/bignumber.js/-/bignumber.js-7.2.1.tgz", 45 | "integrity": "sha512-S4XzBk5sMB+Rcb/LNcpzXr57VRTxgAvaAEDAl1AwRx27j00hT84O6OkteE7u8UB3NuaaygCRrEpqox4uDOrbdQ==" 46 | }, 47 | "body-parser": { 48 | "version": "1.19.0", 49 | "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.19.0.tgz", 50 | "integrity": "sha512-dhEPs72UPbDnAQJ9ZKMNTP6ptJaionhP5cBb541nXPlW60Jepo9RV/a4fX4XWW9CuFNK22krhrj1+rgzifNCsw==", 51 | "requires": { 52 | "bytes": "3.1.0", 53 | "content-type": "~1.0.4", 54 | "debug": "2.6.9", 55 | "depd": "~1.1.2", 56 | "http-errors": "1.7.2", 57 | "iconv-lite": "0.4.24", 58 | "on-finished": "~2.3.0", 59 | "qs": "6.7.0", 60 | "raw-body": "2.4.0", 61 | "type-is": "~1.6.17" 62 | } 63 | }, 64 | "buffer-equal-constant-time": { 65 | "version": "1.0.1", 66 | "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", 67 | "integrity": "sha1-+OcRMvf/5uAaXJaXpMbz5I1cyBk=" 68 | }, 69 | "bytes": { 70 | "version": "3.1.0", 71 | "resolved": "https://registry.npmjs.org/bytes/-/bytes-3.1.0.tgz", 72 | "integrity": "sha512-zauLjrfCG+xvoyaqLoV8bLVXXNGC4JqlxFCutSDWA6fJrTo2ZuvLYTqZ7aHBLZSMOopbzwv8f+wZcVzfVTI2Dg==" 73 | }, 74 | "content-disposition": { 75 | "version": "0.5.3", 76 | "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", 77 | "integrity": "sha512-ExO0774ikEObIAEV9kDo50o+79VCUdEB6n6lzKgGwupcVeRlhrj3qGAfwq8G6uBJjkqLrhT0qEYFcWng8z1z0g==", 78 | "requires": { 79 | "safe-buffer": "5.1.2" 80 | } 81 | }, 82 | "content-type": { 83 | "version": "1.0.4", 84 | "resolved": "https://registry.npmjs.org/content-type/-/content-type-1.0.4.tgz", 85 | "integrity": "sha512-hIP3EEPs8tB9AT1L+NUqtwOAps4mk2Zob89MWXMHjHWg9milF/j4osnnQLXBCBFBk/tvIG/tUc9mOUJiPBhPXA==" 86 | }, 87 | "cookie": { 88 | "version": "0.4.0", 89 | "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.4.0.tgz", 90 | "integrity": "sha512-+Hp8fLp57wnUSt0tY0tHEXh4voZRDnoIrZPqlo3DPiI4y9lwg/jqx+1Om94/W6ZaPDOUbnjOt/99w66zk+l1Xg==" 91 | }, 92 | "cookie-signature": { 93 | "version": "1.0.6", 94 | "resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.6.tgz", 95 | "integrity": "sha1-4wOogrNCzD7oylE6eZmXNNqzriw=" 96 | }, 97 | "debug": { 98 | "version": "2.6.9", 99 | "resolved": "https://registry.npmjs.org/debug/-/debug-2.6.9.tgz", 100 | "integrity": "sha512-bC7ElrdJaJnPbAP+1EotYvqZsb3ecl5wi6Bfi6BJTUcNowp6cvspg0jXznRTKDjm/E7AdgFBVeAPVMNcKGsHMA==", 101 | "requires": { 102 | "ms": "2.0.0" 103 | } 104 | }, 105 | "depd": { 106 | "version": "1.1.2", 107 | "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.2.tgz", 108 | "integrity": "sha1-m81S4UwJd2PnSbJ0xDRu0uVgtak=" 109 | }, 110 | "destroy": { 111 | "version": "1.0.4", 112 | "resolved": "https://registry.npmjs.org/destroy/-/destroy-1.0.4.tgz", 113 | "integrity": "sha1-l4hXRCxEdJ5CBmE+N5RiBYJqvYA=" 114 | }, 115 | "ecdsa-sig-formatter": { 116 | "version": "1.0.11", 117 | "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", 118 | "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", 119 | "requires": { 120 | "safe-buffer": "^5.0.1" 121 | } 122 | }, 123 | "ee-first": { 124 | "version": "1.1.1", 125 | "resolved": "https://registry.npmjs.org/ee-first/-/ee-first-1.1.1.tgz", 126 | "integrity": "sha1-WQxhFWsK4vTwJVcyoViyZrxWsh0=" 127 | }, 128 | "encodeurl": { 129 | "version": "1.0.2", 130 | "resolved": "https://registry.npmjs.org/encodeurl/-/encodeurl-1.0.2.tgz", 131 | "integrity": "sha1-rT/0yG7C0CkyL1oCw6mmBslbP1k=" 132 | }, 133 | "es6-promise": { 134 | "version": "4.2.8", 135 | "resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz", 136 | "integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==" 137 | }, 138 | "es6-promisify": { 139 | "version": "5.0.0", 140 | "resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz", 141 | "integrity": "sha1-UQnWLz5W6pZ8S2NQWu8IKRyKUgM=", 142 | "requires": { 143 | "es6-promise": "^4.0.3" 144 | } 145 | }, 146 | "escape-html": { 147 | "version": "1.0.3", 148 | "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", 149 | "integrity": "sha1-Aljq5NPQwJdN4cFpGI7wBR0dGYg=" 150 | }, 151 | "etag": { 152 | "version": "1.8.1", 153 | "resolved": "https://registry.npmjs.org/etag/-/etag-1.8.1.tgz", 154 | "integrity": "sha1-Qa4u62XvpiJorr/qg6x9eSmbCIc=" 155 | }, 156 | "event-target-shim": { 157 | "version": "5.0.1", 158 | "resolved": "https://registry.npmjs.org/event-target-shim/-/event-target-shim-5.0.1.tgz", 159 | "integrity": "sha512-i/2XbnSz/uxRCU6+NdVJgKWDTM427+MqYbkQzD321DuCQJUqOuJKIA0IM2+W2xtYHdKOmZ4dR6fExsd4SXL+WQ==" 160 | }, 161 | "express": { 162 | "version": "4.17.1", 163 | "resolved": "https://registry.npmjs.org/express/-/express-4.17.1.tgz", 164 | "integrity": "sha512-mHJ9O79RqluphRrcw2X/GTh3k9tVv8YcoyY4Kkh4WDMUYKRZUq0h1o0w2rrrxBqM7VoeUVqgb27xlEMXTnYt4g==", 165 | "requires": { 166 | "accepts": "~1.3.7", 167 | "array-flatten": "1.1.1", 168 | "body-parser": "1.19.0", 169 | "content-disposition": "0.5.3", 170 | "content-type": "~1.0.4", 171 | "cookie": "0.4.0", 172 | "cookie-signature": "1.0.6", 173 | "debug": "2.6.9", 174 | "depd": "~1.1.2", 175 | "encodeurl": "~1.0.2", 176 | "escape-html": "~1.0.3", 177 | "etag": "~1.8.1", 178 | "finalhandler": "~1.1.2", 179 | "fresh": "0.5.2", 180 | "merge-descriptors": "1.0.1", 181 | "methods": "~1.1.2", 182 | "on-finished": "~2.3.0", 183 | "parseurl": "~1.3.3", 184 | "path-to-regexp": "0.1.7", 185 | "proxy-addr": "~2.0.5", 186 | "qs": "6.7.0", 187 | "range-parser": "~1.2.1", 188 | "safe-buffer": "5.1.2", 189 | "send": "0.17.1", 190 | "serve-static": "1.14.1", 191 | "setprototypeof": "1.1.1", 192 | "statuses": "~1.5.0", 193 | "type-is": "~1.6.18", 194 | "utils-merge": "1.0.1", 195 | "vary": "~1.1.2" 196 | } 197 | }, 198 | "extend": { 199 | "version": "3.0.2", 200 | "resolved": "https://registry.npmjs.org/extend/-/extend-3.0.2.tgz", 201 | "integrity": "sha512-fjquC59cD7CyW6urNXK0FBufkZcoiGG80wTuPujX590cB5Ttln20E2UB4S/WARVqhXffZl2LNgS+gQdPIIim/g==" 202 | }, 203 | "fast-text-encoding": { 204 | "version": "1.0.0", 205 | "resolved": "https://registry.npmjs.org/fast-text-encoding/-/fast-text-encoding-1.0.0.tgz", 206 | "integrity": "sha512-R9bHCvweUxxwkDwhjav5vxpFvdPGlVngtqmx4pIZfSUhM/Q4NiIUHB456BAf+Q1Nwu3HEZYONtu+Rya+af4jiQ==" 207 | }, 208 | "finalhandler": { 209 | "version": "1.1.2", 210 | "resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-1.1.2.tgz", 211 | "integrity": "sha512-aAWcW57uxVNrQZqFXjITpW3sIUQmHGG3qSb9mUah9MgMC4NeWhNOlNjXEYq3HjRAvL6arUviZGGJsBg6z0zsWA==", 212 | "requires": { 213 | "debug": "2.6.9", 214 | "encodeurl": "~1.0.2", 215 | "escape-html": "~1.0.3", 216 | "on-finished": "~2.3.0", 217 | "parseurl": "~1.3.3", 218 | "statuses": "~1.5.0", 219 | "unpipe": "~1.0.0" 220 | } 221 | }, 222 | "forwarded": { 223 | "version": "0.1.2", 224 | "resolved": "https://registry.npmjs.org/forwarded/-/forwarded-0.1.2.tgz", 225 | "integrity": "sha1-mMI9qxF1ZXuMBXPozszZGw/xjIQ=" 226 | }, 227 | "fresh": { 228 | "version": "0.5.2", 229 | "resolved": "https://registry.npmjs.org/fresh/-/fresh-0.5.2.tgz", 230 | "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=" 231 | }, 232 | "gaxios": { 233 | "version": "1.8.4", 234 | "resolved": "https://registry.npmjs.org/gaxios/-/gaxios-1.8.4.tgz", 235 | "integrity": "sha512-BoENMnu1Gav18HcpV9IleMPZ9exM+AvUjrAOV4Mzs/vfz2Lu/ABv451iEXByKiMPn2M140uul1txXCg83sAENw==", 236 | "requires": { 237 | "abort-controller": "^3.0.0", 238 | "extend": "^3.0.2", 239 | "https-proxy-agent": "^2.2.1", 240 | "node-fetch": "^2.3.0" 241 | } 242 | }, 243 | "gcp-metadata": { 244 | "version": "1.0.0", 245 | "resolved": "https://registry.npmjs.org/gcp-metadata/-/gcp-metadata-1.0.0.tgz", 246 | "integrity": "sha512-Q6HrgfrCQeEircnNP3rCcEgiDv7eF9+1B+1MMgpE190+/+0mjQR8PxeOaRgxZWmdDAF9EIryHB9g1moPiw1SbQ==", 247 | "requires": { 248 | "gaxios": "^1.0.2", 249 | "json-bigint": "^0.3.0" 250 | } 251 | }, 252 | "google-auth-library": { 253 | "version": "3.1.2", 254 | "resolved": "https://registry.npmjs.org/google-auth-library/-/google-auth-library-3.1.2.tgz", 255 | "integrity": "sha512-cDQMzTotwyWMrg5jRO7q0A4TL/3GWBgO7I7q5xGKNiiFf9SmGY/OJ1YsLMgI2MVHHsEGyrqYnbnmV1AE+Z6DnQ==", 256 | "requires": { 257 | "base64-js": "^1.3.0", 258 | "fast-text-encoding": "^1.0.0", 259 | "gaxios": "^1.2.1", 260 | "gcp-metadata": "^1.0.0", 261 | "gtoken": "^2.3.2", 262 | "https-proxy-agent": "^2.2.1", 263 | "jws": "^3.1.5", 264 | "lru-cache": "^5.0.0", 265 | "semver": "^5.5.0" 266 | } 267 | }, 268 | "google-p12-pem": { 269 | "version": "1.0.4", 270 | "resolved": "https://registry.npmjs.org/google-p12-pem/-/google-p12-pem-1.0.4.tgz", 271 | "integrity": "sha512-SwLAUJqUfTB2iS+wFfSS/G9p7bt4eWcc2LyfvmUXe7cWp6p3mpxDo6LLI29MXdU6wvPcQ/up298X7GMC5ylAlA==", 272 | "requires": { 273 | "node-forge": "^0.8.0", 274 | "pify": "^4.0.0" 275 | } 276 | }, 277 | "googleapis": { 278 | "version": "39.2.0", 279 | "resolved": "https://registry.npmjs.org/googleapis/-/googleapis-39.2.0.tgz", 280 | "integrity": "sha512-66X8TG1B33zAt177sG1CoKoYHPP/B66tEpnnSANGCqotMuY5gqSQO8G/0gqHZR2jRgc5CHSSNOJCnpI0SuDxMQ==", 281 | "requires": { 282 | "google-auth-library": "^3.0.0", 283 | "googleapis-common": "^0.7.0" 284 | } 285 | }, 286 | "googleapis-common": { 287 | "version": "0.7.2", 288 | "resolved": "https://registry.npmjs.org/googleapis-common/-/googleapis-common-0.7.2.tgz", 289 | "integrity": "sha512-9DEJIiO4nS7nw0VE1YVkEfXEj8x8MxsuB+yZIpOBULFSN9OIKcUU8UuKgSZFU4lJmRioMfngktrbkMwWJcUhQg==", 290 | "requires": { 291 | "gaxios": "^1.2.2", 292 | "google-auth-library": "^3.0.0", 293 | "pify": "^4.0.0", 294 | "qs": "^6.5.2", 295 | "url-template": "^2.0.8", 296 | "uuid": "^3.2.1" 297 | } 298 | }, 299 | "gtoken": { 300 | "version": "2.3.3", 301 | "resolved": "https://registry.npmjs.org/gtoken/-/gtoken-2.3.3.tgz", 302 | "integrity": "sha512-EaB49bu/TCoNeQjhCYKI/CurooBKkGxIqFHsWABW0b25fobBYVTMe84A8EBVVZhl8emiUdNypil9huMOTmyAnw==", 303 | "requires": { 304 | "gaxios": "^1.0.4", 305 | "google-p12-pem": "^1.0.0", 306 | "jws": "^3.1.5", 307 | "mime": "^2.2.0", 308 | "pify": "^4.0.0" 309 | }, 310 | "dependencies": { 311 | "mime": { 312 | "version": "2.4.4", 313 | "resolved": "https://registry.npmjs.org/mime/-/mime-2.4.4.tgz", 314 | "integrity": "sha512-LRxmNwziLPT828z+4YkNzloCFC2YM4wrB99k+AV5ZbEyfGNWfG8SO1FUXLmLDBSo89NrJZ4DIWeLjy1CHGhMGA==" 315 | } 316 | } 317 | }, 318 | "http-errors": { 319 | "version": "1.7.2", 320 | "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.7.2.tgz", 321 | "integrity": "sha512-uUQBt3H/cSIVfch6i1EuPNy/YsRSOUBXTVfZ+yR7Zjez3qjBz6i9+i4zjNaoqcoFVI4lQJ5plg63TvGfRSDCRg==", 322 | "requires": { 323 | "depd": "~1.1.2", 324 | "inherits": "2.0.3", 325 | "setprototypeof": "1.1.1", 326 | "statuses": ">= 1.5.0 < 2", 327 | "toidentifier": "1.0.0" 328 | } 329 | }, 330 | "https-proxy-agent": { 331 | "version": "2.2.4", 332 | "resolved": "https://registry.npmjs.org/https-proxy-agent/-/https-proxy-agent-2.2.4.tgz", 333 | "integrity": "sha512-OmvfoQ53WLjtA9HeYP9RNrWMJzzAz1JGaSFr1nijg0PVR1JaD/xbJq1mdEIIlxGpXp9eSe/O2LgU9DJmTPd0Eg==", 334 | "requires": { 335 | "agent-base": "^4.3.0", 336 | "debug": "^3.1.0" 337 | }, 338 | "dependencies": { 339 | "debug": { 340 | "version": "3.2.6", 341 | "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.6.tgz", 342 | "integrity": "sha512-mel+jf7nrtEl5Pn1Qx46zARXKDpBbvzezse7p7LqINmdoIk8PYP5SySaxEmYv6TZ0JyEKA1hsCId6DIhgITtWQ==", 343 | "requires": { 344 | "ms": "^2.1.1" 345 | } 346 | }, 347 | "ms": { 348 | "version": "2.1.2", 349 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", 350 | "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==" 351 | } 352 | } 353 | }, 354 | "iconv-lite": { 355 | "version": "0.4.24", 356 | "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.24.tgz", 357 | "integrity": "sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==", 358 | "requires": { 359 | "safer-buffer": ">= 2.1.2 < 3" 360 | } 361 | }, 362 | "inherits": { 363 | "version": "2.0.3", 364 | "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.3.tgz", 365 | "integrity": "sha1-Yzwsg+PaQqUC9SRmAiSA9CCCYd4=" 366 | }, 367 | "ipaddr.js": { 368 | "version": "1.9.0", 369 | "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.9.0.tgz", 370 | "integrity": "sha512-M4Sjn6N/+O6/IXSJseKqHoFc+5FdGJ22sXqnjTpdZweHK64MzEPAyQZyEU3R/KRv2GLoa7nNtg/C2Ev6m7z+eA==" 371 | }, 372 | "json-bigint": { 373 | "version": "0.3.0", 374 | "resolved": "https://registry.npmjs.org/json-bigint/-/json-bigint-0.3.0.tgz", 375 | "integrity": "sha1-DM2RLEuCcNBfBW+9E4FLU9OCWx4=", 376 | "requires": { 377 | "bignumber.js": "^7.0.0" 378 | } 379 | }, 380 | "jwa": { 381 | "version": "1.4.1", 382 | "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", 383 | "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", 384 | "requires": { 385 | "buffer-equal-constant-time": "1.0.1", 386 | "ecdsa-sig-formatter": "1.0.11", 387 | "safe-buffer": "^5.0.1" 388 | } 389 | }, 390 | "jws": { 391 | "version": "3.2.2", 392 | "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", 393 | "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", 394 | "requires": { 395 | "jwa": "^1.4.1", 396 | "safe-buffer": "^5.0.1" 397 | } 398 | }, 399 | "lru-cache": { 400 | "version": "5.1.1", 401 | "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-5.1.1.tgz", 402 | "integrity": "sha512-KpNARQA3Iwv+jTA0utUVVbrh+Jlrr1Fv0e56GGzAFOXN7dk/FviaDW8LHmK52DlcH4WP2n6gI8vN1aesBFgo9w==", 403 | "requires": { 404 | "yallist": "^3.0.2" 405 | } 406 | }, 407 | "media-typer": { 408 | "version": "0.3.0", 409 | "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", 410 | "integrity": "sha1-hxDXrwqmJvj/+hzgAWhUUmMlV0g=" 411 | }, 412 | "merge-descriptors": { 413 | "version": "1.0.1", 414 | "resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-1.0.1.tgz", 415 | "integrity": "sha1-sAqqVW3YtEVoFQ7J0blT8/kMu2E=" 416 | }, 417 | "methods": { 418 | "version": "1.1.2", 419 | "resolved": "https://registry.npmjs.org/methods/-/methods-1.1.2.tgz", 420 | "integrity": "sha1-VSmk1nZUE07cxSZmVoNbD4Ua/O4=" 421 | }, 422 | "mime": { 423 | "version": "1.6.0", 424 | "resolved": "https://registry.npmjs.org/mime/-/mime-1.6.0.tgz", 425 | "integrity": "sha512-x0Vn8spI+wuJ1O6S7gnbaQg8Pxh4NNHb7KSINmEWKiPE4RKOplvijn+NkmYmmRgP68mc70j2EbeTFRsrswaQeg==" 426 | }, 427 | "mime-db": { 428 | "version": "1.40.0", 429 | "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.40.0.tgz", 430 | "integrity": "sha512-jYdeOMPy9vnxEqFRRo6ZvTZ8d9oPb+k18PKoYNYUe2stVEBPPwsln/qWzdbmaIvnhZ9v2P+CuecK+fpUfsV2mA==" 431 | }, 432 | "mime-types": { 433 | "version": "2.1.24", 434 | "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.24.tgz", 435 | "integrity": "sha512-WaFHS3MCl5fapm3oLxU4eYDw77IQM2ACcxQ9RIxfaC3ooc6PFuBMGZZsYpvoXS5D5QTWPieo1jjLdAm3TBP3cQ==", 436 | "requires": { 437 | "mime-db": "1.40.0" 438 | } 439 | }, 440 | "ms": { 441 | "version": "2.0.0", 442 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.0.0.tgz", 443 | "integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=" 444 | }, 445 | "negotiator": { 446 | "version": "0.6.2", 447 | "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.2.tgz", 448 | "integrity": "sha512-hZXc7K2e+PgeI1eDBe/10Ard4ekbfrrqG8Ep+8Jmf4JID2bNg7NvCPOZN+kfF574pFQI7mum2AUqDidoKqcTOw==" 449 | }, 450 | "node-fetch": { 451 | "version": "2.6.1", 452 | "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.1.tgz", 453 | "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" 454 | }, 455 | "node-forge": { 456 | "version": "0.8.5", 457 | "resolved": "https://registry.npmjs.org/node-forge/-/node-forge-0.8.5.tgz", 458 | "integrity": "sha512-vFMQIWt+J/7FLNyKouZ9TazT74PRV3wgv9UT4cRjC8BffxFbKXkgIWR42URCPSnHm/QDz6BOlb2Q0U4+VQT67Q==" 459 | }, 460 | "on-finished": { 461 | "version": "2.3.0", 462 | "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", 463 | "integrity": "sha1-IPEzZIGwg811M3mSoWlxqi2QaUc=", 464 | "requires": { 465 | "ee-first": "1.1.1" 466 | } 467 | }, 468 | "parseurl": { 469 | "version": "1.3.3", 470 | "resolved": "https://registry.npmjs.org/parseurl/-/parseurl-1.3.3.tgz", 471 | "integrity": "sha512-CiyeOxFT/JZyN5m0z9PfXw4SCBJ6Sygz1Dpl0wqjlhDEGGBP1GnsUVEL0p63hoG1fcj3fHynXi9NYO4nWOL+qQ==" 472 | }, 473 | "path-to-regexp": { 474 | "version": "0.1.7", 475 | "resolved": "https://registry.npmjs.org/path-to-regexp/-/path-to-regexp-0.1.7.tgz", 476 | "integrity": "sha1-32BBeABfUi8V60SQ5yR6G/qmf4w=" 477 | }, 478 | "pify": { 479 | "version": "4.0.1", 480 | "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", 481 | "integrity": "sha512-uB80kBFb/tfd68bVleG9T5GGsGPjJrLAUpR5PZIrhBnIaRTQRjqdJSsIKkOP6OAIFbj7GOrcudc5pNjZ+geV2g==" 482 | }, 483 | "proxy-addr": { 484 | "version": "2.0.5", 485 | "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.5.tgz", 486 | "integrity": "sha512-t/7RxHXPH6cJtP0pRG6smSr9QJidhB+3kXu0KgXnbGYMgzEnUxRQ4/LDdfOwZEMyIh3/xHb8PX3t+lfL9z+YVQ==", 487 | "requires": { 488 | "forwarded": "~0.1.2", 489 | "ipaddr.js": "1.9.0" 490 | } 491 | }, 492 | "qs": { 493 | "version": "6.7.0", 494 | "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", 495 | "integrity": "sha512-VCdBRNFTX1fyE7Nb6FYoURo/SPe62QCaAyzJvUjwRaIsc+NePBEniHlvxFmmX56+HZphIGtV0XeCirBtpDrTyQ==" 496 | }, 497 | "range-parser": { 498 | "version": "1.2.1", 499 | "resolved": "https://registry.npmjs.org/range-parser/-/range-parser-1.2.1.tgz", 500 | "integrity": "sha512-Hrgsx+orqoygnmhFbKaHE6c296J+HTAQXoxEF6gNupROmmGJRoyzfG3ccAveqCBrwr/2yxQ5BVd/GTl5agOwSg==" 501 | }, 502 | "raw-body": { 503 | "version": "2.4.0", 504 | "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.4.0.tgz", 505 | "integrity": "sha512-4Oz8DUIwdvoa5qMJelxipzi/iJIi40O5cGV1wNYp5hvZP8ZN0T+jiNkL0QepXs+EsQ9XJ8ipEDoiH70ySUJP3Q==", 506 | "requires": { 507 | "bytes": "3.1.0", 508 | "http-errors": "1.7.2", 509 | "iconv-lite": "0.4.24", 510 | "unpipe": "1.0.0" 511 | } 512 | }, 513 | "safe-buffer": { 514 | "version": "5.1.2", 515 | "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.2.tgz", 516 | "integrity": "sha512-Gd2UZBJDkXlY7GbJxfsE8/nvKkUEU1G38c1siN6QP6a9PT9MmHB8GnpscSmMJSoF8LOIrt8ud/wPtojys4G6+g==" 517 | }, 518 | "safer-buffer": { 519 | "version": "2.1.2", 520 | "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", 521 | "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" 522 | }, 523 | "semver": { 524 | "version": "5.7.1", 525 | "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", 526 | "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==" 527 | }, 528 | "send": { 529 | "version": "0.17.1", 530 | "resolved": "https://registry.npmjs.org/send/-/send-0.17.1.tgz", 531 | "integrity": "sha512-BsVKsiGcQMFwT8UxypobUKyv7irCNRHk1T0G680vk88yf6LBByGcZJOTJCrTP2xVN6yI+XjPJcNuE3V4fT9sAg==", 532 | "requires": { 533 | "debug": "2.6.9", 534 | "depd": "~1.1.2", 535 | "destroy": "~1.0.4", 536 | "encodeurl": "~1.0.2", 537 | "escape-html": "~1.0.3", 538 | "etag": "~1.8.1", 539 | "fresh": "0.5.2", 540 | "http-errors": "~1.7.2", 541 | "mime": "1.6.0", 542 | "ms": "2.1.1", 543 | "on-finished": "~2.3.0", 544 | "range-parser": "~1.2.1", 545 | "statuses": "~1.5.0" 546 | }, 547 | "dependencies": { 548 | "ms": { 549 | "version": "2.1.1", 550 | "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", 551 | "integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" 552 | } 553 | } 554 | }, 555 | "serve-static": { 556 | "version": "1.14.1", 557 | "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.14.1.tgz", 558 | "integrity": "sha512-JMrvUwE54emCYWlTI+hGrGv5I8dEwmco/00EvkzIIsR7MqrHonbD9pO2MOfFnpFntl7ecpZs+3mW+XbQZu9QCg==", 559 | "requires": { 560 | "encodeurl": "~1.0.2", 561 | "escape-html": "~1.0.3", 562 | "parseurl": "~1.3.3", 563 | "send": "0.17.1" 564 | } 565 | }, 566 | "setprototypeof": { 567 | "version": "1.1.1", 568 | "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.1.1.tgz", 569 | "integrity": "sha512-JvdAWfbXeIGaZ9cILp38HntZSFSo3mWg6xGcJJsd+d4aRMOqauag1C63dJfDw7OaMYwEbHMOxEZ1lqVRYP2OAw==" 570 | }, 571 | "statuses": { 572 | "version": "1.5.0", 573 | "resolved": "https://registry.npmjs.org/statuses/-/statuses-1.5.0.tgz", 574 | "integrity": "sha1-Fhx9rBd2Wf2YEfQ3cfqZOBR4Yow=" 575 | }, 576 | "toidentifier": { 577 | "version": "1.0.0", 578 | "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.0.tgz", 579 | "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==" 580 | }, 581 | "type-is": { 582 | "version": "1.6.18", 583 | "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", 584 | "integrity": "sha512-TkRKr9sUTxEH8MdfuCSP7VizJyzRNMjj2J2do2Jr3Kym598JVdEksuzPQCnlFPW4ky9Q+iA+ma9BGm06XQBy8g==", 585 | "requires": { 586 | "media-typer": "0.3.0", 587 | "mime-types": "~2.1.24" 588 | } 589 | }, 590 | "unpipe": { 591 | "version": "1.0.0", 592 | "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz", 593 | "integrity": "sha1-sr9O6FFKrmFltIF4KdIbLvSZBOw=" 594 | }, 595 | "url-template": { 596 | "version": "2.0.8", 597 | "resolved": "https://registry.npmjs.org/url-template/-/url-template-2.0.8.tgz", 598 | "integrity": "sha1-/FZaPMy/93MMd19WQflVV5FDnyE=" 599 | }, 600 | "utils-merge": { 601 | "version": "1.0.1", 602 | "resolved": "https://registry.npmjs.org/utils-merge/-/utils-merge-1.0.1.tgz", 603 | "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=" 604 | }, 605 | "uuid": { 606 | "version": "3.3.3", 607 | "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.3.3.tgz", 608 | "integrity": "sha512-pW0No1RGHgzlpHJO1nsVrHKpOEIxkGg1xB+v0ZmdNH5OAeAwzAVrCnI2/6Mtx+Uys6iaylxa+D3g4j63IKKjSQ==" 609 | }, 610 | "vary": { 611 | "version": "1.1.2", 612 | "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", 613 | "integrity": "sha1-IpnwLG3tMNSllhsLn3RSShj2NPw=" 614 | }, 615 | "yallist": { 616 | "version": "3.0.3", 617 | "resolved": "https://registry.npmjs.org/yallist/-/yallist-3.0.3.tgz", 618 | "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==" 619 | } 620 | } 621 | } 622 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "nodejs-booking-app", 3 | "version": "1.0.0", 4 | "description": "An appointment booking web app written using JavaScript and powered by Node JS.", 5 | "main": "server.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "Aryan Nateq", 11 | "license": "GPL-3.0", 12 | "dependencies": { 13 | "express": "^4.17.1", 14 | "googleapis": "^39.2.0" 15 | } 16 | } 17 | -------------------------------------------------------------------------------- /server.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const gcal = require('./Utility/gcal.js'); 3 | 4 | const days = require('./ReqHandlers/GET-Handlers/days.js'); 5 | const timeslots = require('./ReqHandlers/GET-Handlers/timeslots.js'); 6 | const book = require('./ReqHandlers/POST-Handlers/book.js'); 7 | 8 | const app = express(); 9 | const auth = {}; 10 | 11 | // Get the OAuth2 client for making Google Calendar API requests. 12 | gcal.initAuthorize(setAuth); 13 | 14 | function setAuth(auth) { 15 | this.auth = auth; 16 | console.log('\nServer is now running... Ctrl+C to end'); 17 | } 18 | 19 | /** 20 | * Handles 'days' GET requests. 21 | * @param {object} req The requests object provided by Express. See Express doc. 22 | * @param {object} res The results object provided by Express. See Express doc. 23 | */ 24 | function handleGetDays(req, res) { 25 | const year = req.query.year; 26 | const month = req.query.month; 27 | days.getBookableDays(this.auth, year, month) 28 | .then(function(data) { 29 | res.send(data); 30 | }) 31 | .catch(function(data) { 32 | res.send(data); 33 | }); 34 | } 35 | 36 | /** 37 | * Handles 'timeslots' GET requests. 38 | * @param {object} req The requests object provided by Express. See Express doc. 39 | * @param {object} res The results object provided by Express. See Express doc. 40 | */ 41 | function handleGetTimeslots(req, res) { 42 | const year = req.query.year; 43 | const month = req.query.month; 44 | const day = req.query.day; 45 | timeslots.getAvailTimeslots(this.auth, year, month, day) 46 | .then(function(data) { 47 | res.send(data); 48 | }) 49 | .catch(function(data) { 50 | res.send(data); 51 | }); 52 | } 53 | 54 | /** 55 | * Handles 'book' POST requests. 56 | * @param {object} req The requests object provided by Express. See Express doc. 57 | * @param {object} res The results object provided by Express. See Express doc. 58 | */ 59 | function handleBookAppointment(req, res) { 60 | const year = req.query.year; 61 | const month = req.query.month; 62 | const day = req.query.day; 63 | const hour = req.query.hour; 64 | const minute = req.query.minute; 65 | book.bookAppointment(this.auth, year, month, day, hour, minute) 66 | .then(function(data) { 67 | res.send(data); 68 | }) 69 | .catch(function(data) { 70 | res.send(data); 71 | }); 72 | } 73 | 74 | // Routes. 75 | app.get('/days', handleGetDays); 76 | app.get('/timeslots', handleGetTimeslots); 77 | app.post('/book', handleBookAppointment); 78 | 79 | // Listen on port 8080 for incoming requests to the server. 80 | const server = app.listen(8080, function() {}); --------------------------------------------------------------------------------