Работа над проектом

This commit is contained in:
Book Pauk
2022-08-21 21:10:56 +07:00
parent c7073635e3
commit 705fce73f7
7 changed files with 172 additions and 28 deletions

View File

@@ -4,7 +4,7 @@ const _ = require('lodash');
const WorkerState = require('../core/WorkerState');//singleton
const WebWorker = require('../core/WebWorker');//singleton
const log = new (require('../core/AppLogger'))().log;//singleton
//const utils = require('../core/utils');
const utils = require('../core/utils');
const cleanPeriod = 1*60*1000;//1 минута
const closeSocketOnIdle = 5*60*1000;//5 минут
@@ -68,6 +68,8 @@ class WebSocketController {
await this.getWorkerState(req, ws); break;
case 'search':
await this.search(req, ws); break;
case 'get-book-list':
await this.getBookList(req, ws); break;
default:
throw new Error(`Action not found: ${req.action}`);
@@ -122,6 +124,15 @@ class WebSocketController {
this.send(result, req, ws);
}
async getBookList(req, ws) {
if (!utils.hasProp(req, 'authorId'))
throw new Error(`authorId is empty`);
const result = await this.webWorker.getBookList(req.authorId);
this.send(result, req, ws);
}
}
module.exports = WebSocketController;