importing the data json
This commit is contained in:
parent
c7f6066365
commit
64fd4b23c9
7 changed files with 51 additions and 17 deletions
|
@ -1 +1,7 @@
|
||||||
["2023-05-01","2023-06-12","2023-09-25"]
|
{
|
||||||
|
"holidays": [
|
||||||
|
"2023-05-01",
|
||||||
|
"2023-06-12",
|
||||||
|
"2023-09-25"
|
||||||
|
]
|
||||||
|
}
|
|
@ -1 +1,10 @@
|
||||||
["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"
|
||||||
|
]
|
||||||
|
}
|
|
@ -1,5 +1,7 @@
|
||||||
import express from 'express';
|
import express from 'express';
|
||||||
import routes from './routes';
|
import routes from './routes';
|
||||||
|
import { getAvailableTimeSlots } from './services/timeslotsService';
|
||||||
|
import { getHolidays } from './services/holidaysService';
|
||||||
|
|
||||||
const app = express();
|
const app = express();
|
||||||
|
|
||||||
|
|
|
@ -21,7 +21,8 @@ const generateMockDataFiles = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fs.existsSync('./data/timeSlots.json')) {
|
if (!fs.existsSync('./data/timeSlots.json')) {
|
||||||
const timeSlots = [
|
const timeSlots = {
|
||||||
|
timeSlots: [
|
||||||
"08:00 - 10:00",
|
"08:00 - 10:00",
|
||||||
"10:00 - 12:00",
|
"10:00 - 12:00",
|
||||||
"12:00 - 14:00",
|
"12:00 - 14:00",
|
||||||
|
@ -29,15 +30,18 @@ const generateMockDataFiles = () => {
|
||||||
"16:00 - 18:00",
|
"16:00 - 18:00",
|
||||||
"18:00 - 20:00"
|
"18:00 - 20:00"
|
||||||
]
|
]
|
||||||
|
}
|
||||||
fs.writeFileSync('./data/timeSlots.json', JSON.stringify(timeSlots));
|
fs.writeFileSync('./data/timeSlots.json', JSON.stringify(timeSlots));
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!fs.existsSync('./data/holidays.json')) {
|
if (!fs.existsSync('./data/holidays.json')) {
|
||||||
const holidays = [
|
const holidays = {
|
||||||
|
holidays: [
|
||||||
"2023-05-01",
|
"2023-05-01",
|
||||||
"2023-06-12",
|
"2023-06-12",
|
||||||
"2023-09-25"
|
"2023-09-25"
|
||||||
]
|
]
|
||||||
|
}
|
||||||
fs.writeFileSync('./data/holidays.json', JSON.stringify(holidays));
|
fs.writeFileSync('./data/holidays.json', JSON.stringify(holidays));
|
||||||
}
|
}
|
||||||
}
|
}
|
6
src/services/holidaysService.ts
Normal file
6
src/services/holidaysService.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import holidays from '../../data/holidays.json';
|
||||||
|
|
||||||
|
export function getHolidays() {
|
||||||
|
// for demo resolving the promise immediately with mock data
|
||||||
|
return Promise.resolve(holidays);
|
||||||
|
}
|
6
src/services/timeslotsService.ts
Normal file
6
src/services/timeslotsService.ts
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
import timeSlots from '../../data/timeslots.json';
|
||||||
|
|
||||||
|
export function getAvailableTimeSlots() {
|
||||||
|
// for demo resolving the promise immediately with mock data
|
||||||
|
return Promise.resolve(timeSlots);
|
||||||
|
}
|
|
@ -1,5 +1,6 @@
|
||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"resolveJsonModule": true,
|
||||||
"target": "es6",
|
"target": "es6",
|
||||||
"module": "commonjs",
|
"module": "commonjs",
|
||||||
"outDir": "dist",
|
"outDir": "dist",
|
||||||
|
|
Loading…
Reference in a new issue