31 lines
853 B
TypeScript
31 lines
853 B
TypeScript
import { Controller, Inject, Post, Req, UseGuards } from "@nestjs/common";
|
|
import { ApiTokenGuard } from "src/api/guards/api-token.guard";
|
|
import { FunctionService } from "./function.service";
|
|
import { Token } from "src/api/entities/token.entity";
|
|
|
|
@Controller("functions")
|
|
@UseGuards(ApiTokenGuard)
|
|
export class FunctionController {
|
|
constructor(
|
|
@Inject(FunctionService)
|
|
private readonly functionService: FunctionService
|
|
) {}
|
|
|
|
@Post("create")
|
|
async createFunction(
|
|
@Req() req: Request & { apiToken: Token },
|
|
name: string,
|
|
source: string
|
|
) {
|
|
return this.functionService.create(req.apiToken.project.id, name, source);
|
|
}
|
|
|
|
@Post("delete")
|
|
async deleteFunction(
|
|
@Req() req: Request & { apiToken: Token },
|
|
name: string
|
|
) {
|
|
return this.functionService.deleteFunction(req.apiToken.project.id, name);
|
|
}
|
|
}
|