delivery_system/src/index.ts

59 lines
1.4 KiB
TypeScript

import app from './app';
import fs from 'fs';
const env = process.env.NODE_ENV || 'development';
const PORT = process.env.PORT || 3000;
app.listen(PORT, () => {
console.log("STARTING ... ")
if (env === 'development') {
console.log("Generating mock data files")
// generateMockDataFiles();
}
console.log(`Server is running on port ${PORT}`);
});
// const generateMockDataFiles = () => {
// if (!fs.existsSync('./data')) {
// fs.mkdirSync('./data');
// }
// if (!fs.existsSync('./data/timeSlots.json')) {
// const timeSlots = {
// 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"
// ]
// }
// fs.writeFileSync('./data/timeSlots.json', JSON.stringify(timeSlots));
// }
// if (!fs.existsSync('./data/holidays.json')) {
// const holidays = {
// "holidays": [
// {
// "name": "New Year's Day",
// "date": "2023-01-17",
// "country": "US"
// },
// {
// "name": "Mother's Day",
// "date": "2023-09-18",
// "country": "US"
// },
// {
// "name": "Independence Day",
// "date": "2023-10-17",
// "country": "US"
// }
// ]
// }
// fs.writeFileSync('./data/holidays.json', JSON.stringify(holidays));
// }
// }