fixing typescript config issue

This commit is contained in:
Kfir Dayan 2023-04-24 21:49:20 +03:00
parent 64fd4b23c9
commit 851e756dc3
9 changed files with 29 additions and 24 deletions

View file

@ -1,7 +1 @@
{
"holidays": [
"2023-05-01",
"2023-06-12",
"2023-09-25"
]
}
{"holidays":["2023-05-01","2023-06-12","2023-09-25"]}

View file

@ -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"
]
}
{"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"]}

7
src/data/holidays.json Normal file
View file

@ -0,0 +1,7 @@
{
"holidays": [
"2023-05-01",
"2023-06-12",
"2023-09-25"
]
}

10
src/data/timeSlots.json Normal file
View file

@ -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"
]
}

View file

@ -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<void | Address> => {
export const resolveAddress = async (searchTerm: string): Promise<Address> => {
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];

View file

@ -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<Address> = 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) => {

View file

@ -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

View file

@ -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

2
src/types/index.js Normal file
View file

@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });