From 851e756dc3c48ae16793048ab47dff0b80644e1a Mon Sep 17 00:00:00 2001 From: Kfir Dayan Date: Mon, 24 Apr 2023 21:49:20 +0300 Subject: [PATCH] fixing typescript config issue --- data/holidays.json | 8 +------- data/timeSlots.json | 11 +---------- src/data/holidays.json | 7 +++++++ src/data/timeSlots.json | 10 ++++++++++ src/geocoding.ts | 2 +- src/handlers.ts | 9 +++++---- src/services/holidaysService.ts | 2 +- src/services/timeslotsService.ts | 2 +- src/types/index.js | 2 ++ 9 files changed, 29 insertions(+), 24 deletions(-) create mode 100644 src/data/holidays.json create mode 100644 src/data/timeSlots.json create mode 100644 src/types/index.js diff --git a/data/holidays.json b/data/holidays.json index 94832df..50168b1 100644 --- a/data/holidays.json +++ b/data/holidays.json @@ -1,7 +1 @@ -{ - "holidays": [ - "2023-05-01", - "2023-06-12", - "2023-09-25" - ] -} \ No newline at end of file +{"holidays":["2023-05-01","2023-06-12","2023-09-25"]} \ No newline at end of file diff --git a/data/timeSlots.json b/data/timeSlots.json index 5bdab5d..ee4f0b3 100644 --- a/data/timeSlots.json +++ b/data/timeSlots.json @@ -1,10 +1 @@ -{ - "timeSlots": [ - "08:00 - 10:00", - "10:00 - 12:00", - "12:00 - 14:00", - "14:00 - 16:00", - "16:00 - 18:00", - "18:00 - 20:00" - ] -} \ No newline at end of file +{"timeSlots":["08:00 - 10:00","10:00 - 12:00","12:00 - 14:00","14:00 - 16:00","16:00 - 18:00","18:00 - 20:00"]} \ No newline at end of file diff --git a/src/data/holidays.json b/src/data/holidays.json new file mode 100644 index 0000000..94832df --- /dev/null +++ b/src/data/holidays.json @@ -0,0 +1,7 @@ +{ + "holidays": [ + "2023-05-01", + "2023-06-12", + "2023-09-25" + ] +} \ No newline at end of file diff --git a/src/data/timeSlots.json b/src/data/timeSlots.json new file mode 100644 index 0000000..5bdab5d --- /dev/null +++ b/src/data/timeSlots.json @@ -0,0 +1,10 @@ +{ + "timeSlots": [ + "08:00 - 10:00", + "10:00 - 12:00", + "12:00 - 14:00", + "14:00 - 16:00", + "16:00 - 18:00", + "18:00 - 20:00" + ] +} \ No newline at end of file diff --git a/src/geocoding.ts b/src/geocoding.ts index 1342ad3..efab420 100644 --- a/src/geocoding.ts +++ b/src/geocoding.ts @@ -8,7 +8,7 @@ const GEOCODING_API_KEY = process.env.GEOCODING_API_KEY; // will return at least - street, line1, line2, country, postcode -export const resolveAddress = async (searchTerm: string): Promise => { +export const resolveAddress = async (searchTerm: string): Promise
=> { const response = await axios.get(`https://api.geoapify.com/v1/geocode/search?text=${searchTerm}&format=json&apiKey=${GEOCODING_API_KEY}`); if (response.data.results.length > 0) { const result = response.data.results[0]; diff --git a/src/handlers.ts b/src/handlers.ts index d81ba34..e10dbda 100644 --- a/src/handlers.ts +++ b/src/handlers.ts @@ -3,16 +3,17 @@ import { resolveAddress } from './geocoding'; import { Address } from './types'; export const resolveAddressHandler = (req: Request, res: Response) => { - - const address = resolveAddress(req.body.searchTerm); - + console.log("resolveAddressHandler called"); + const address: Promise
= resolveAddress(req.body.searchTerm); address.then((result) => { + console.log("resolveAddressHandler result: ", result); res.status(200).json(result); }) -}; +}; export const timeslotsHandler = (req: Request, res: Response) => { // TODO: Implement timeslots functionality + }; export const deliveriesHandler = (req: Request, res: Response) => { diff --git a/src/services/holidaysService.ts b/src/services/holidaysService.ts index 2c10268..ce163d7 100644 --- a/src/services/holidaysService.ts +++ b/src/services/holidaysService.ts @@ -1,4 +1,4 @@ -import holidays from '../../data/holidays.json'; +import holidays from '../data/holidays.json'; export function getHolidays() { // for demo resolving the promise immediately with mock data diff --git a/src/services/timeslotsService.ts b/src/services/timeslotsService.ts index 71987be..84292cf 100644 --- a/src/services/timeslotsService.ts +++ b/src/services/timeslotsService.ts @@ -1,4 +1,4 @@ -import timeSlots from '../../data/timeslots.json'; +import timeSlots from '../data/timeslots.json'; export function getAvailableTimeSlots() { // for demo resolving the promise immediately with mock data diff --git a/src/types/index.js b/src/types/index.js new file mode 100644 index 0000000..c8ad2e5 --- /dev/null +++ b/src/types/index.js @@ -0,0 +1,2 @@ +"use strict"; +Object.defineProperty(exports, "__esModule", { value: true });