From b372d46928b9658b21658d4e768777f6bd33998a Mon Sep 17 00:00:00 2001 From: jacoblurie29 Date: Sun, 14 Apr 2024 21:30:01 -0500 Subject: [PATCH] Fix comments and remove unused functions --- src/controllers/Dashboard.controller.ts | 3 - src/controllers/FlightRequest.controller.ts | 65 --------------------- src/routes/routes.ts | 4 -- 3 files changed, 72 deletions(-) diff --git a/src/controllers/Dashboard.controller.ts b/src/controllers/Dashboard.controller.ts index 28c767b..a97a163 100644 --- a/src/controllers/Dashboard.controller.ts +++ b/src/controllers/Dashboard.controller.ts @@ -9,9 +9,6 @@ import type { Request, Response } from 'express'; * @param res - the response object */ export const getDashboardStats = async (req: Request, res: Response) => { - // use Joi to validate the request body - // ... - const base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY || '' }).base( 'appwPsfAb6U8CV3mf' ); diff --git a/src/controllers/FlightRequest.controller.ts b/src/controllers/FlightRequest.controller.ts index ef483f1..1ec6bc6 100644 --- a/src/controllers/FlightRequest.controller.ts +++ b/src/controllers/FlightRequest.controller.ts @@ -1,5 +1,3 @@ -/* eslint-disable no-irregular-whitespace */ -import { createTestFlightLegData } from '../data/test-data'; import logger from '../util/logger'; import { trimFlightLeg, trimRequest } from '../util/trim'; import Airtable from 'airtable'; @@ -13,20 +11,6 @@ const base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY || '', }).base('appwPsfAb6U8CV3mf'); -/** - * This function returns all flight requests for a given user - * - * Steps to complete: - * 1. Get the userId from the query parameters, if it doesn't exist return a 400 - * 2. Make a call to AirTable to get all flight requests for the user, if that fails return a 500 (hint, use try/catch) - *    If there are no flight requests for the user return a 400. (hint: use the AirTable API, see TestControllers/retrievePassengers.ts for an example) - *    Another hint - we will be filtering by the "Passenger ID" field in the AirTable - * 3. Remove any unnecessary data from the flight requests (there is a lot of data in the AirTable response we don't need) - * 4. Return the flight requests for the user - * - * @param req - the request object - * @param res - the response object - */ /** * Get all flight requests for a given user * @@ -177,52 +161,3 @@ export const getFlightLegsById = async (req: Request, res: Response) => { return res.status(200).send(flightLegs); }; - -/** - * This function creates a flight request for a given user - * - * Steps to complete: - * 1. Use Joi to validate the request body, if it doesn't exist or is invalid return a 400 - * 2. Create a fake flight request by making a call to JotForm. If that fails return a 500 (hint, use try/catch) - * 3. Return the flight request that was created - * - * @param req - the request object - * @param res - the response object - */ -export const createFlightRequest = async (req: Request, res: Response) => { - // get the flight request data from the request body - // const data = req.body; - - // use Joi to validate the request body - // ... - - // create a fake flight request - const flightRequest = createTestFlightLegData(); // return the flight request - - res.status(200).send(flightRequest); -}; - -/** - * This function updates a flight request for a given flightRequestId - * - * Steps to complete: - * 1. Get the flightRequestId from the path parameters, if it doesn't exist return a 400 - * 2. Use Joi to validate the request body, if it doesn't exist or is invalid return a 400 - * 3. Update the flight request by making a call to AirTable. If that fails return a 500 (hint, use try/catch) - * 4. Return the entire flight request that was updated, once again removing any unnecessary data - * - * @param req - the request object - * @param res - the response object - */ -export const updateFlightRequest = async (req: Request, res: Response) => { - // get the flightRequestId from the path parameters - // const { flightRequestId } = req.params; - - // use Joi to validate the request body - // ... - - // create a fake flight request that was "updated" - const flightRequest = createTestFlightLegData(); // return the flight request - - res.status(200).send(flightRequest); -}; diff --git a/src/routes/routes.ts b/src/routes/routes.ts index c2cf049..4fffee2 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -14,8 +14,6 @@ import { getAllFlightRequestsForUser, getFlightRequestById, getFlightLegsById, - createFlightRequest, - updateFlightRequest, } from '../controllers/FlightRequest.controller'; import express from 'express'; import type { Request, Response } from 'express'; @@ -51,7 +49,5 @@ router.get('/dashboard/', getDashboardStats); router.get('/requests', validateAuth, getAllFlightRequestsForUser); router.get('/requests/:id', validateAuth, getFlightRequestById); router.get('/requests/:id/legs', validateAuth, getFlightLegsById); -router.post('/requests/', validateAuth, createFlightRequest); -router.put('/requests/:id', validateAuth, updateFlightRequest); export default router;