From f78172966f3eb0bdec087c8136cf7df24c6bc822 Mon Sep 17 00:00:00 2001 From: 22rohanr <22rohanr@students.harker.org> Date: Sun, 20 Oct 2024 14:20:36 -0500 Subject: [PATCH] finished change --- src/controllers/Dashboard.controller.ts | 4 +--- src/controllers/FlightRequest.controller.ts | 6 +++--- src/controllers/Passenger.controller.ts | 8 ++++---- src/controllers/User.controller.ts | 2 +- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/controllers/Dashboard.controller.ts b/src/controllers/Dashboard.controller.ts index a97a163..60f1908 100644 --- a/src/controllers/Dashboard.controller.ts +++ b/src/controllers/Dashboard.controller.ts @@ -9,9 +9,7 @@ import type { Request, Response } from 'express'; * @param res - the response object */ export const getDashboardStats = async (req: Request, res: Response) => { - const base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY || '' }).base( - 'appwPsfAb6U8CV3mf' - ); + const base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY || '' }).base(process.env.AIRTABLE_BASE_ID || ''); try { await base('Data Table') diff --git a/src/controllers/FlightRequest.controller.ts b/src/controllers/FlightRequest.controller.ts index b961e94..b541a92 100644 --- a/src/controllers/FlightRequest.controller.ts +++ b/src/controllers/FlightRequest.controller.ts @@ -10,7 +10,7 @@ dotenv.config(); const base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY || '', -}).base('appwPsfAb6U8CV3mf'); +}).base(process.env.AIRTABLE_BASE_ID || ''); /** * Get all flight requests for a given user @@ -113,7 +113,7 @@ export const getFlightRequestById = async (req: Request, res: Response) => { const base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY || '', - }).base('appwPsfAb6U8CV3mf'); + }).base(process.env.AIRTABLE_BASE_ID || ''); try { await base('Flight Requests (Trips)').find( @@ -148,7 +148,7 @@ export const getFlightLegsById = async (req: Request, res: Response) => { const base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY || '', - }).base('appwPsfAb6U8CV3mf'); + }).base(process.env.AIRTABLE_BASE_ID || ''); try { flightLegs = await base('Flight Legs') diff --git a/src/controllers/Passenger.controller.ts b/src/controllers/Passenger.controller.ts index e6e0f48..00ad93a 100644 --- a/src/controllers/Passenger.controller.ts +++ b/src/controllers/Passenger.controller.ts @@ -11,7 +11,7 @@ dotenv.config(); const base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY || '', -}).base('appwPsfAb6U8CV3mf'); +}).base(process.env.AIRTABLE_BASE_ID || ''); /** * Get all of the related passengers for a user (people they have flown with in the past) @@ -29,7 +29,7 @@ export const getAllPassengersForUser = async (req: Request, res: Response) => { const base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY || '', - }).base('appwPsfAb6U8CV3mf'); + }).base(process.env.AIRTABLE_BASE_ID || ''); try { // make a call to AirTable to get all passengers for the user @@ -93,7 +93,7 @@ export const getPassengerById = async (req: Request, res: Response) => { const base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY || '', - }).base('appwPsfAb6U8CV3mf'); + }).base(process.env.AIRTABLE_BASE_ID || ''); try { await base('Passengers').find( @@ -308,7 +308,7 @@ export const updatePassenger = async (req: Request, res: Response) => { const base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY || '', - }).base('appwPsfAb6U8CV3mf'); + }).base(process.env.AIRTABLE_BASE_ID || ''); try { // make a call to AirTable to update the passenger diff --git a/src/controllers/User.controller.ts b/src/controllers/User.controller.ts index e4b135a..32f9176 100644 --- a/src/controllers/User.controller.ts +++ b/src/controllers/User.controller.ts @@ -45,7 +45,7 @@ export const createUser = async (req: WithAuthProp, res: Response) => { const base = new Airtable({ apiKey: process.env.AIRTABLE_API_KEY || '', - }).base('appwPsfAb6U8CV3mf'); + }).base(process.env.AIRTABLE_BASE_ID || ''); const passenger = await base('Passengers') .select({