14066 extensibility add coretriggerroute table (#14241)

This Pr 
- adds a `route` table to the core schema
- adds a controller to trigger route

For now, we need to add a `/s/<workspace_id>` prefix to all routes

We plan to create a custom domain table in order to let the users create
subdomains for their workspace, and so to link their routes to a
subdomain. Thank to that, we will be able to identify workspace_id from
domain name, and the prefix could be `/s`. If we create a native
dedicated subdomain for routes for each workspaces, the prefix could be
completely removed!

Here the follow up ticket to do that ->
https://github.com/twentyhq/twenty/issues/14240
This commit is contained in:
martmull
2025-09-02 11:24:59 +02:00
committed by GitHub
parent bfad5b0477
commit a722d97724
12 changed files with 367 additions and 8 deletions
@@ -0,0 +1,86 @@
import {
Controller,
Delete,
Get,
Param,
Patch,
Post,
Put,
Req,
UseFilters,
UseGuards,
} from '@nestjs/common';
import { Request } from 'express';
import { PublicEndpointGuard } from 'src/engine/guards/public-endpoint.guard';
import { RouteService } from 'src/engine/metadata-modules/route/route.service';
import { HTTPMethod } from 'src/engine/metadata-modules/route/route.entity';
import { RestApiExceptionFilter } from 'src/engine/api/rest/rest-api-exception.filter';
@Controller('s/:workspaceId')
@UseGuards(PublicEndpointGuard)
@UseFilters(RestApiExceptionFilter)
export class RouteController {
constructor(private readonly routeService: RouteService) {}
@Get('*')
async get(
@Param('workspaceId') workspaceId: string,
@Req() request: Request,
) {
return await this.routeService.handle({
workspaceId,
request,
httpMethod: HTTPMethod.GET,
});
}
@Post('*')
async post(
@Param('workspaceId') workspaceId: string,
@Req() request: Request,
) {
return await this.routeService.handle({
workspaceId,
request,
httpMethod: HTTPMethod.POST,
});
}
@Put('*')
async put(
@Param('workspaceId') workspaceId: string,
@Req() request: Request,
) {
return await this.routeService.handle({
workspaceId,
request,
httpMethod: HTTPMethod.PUT,
});
}
@Patch('*')
async patch(
@Param('workspaceId') workspaceId: string,
@Req() request: Request,
) {
return await this.routeService.handle({
workspaceId,
request,
httpMethod: HTTPMethod.PATCH,
});
}
@Delete('*')
async delete(
@Param('workspaceId') workspaceId: string,
@Req() request: Request,
) {
return await this.routeService.handle({
workspaceId,
request,
httpMethod: HTTPMethod.DELETE,
});
}
}