feat(snippets): add snippets entity, crud, and auto-browser-per-run
- add Snippet entity with name, description, code; full CRUD backend - add snippets pages (list, create, edit, detail) and nav entry - add runSnippet helper in code-executor using new Function with args array - add result param to execute() so validateCode can access exec output - remove sessionName from steps; each run now spawns its own fresh browser - fix waitForURL race by polling localStorage for token instead
This commit is contained in:
1 parent
1efbbb38a3
commit
1164289173
26 files changed
+876
-89
No files matched your search
@@ -0,0 +1,67 @@
|
||||
import {
|
||||
Body,
|
||||
Controller,
|
||||
Delete,
|
||||
Get,
|
||||
HttpCode,
|
||||
Param,
|
||||
ParseIntPipe,
|
||||
Patch,
|
||||
Post,
|
||||
Query,
|
||||
} from "@nestjs/common";
|
||||
import { ApiOperation, ApiResponse, ApiTags } from "@nestjs/swagger";
|
||||
import { SnippetService, SnippetOrderBy } from "./snippet.service";
|
||||
import { CreateSnippetDto } from "./dto/create-snippet.dto";
|
||||
import { UpdateSnippetDto } from "./dto/update-snippet.dto";
|
||||
import { PaginationQueryDto } from "../common/dto/pagination.dto";
|
||||
|
||||
@ApiTags("snippets")
|
||||
@Controller("snippets")
|
||||
export class SnippetController {
|
||||
constructor(private readonly snippetService: SnippetService) {}
|
||||
|
||||
@Post()
|
||||
@ApiOperation({ summary: "Create a new snippet" })
|
||||
@ApiResponse({ status: 201, description: "Snippet created" })
|
||||
@ApiResponse({ status: 409, description: "Name already taken" })
|
||||
create(@Body() dto: CreateSnippetDto) {
|
||||
return this.snippetService.create(dto);
|
||||
}
|
||||
|
||||
@Get()
|
||||
@ApiOperation({ summary: "List all snippets (paginated)" })
|
||||
@ApiResponse({ status: 200, description: "Paginated snippets" })
|
||||
findAll(@Query() query: PaginationQueryDto<SnippetOrderBy>) {
|
||||
return this.snippetService.findAll(query);
|
||||
}
|
||||
|
||||
@Get(":id")
|
||||
@ApiOperation({ summary: "Get snippet by ID" })
|
||||
@ApiResponse({ status: 200, description: "Snippet record" })
|
||||
@ApiResponse({ status: 404, description: "Snippet not found" })
|
||||
findOne(@Param("id", ParseIntPipe) id: number) {
|
||||
return this.snippetService.findOne(id);
|
||||
}
|
||||
|
||||
@Patch(":id")
|
||||
@ApiOperation({ summary: "Update a snippet" })
|
||||
@ApiResponse({ status: 200, description: "Snippet updated" })
|
||||
@ApiResponse({ status: 404, description: "Snippet not found" })
|
||||
@ApiResponse({ status: 409, description: "Name already taken" })
|
||||
update(
|
||||
@Param("id", ParseIntPipe) id: number,
|
||||
@Body() dto: UpdateSnippetDto,
|
||||
) {
|
||||
return this.snippetService.update(id, dto);
|
||||
}
|
||||
|
||||
@Delete(":id")
|
||||
@HttpCode(204)
|
||||
@ApiOperation({ summary: "Delete a snippet" })
|
||||
@ApiResponse({ status: 204, description: "Snippet deleted" })
|
||||
@ApiResponse({ status: 404, description: "Snippet not found" })
|
||||
remove(@Param("id", ParseIntPipe) id: number) {
|
||||
return this.snippetService.remove(id);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user