-
Notifications
You must be signed in to change notification settings - Fork 0
/
core.js
34 lines (28 loc) · 1021 Bytes
/
core.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
/*
* kvázi-interaktorként viselkedő osztály
*/
const Storage = require('./storage');
const storage = new Storage();
module.exports = class Core {
// az url query-vel fordulunk a storage-hez
// és json-né alakított választ kapunk vissza
getDataWithQueryString(queryString) {
const resultObject = storage.queryInFileSystem(queryString);
return this.parseAnswerToJson(resultObject);
}
// a lekérdezés logoláshoz szükséges információit
// továbbítjuk a storage felé
writeLogEntry(queryString, filePath) {
storage.writeRequestLog(queryString, filePath);
}
// lekérdezzük a storage-tól a lelogolt kéréseket
getLogData(filePath) {
const logContent = storage.getLogContent(filePath);
return JSON.stringify(logContent);
}
// a storage válaszát json-né alakítjuk
// (ezt éppen használhattam volna a getLogData()-ban is :\)
parseAnswerToJson(answer) {
return JSON.stringify(answer);
}
}