fase(3): crawling module domain and application
This commit is contained in:
28
dist/modules/crawling/application/queries/GetSessionQuery.js
vendored
Normal file
28
dist/modules/crawling/application/queries/GetSessionQuery.js
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.GetSessionQuery = void 0;
|
||||
const Result_1 = require("../../../../shared/domain/Result");
|
||||
const UniqueId_1 = require("../../../../shared/domain/UniqueId");
|
||||
class GetSessionQuery {
|
||||
constructor(repository) {
|
||||
this.repository = repository;
|
||||
}
|
||||
async execute(request) {
|
||||
const id = UniqueId_1.UniqueId.from(request.sessionId);
|
||||
const session = await this.repository.findById(id);
|
||||
if (!session) {
|
||||
return (0, Result_1.Err)('Session not found');
|
||||
}
|
||||
const dto = {
|
||||
id: session.id.toString(),
|
||||
url: session.url,
|
||||
status: session.status,
|
||||
seed: session.seed,
|
||||
maxStates: session.maxStates,
|
||||
statesVisited: session.statesVisited,
|
||||
config: session.config,
|
||||
};
|
||||
return (0, Result_1.Ok)(dto);
|
||||
}
|
||||
}
|
||||
exports.GetSessionQuery = GetSessionQuery;
|
||||
Reference in New Issue
Block a user