feat(browser): add POST /open with session restore and reader mode

- restores cookies and localStorage from DB before page navigation
- readerMode flag extracts plain text via @mozilla/readability (Firefox reader engine)
- add localStorage default '{}' on session entity for clean schema migrations
This commit is contained in:
ars9 committed 2026-04-07 12:27:34 +03:00
1 parent 41dbddd2a1
commit 9e5a813e9d
10 files changed
+688 -4

No files matched your search

+29
View File
@@ -0,0 +1,29 @@
import { Body, Controller, Post } from '@nestjs/common';
import { ApiOperation, ApiResponse, ApiTags } from '@nestjs/swagger';
import { BrowserService, OpenResult } from './browser.service';
import { OpenDto } from './dto/open.dto';
@ApiTags('browser')
@Controller()
export class BrowserController {
constructor(private readonly browserService: BrowserService) {}
@Post('open')
@ApiOperation({ summary: 'Open a URL with a stored session (cookies + localStorage)' })
@ApiResponse({
status: 201,
description: 'Page loaded successfully',
schema: {
properties: {
url: { type: 'string' },
title: { type: 'string' },
content: { type: 'string' },
},
},
})
@ApiResponse({ status: 400, description: 'Session not found or invalid input' })
@ApiResponse({ status: 500, description: 'Browser automation failed' })
open(@Body() dto: OpenDto): Promise<OpenResult> {
return this.browserService.open(dto.sessionName, dto.url, dto.readerMode ?? false);
}
}