-
Notifications
You must be signed in to change notification settings - Fork 0
/
weather.js
42 lines (34 loc) · 1.37 KB
/
weather.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#!/usr/bin/env node
import path from "node:path";
import os from "node:os";
import fs from "node:fs";
import { App } from "./services/app.service.js";
import { ArgumentManager } from "./services/args.service.js";
import { LogManager } from "./services/log.service.js";
import { StorageManager } from "./services/storage.service.js";
import { WeatherAPI } from "./services/weather.service.js";
import { fileURLToPath } from 'url';
import { dirname } from 'path';
const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);
const getOpenWeatherConfig = async (filePath) => {
const data = await fs.promises.readFile(filePath, "utf-8");
return JSON.parse(data).openweater;
};
const OPEN_WEATHER_CONFIG = await getOpenWeatherConfig(path.resolve(__dirname, "./app.config.json"));
const FILE_PATH = path.join(os.homedir(), "weather-data.json"); // Move upper later
// const WEATHER_BASE_URL = config.openweater.apiUrl;
const argsManager = new ArgumentManager();
const storageManager = new StorageManager({ filePath: FILE_PATH });
const logManager = new LogManager();
const weatherManager = new WeatherAPI({ config: OPEN_WEATHER_CONFIG });
const application = new App({
argsManager,
storageManager,
logManager,
weatherManager
});
application
.launch()
.catch((error) => console.error(error));
// .then(() => // console.log("App started"))