mirror of https://github.com/nocodb/nocodb
Ramesh Mane
6 days ago
8 changed files with 277 additions and 17 deletions
@ -0,0 +1,44 @@ |
|||||||
|
import { |
||||||
|
Body, |
||||||
|
Controller, |
||||||
|
Get, |
||||||
|
HttpCode, |
||||||
|
Param, |
||||||
|
Post, |
||||||
|
UseGuards, |
||||||
|
} from '@nestjs/common'; |
||||||
|
import { GlobalGuard } from '~/guards/global/global.guard'; |
||||||
|
import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard'; |
||||||
|
import { TenantContext } from '~/decorators/tenant-context.decorator'; |
||||||
|
import { NcContext } from '~/interface/config'; |
||||||
|
import { CustomUrlsService } from 'src/services/custom-urls.service'; |
||||||
|
|
||||||
|
@Controller() |
||||||
|
@UseGuards(MetaApiLimiterGuard, GlobalGuard) |
||||||
|
export class CustomUrlsController { |
||||||
|
constructor(protected readonly customUrlsService: CustomUrlsService) {} |
||||||
|
|
||||||
|
@Get([ |
||||||
|
'/api/v1/db/meta/custom-url/:customPath', |
||||||
|
'/api/v2/meta/custom-url/:customPath', |
||||||
|
]) |
||||||
|
async getOriginalPath( |
||||||
|
@TenantContext() context: NcContext, |
||||||
|
@Param('customPath') customPath: string, |
||||||
|
) { |
||||||
|
await this.customUrlsService.getOriginalPath(context, customPath); |
||||||
|
} |
||||||
|
|
||||||
|
@Post(['/api/v1/db/meta/custom-url/check-path', '/api/v2/meta/check-path']) |
||||||
|
@HttpCode(200) |
||||||
|
async checkAvailability( |
||||||
|
@TenantContext() context: NcContext, |
||||||
|
@Body() |
||||||
|
body: { |
||||||
|
id?: string; |
||||||
|
custom_path?: string; |
||||||
|
}, |
||||||
|
) { |
||||||
|
await this.customUrlsService.checkAvailability(context, body); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,20 @@ |
|||||||
|
import { Injectable } from '@nestjs/common'; |
||||||
|
import type { NcContext } from '~/interface/config'; |
||||||
|
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; |
||||||
|
import CustomUrl from 'src/models/CustomUrl'; |
||||||
|
|
||||||
|
@Injectable() |
||||||
|
export class CustomUrlsService { |
||||||
|
constructor(private readonly appHooksService: AppHooksService) {} |
||||||
|
|
||||||
|
async checkAvailability( |
||||||
|
context: NcContext, |
||||||
|
params: Pick<CustomUrl, 'id' | 'custom_path'>, |
||||||
|
) { |
||||||
|
return await CustomUrl.checkAvailability(context, params); |
||||||
|
} |
||||||
|
|
||||||
|
async getOriginalPath(context: NcContext, custom_path: string) { |
||||||
|
return await CustomUrl.getOriginUrlByCustomPath(context, custom_path); |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue