mirror of https://github.com/nocodb/nocodb
Ramesh Mane
4 days ago
7 changed files with 7 additions and 322 deletions
@ -1,38 +0,0 @@
|
||||
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 { 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(@Param('customPath') customPath: string) { |
||||
return await this.customUrlsService.getOriginalPath(customPath); |
||||
} |
||||
|
||||
@Post(['/api/v1/db/meta/custom-url/check-path', '/api/v2/meta/check-path']) |
||||
@HttpCode(200) |
||||
async checkAvailability( |
||||
@Body() |
||||
body: { |
||||
id?: string; |
||||
custom_path?: string; |
||||
}, |
||||
) { |
||||
return await this.customUrlsService.checkAvailability(body); |
||||
} |
||||
} |
@ -1,44 +0,0 @@
|
||||
import type { Knex } from 'knex'; |
||||
import { MetaTable } from '~/utils/globals'; |
||||
|
||||
const up = async (knex: Knex) => { |
||||
await knex.schema.createTable(MetaTable.CUSTOM_URLS, (table) => { |
||||
table.string('id', 20); |
||||
|
||||
table.string('fk_workspace_id', 20); |
||||
|
||||
table.string('base_id', 20); |
||||
|
||||
table.string('fk_model_id', 20); |
||||
|
||||
table.string('view_id', 20); |
||||
|
||||
table.string('original_path'); |
||||
|
||||
table.string('custom_path'); |
||||
|
||||
table.timestamps(true, true); |
||||
}); |
||||
|
||||
await knex.schema.alterTable(MetaTable.PROJECT, (table) => { |
||||
table.string('fk_custom_url_id', 20).index(); |
||||
}); |
||||
|
||||
await knex.schema.alterTable(MetaTable.VIEWS, (table) => { |
||||
table.string('fk_custom_url_id', 20).index(); |
||||
}); |
||||
}; |
||||
|
||||
const down = async (knex: Knex) => { |
||||
await knex.schema.dropTable(MetaTable.CUSTOM_URLS); |
||||
|
||||
await knex.schema.alterTable(MetaTable.PROJECT, (table) => { |
||||
table.dropColumn('fk_custom_url_id'); |
||||
}); |
||||
|
||||
await knex.schema.alterTable(MetaTable.VIEWS, (table) => { |
||||
table.dropColumn('fk_custom_url_id'); |
||||
}); |
||||
}; |
||||
|
||||
export { up, down }; |
@ -1,17 +0,0 @@
|
||||
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(params: Pick<CustomUrl, 'id' | 'custom_path'>) { |
||||
return await CustomUrl.checkAvailability(params); |
||||
} |
||||
|
||||
async getOriginalPath(custom_path: string) { |
||||
return await CustomUrl.getOriginUrlByCustomPath(custom_path); |
||||
} |
||||
} |
Loading…
Reference in new issue