Browse Source

refactor: proper request type - WIP

pull/6914/head
Pranav C 1 year ago
parent
commit
30a95e3347
  1. 9
      packages/nocodb/src/controllers/api-tokens.controller.ts
  2. 13
      packages/nocodb/src/controllers/attachments-secure.controller.ts
  3. 16
      packages/nocodb/src/controllers/attachments.controller.ts
  4. 13
      packages/nocodb/src/controllers/audits.controller.ts
  5. 14
      packages/nocodb/src/controllers/auth/auth.controller.ts
  6. 15
      packages/nocodb/src/controllers/base-users.controller.ts
  7. 11
      packages/nocodb/src/controllers/bases.controller.ts
  8. 17
      packages/nocodb/src/controllers/bulk-data-alias.controller.ts
  9. 11
      packages/nocodb/src/controllers/columns.controller.ts
  10. 7
      packages/nocodb/src/controllers/data-alias-export.controller.ts
  11. 17
      packages/nocodb/src/controllers/data-alias-nested.controller.ts
  12. 33
      packages/nocodb/src/controllers/data-alias.controller.ts
  13. 27
      packages/nocodb/src/controllers/data-table.controller.ts
  14. 27
      packages/nocodb/src/controllers/datas.controller.ts
  15. 9
      packages/nocodb/src/controllers/filters.controller.ts
  16. 5
      packages/nocodb/src/controllers/form-columns.controller.ts
  17. 4
      packages/nocodb/src/controllers/forms.controller.ts
  18. 4
      packages/nocodb/src/controllers/galleries.controller.ts
  19. 2
      packages/nocodb/src/controllers/grid-columns.controller.ts
  20. 4
      packages/nocodb/src/controllers/grids.controller.ts
  21. 10
      packages/nocodb/src/controllers/hooks.controller.ts
  22. 4
      packages/nocodb/src/controllers/kanbans.controller.ts
  23. 4
      packages/nocodb/src/controllers/maps.controller.ts
  24. 2
      packages/nocodb/src/controllers/model-visibilities.controller.ts
  25. 2
      packages/nocodb/src/controllers/notifications.controller.ts
  26. 2
      packages/nocodb/src/controllers/org-tokens.controller.ts
  27. 2
      packages/nocodb/src/controllers/org-users.controller.ts
  28. 4
      packages/nocodb/src/controllers/plugins.controller.ts
  29. 19
      packages/nocodb/src/controllers/public-datas.controller.ts
  30. 2
      packages/nocodb/src/controllers/public-metas.controller.ts
  31. 2
      packages/nocodb/src/controllers/shared-bases.controller.ts
  32. 6
      packages/nocodb/src/controllers/sorts.controller.ts
  33. 5
      packages/nocodb/src/controllers/sources.controller.ts
  34. 6
      packages/nocodb/src/controllers/sync.controller.ts
  35. 2
      packages/nocodb/src/controllers/utils.controller.ts
  36. 4
      packages/nocodb/src/controllers/view-columns.controller.ts
  37. 6
      packages/nocodb/src/controllers/views.controller.ts
  38. 9
      packages/nocodb/src/interface/config.ts
  39. 2
      packages/nocodb/src/modules/jobs/jobs.controller.ts
  40. 2
      packages/nocodb/src/modules/jobs/jobs/at-import/at-import.controller.ts
  41. 6
      packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts
  42. 4
      packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.controller.ts
  43. 2
      packages/nocodb/src/modules/jobs/jobs/source-create/source-create.controller.ts
  44. 2
      packages/nocodb/src/modules/jobs/jobs/source-delete/source-delete.controller.ts
  45. 26
      packages/nocodb/src/types/express.d.ts
  46. 3
      packages/nocodb/tsconfig.json

9
packages/nocodb/src/controllers/api-tokens.controller.ts

@ -6,9 +6,10 @@ import {
HttpCode, HttpCode,
Param, Param,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { ApiTokensService } from '~/services/api-tokens.service'; import { ApiTokensService } from '~/services/api-tokens.service';
@ -25,7 +26,7 @@ export class ApiTokensController {
'/api/v2/meta/bases/:baseId/api-tokens', '/api/v2/meta/bases/:baseId/api-tokens',
]) ])
@Acl('baseApiTokenList') @Acl('baseApiTokenList')
async apiTokenList(@Request() req) { async apiTokenList(@Req() req: Request) {
return new PagedResponseImpl( return new PagedResponseImpl(
await this.apiTokensService.apiTokenList({ userId: req['user'].id }), await this.apiTokensService.apiTokenList({ userId: req['user'].id }),
); );
@ -37,7 +38,7 @@ export class ApiTokensController {
]) ])
@HttpCode(200) @HttpCode(200)
@Acl('baseApiTokenCreate') @Acl('baseApiTokenCreate')
async apiTokenCreate(@Request() req, @Body() body) { async apiTokenCreate(@Req() req: Request, @Body() body) {
return await this.apiTokensService.apiTokenCreate({ return await this.apiTokensService.apiTokenCreate({
tokenBody: body, tokenBody: body,
userId: req['user'].id, userId: req['user'].id,
@ -50,7 +51,7 @@ export class ApiTokensController {
'/api/v2/meta/bases/:baseId/api-tokens/:token', '/api/v2/meta/bases/:baseId/api-tokens/:token',
]) ])
@Acl('baseApiTokenDelete') @Acl('baseApiTokenDelete')
async apiTokenDelete(@Request() req, @Param('token') token: string) { async apiTokenDelete(@Req() req: Request, @Param('token') token: string) {
return await this.apiTokensService.apiTokenDelete({ return await this.apiTokensService.apiTokenDelete({
token, token,
user: req['user'], user: req['user'],

13
packages/nocodb/src/controllers/attachments-secure.controller.ts

@ -6,8 +6,8 @@ import {
HttpCode, HttpCode,
Param, Param,
Post, Post,
Request, Req,
Response, Res,
UploadedFiles, UploadedFiles,
UseGuards, UseGuards,
UseInterceptors, UseInterceptors,
@ -15,8 +15,7 @@ import {
import hash from 'object-hash'; import hash from 'object-hash';
import moment from 'moment'; import moment from 'moment';
import { AnyFilesInterceptor } from '@nestjs/platform-express'; import { AnyFilesInterceptor } from '@nestjs/platform-express';
import { Response as ResponseType } from 'express'; import { Request, Response } from 'express';
import type { Request as RequestType } from 'express';
import type { AttachmentReqType, FileType } from 'nocodb-sdk'; import type { AttachmentReqType, FileType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { AttachmentsService } from '~/services/attachments.service'; import { AttachmentsService } from '~/services/attachments.service';
@ -34,7 +33,7 @@ export class AttachmentsSecureController {
@UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor()) @UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor())
async upload( async upload(
@UploadedFiles() files: Array<FileType>, @UploadedFiles() files: Array<FileType>,
@Request() req: RequestType & { user: { id: string } }, @Req() req: Request & { user: { id: string } },
) { ) {
const path = `${moment().format('YYYY/MM/DD')}/${hash(req.user.id)}`; const path = `${moment().format('YYYY/MM/DD')}/${hash(req.user.id)}`;
@ -53,7 +52,7 @@ export class AttachmentsSecureController {
@UseGuards(MetaApiLimiterGuard, GlobalGuard) @UseGuards(MetaApiLimiterGuard, GlobalGuard)
async uploadViaURL( async uploadViaURL(
@Body() body: Array<AttachmentReqType>, @Body() body: Array<AttachmentReqType>,
@Request() req: RequestType & { user: { id: string } }, @Req() req: Request & { user: { id: string } },
) { ) {
const path = `${moment().format('YYYY/MM/DD')}/${hash(req.user.id)}`; const path = `${moment().format('YYYY/MM/DD')}/${hash(req.user.id)}`;
@ -69,7 +68,7 @@ export class AttachmentsSecureController {
@Get('/dltemp/:param(*)') @Get('/dltemp/:param(*)')
async fileReadv3( async fileReadv3(
@Param('param') param: string, @Param('param') param: string,
@Response() res: ResponseType, @Res() res: Response,
) { ) {
try { try {
const fpath = await PresignedUrl.getPath(`dltemp/${param}`); const fpath = await PresignedUrl.getPath(`dltemp/${param}`);

16
packages/nocodb/src/controllers/attachments.controller.ts

@ -7,14 +7,14 @@ import {
Param, Param,
Post, Post,
Query, Query,
Request, Req,
Response, Res,
UploadedFiles, UploadedFiles,
UseGuards, UseGuards,
UseInterceptors, UseInterceptors,
} from '@nestjs/common'; } from '@nestjs/common';
import { AnyFilesInterceptor } from '@nestjs/platform-express'; import { AnyFilesInterceptor } from '@nestjs/platform-express';
import { Request as RequestType, Response as ResponseType } from 'express'; import { Request, Response } from 'express';
import type { AttachmentReqType, FileType } from 'nocodb-sdk'; import type { AttachmentReqType, FileType } from 'nocodb-sdk';
import { UploadAllowedInterceptor } from '~/interceptors/is-upload-allowed/is-upload-allowed.interceptor'; import { UploadAllowedInterceptor } from '~/interceptors/is-upload-allowed/is-upload-allowed.interceptor';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
@ -32,7 +32,7 @@ export class AttachmentsController {
@UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor()) @UseInterceptors(UploadAllowedInterceptor, AnyFilesInterceptor())
async upload( async upload(
@UploadedFiles() files: Array<FileType>, @UploadedFiles() files: Array<FileType>,
@Request() req: RequestType, @Req() req: Request,
) { ) {
const attachments = await this.attachmentsService.upload({ const attachments = await this.attachmentsService.upload({
files: files, files: files,
@ -50,7 +50,7 @@ export class AttachmentsController {
async uploadViaURL( async uploadViaURL(
@Body() body: Array<AttachmentReqType>, @Body() body: Array<AttachmentReqType>,
@Query('path') path: string, @Query('path') path: string,
@Request() req: any, @Req() req: Request,
) { ) {
const attachments = await this.attachmentsService.uploadViaURL({ const attachments = await this.attachmentsService.uploadViaURL({
urls: body, urls: body,
@ -67,7 +67,7 @@ export class AttachmentsController {
// This route will match any URL that starts with // This route will match any URL that starts with
async fileRead( async fileRead(
@Param('filename') filename: string, @Param('filename') filename: string,
@Response() res: ResponseType, @Res() res: Response,
) { ) {
try { try {
const file = await this.attachmentsService.getFile({ const file = await this.attachmentsService.getFile({
@ -87,7 +87,7 @@ export class AttachmentsController {
@Param('param1') param1: string, @Param('param1') param1: string,
@Param('param2') param2: string, @Param('param2') param2: string,
@Param('filename') filename: string, @Param('filename') filename: string,
@Response() res: ResponseType, @Res() res: Response,
) { ) {
try { try {
const file = await this.attachmentsService.getFile({ const file = await this.attachmentsService.getFile({
@ -109,7 +109,7 @@ export class AttachmentsController {
@Get('/dltemp/:param(*)') @Get('/dltemp/:param(*)')
async fileReadv3( async fileReadv3(
@Param('param') param: string, @Param('param') param: string,
@Response() res: ResponseType, @Res() res: Response,
) { ) {
try { try {
const fpath = await PresignedUrl.getPath(`dltemp/${param}`); const fpath = await PresignedUrl.getPath(`dltemp/${param}`);

13
packages/nocodb/src/controllers/audits.controller.ts

@ -7,9 +7,10 @@ import {
Patch, Patch,
Post, Post,
Query, Query,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { AuditsService } from '~/services/audits.service'; import { AuditsService } from '~/services/audits.service';
@ -24,7 +25,7 @@ export class AuditsController {
@Post(['/api/v1/db/meta/audits/comments', '/api/v2/meta/audits/comments']) @Post(['/api/v1/db/meta/audits/comments', '/api/v2/meta/audits/comments'])
@HttpCode(200) @HttpCode(200)
@Acl('commentRow') @Acl('commentRow')
async commentRow(@Request() req) { async commentRow(@Req() req: Request) {
return await this.auditsService.commentRow({ return await this.auditsService.commentRow({
user: (req as any).user, user: (req as any).user,
body: req.body, body: req.body,
@ -46,7 +47,7 @@ export class AuditsController {
@Get(['/api/v1/db/meta/audits/comments', '/api/v2/meta/audits/comments']) @Get(['/api/v1/db/meta/audits/comments', '/api/v2/meta/audits/comments'])
@Acl('commentList') @Acl('commentList')
async commentList(@Request() req) { async commentList(@Req() req: Request) {
return new PagedResponseImpl( return new PagedResponseImpl(
await this.auditsService.commentList({ query: req.query }), await this.auditsService.commentList({ query: req.query }),
); );
@ -59,7 +60,7 @@ export class AuditsController {
@Acl('commentUpdate') @Acl('commentUpdate')
async commentUpdate( async commentUpdate(
@Param('auditId') auditId: string, @Param('auditId') auditId: string,
@Request() req, @Req() req: Request,
@Body() body: any, @Body() body: any,
) { ) {
return await this.auditsService.commentUpdate({ return await this.auditsService.commentUpdate({
@ -74,14 +75,14 @@ export class AuditsController {
'/api/v2/meta/bases/:baseId/audits/', '/api/v2/meta/bases/:baseId/audits/',
]) ])
@Acl('auditList') @Acl('auditList')
async auditList(@Request() req, @Param('baseId') baseId: string) { async auditList(@Req() req: Request, @Param('baseId') baseId: string) {
return new PagedResponseImpl( return new PagedResponseImpl(
await this.auditsService.auditList({ await this.auditsService.auditList({
query: req.query, query: req.query,
baseId, baseId,
}), }),
{ {
count: this.auditsService.auditCount({ baseId }), count: await this.auditsService.auditCount({ baseId }),
...req.query, ...req.query,
}, },
); );

14
packages/nocodb/src/controllers/auth/auth.controller.ts

@ -41,7 +41,7 @@ export class AuthController {
]) ])
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
@HttpCode(200) @HttpCode(200)
async signup(@Request() req: any, @Response() res: any): Promise<any> { async signup(@Req() req: Request, @Response() res: any): Promise<any> {
if (this.config.get('auth', { infer: true }).disableEmailAuth) { if (this.config.get('auth', { infer: true }).disableEmailAuth) {
NcError.forbidden('Email authentication is disabled'); NcError.forbidden('Email authentication is disabled');
} }
@ -61,7 +61,7 @@ export class AuthController {
]) ])
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
@HttpCode(200) @HttpCode(200)
async refreshToken(@Request() req: any, @Response() res: any): Promise<any> { async refreshToken(@Req() req: Request, @Response() res: any): Promise<any> {
res.json( res.json(
await this.usersService.refreshToken({ await this.usersService.refreshToken({
body: req.body, body: req.body,
@ -137,7 +137,7 @@ export class AuthController {
scope: 'org', scope: 'org',
}) })
@HttpCode(200) @HttpCode(200)
async passwordChange(@Request() req: any): Promise<any> { async passwordChange(@Req() req: Request): Promise<any> {
if (!(req as any).isAuthenticated()) { if (!(req as any).isAuthenticated()) {
NcError.forbidden('Not allowed'); NcError.forbidden('Not allowed');
} }
@ -158,7 +158,7 @@ export class AuthController {
]) ])
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
@HttpCode(200) @HttpCode(200)
async passwordForgot(@Request() req: any): Promise<any> { async passwordForgot(@Req() req: Request): Promise<any> {
await this.usersService.passwordForgot({ await this.usersService.passwordForgot({
siteUrl: (req as any).ncSiteUrl, siteUrl: (req as any).ncSiteUrl,
body: req.body, body: req.body,
@ -190,7 +190,7 @@ export class AuthController {
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
@HttpCode(200) @HttpCode(200)
async passwordReset( async passwordReset(
@Request() req: any, @Req() req: Request,
@Param('tokenId') tokenId: string, @Param('tokenId') tokenId: string,
@Body() body: any, @Body() body: any,
): Promise<any> { ): Promise<any> {
@ -210,7 +210,7 @@ export class AuthController {
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
@HttpCode(200) @HttpCode(200)
async emailVerification( async emailVerification(
@Request() req: any, @Req() req: Request,
@Param('tokenId') tokenId: string, @Param('tokenId') tokenId: string,
): Promise<any> { ): Promise<any> {
await this.usersService.emailVerification({ await this.usersService.emailVerification({
@ -227,7 +227,7 @@ export class AuthController {
]) ])
@UseGuards(PublicApiLimiterGuard) @UseGuards(PublicApiLimiterGuard)
async renderPasswordReset( async renderPasswordReset(
@Request() req: any, @Req() req: Request,
@Response() res: any, @Response() res: any,
@Param('tokenId') tokenId: string, @Param('tokenId') tokenId: string,
): Promise<any> { ): Promise<any> {

15
packages/nocodb/src/controllers/base-users.controller.ts

@ -7,9 +7,10 @@ import {
Param, Param,
Patch, Patch,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { ProjectUserReqType } from 'nocodb-sdk'; import { ProjectUserReqType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { BaseUsersService } from '~/services/base-users/base-users.service'; import { BaseUsersService } from '~/services/base-users/base-users.service';
@ -27,7 +28,7 @@ export class BaseUsersController {
'/api/v2/meta/bases/:baseId/users', '/api/v2/meta/bases/:baseId/users',
]) ])
@Acl('userList') @Acl('userList')
async userList(@Param('baseId') baseId: string, @Request() req) { async userList(@Param('baseId') baseId: string, @Req() req: Request) {
return { return {
users: await this.baseUsersService.userList({ users: await this.baseUsersService.userList({
baseId, baseId,
@ -44,7 +45,7 @@ export class BaseUsersController {
@Acl('userInvite') @Acl('userInvite')
async userInvite( async userInvite(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Request() req, @Req() req: Request,
@Body() body: ProjectUserReqType, @Body() body: ProjectUserReqType,
): Promise<any> { ): Promise<any> {
// todo: move this to a service // todo: move this to a service
@ -66,7 +67,7 @@ export class BaseUsersController {
async baseUserUpdate( async baseUserUpdate(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Param('userId') userId: string, @Param('userId') userId: string,
@Request() req, @Req() req: Request,
@Body() @Body()
body: ProjectUserReqType & { body: ProjectUserReqType & {
base_id: string; base_id: string;
@ -91,7 +92,7 @@ export class BaseUsersController {
async baseUserDelete( async baseUserDelete(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Param('userId') userId: string, @Param('userId') userId: string,
@Request() req, @Req() req: Request,
): Promise<any> { ): Promise<any> {
await this.baseUsersService.baseUserDelete({ await this.baseUsersService.baseUserDelete({
baseId, baseId,
@ -112,7 +113,7 @@ export class BaseUsersController {
async baseUserInviteResend( async baseUserInviteResend(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Param('userId') userId: string, @Param('userId') userId: string,
@Request() req, @Req() req: Request,
@Body() body: ProjectUserReqType, @Body() body: ProjectUserReqType,
): Promise<any> { ): Promise<any> {
await this.baseUsersService.baseUserInviteResend({ await this.baseUsersService.baseUserInviteResend({
@ -133,7 +134,7 @@ export class BaseUsersController {
@Acl('baseUserMetaUpdate') @Acl('baseUserMetaUpdate')
async baseUserMetaUpdate( async baseUserMetaUpdate(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Request() req, @Req() req: Request,
@Body() body: ProjectUserReqType, @Body() body: ProjectUserReqType,
): Promise<any> { ): Promise<any> {
return await this.baseUsersService.baseUserMetaUpdate({ return await this.baseUsersService.baseUserMetaUpdate({

11
packages/nocodb/src/controllers/bases.controller.ts

@ -8,9 +8,10 @@ import {
Patch, Patch,
Post, Post,
Query, Query,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import isDocker from 'is-docker'; import isDocker from 'is-docker';
import { ProjectReqType } from 'nocodb-sdk'; import { ProjectReqType } from 'nocodb-sdk';
import type { BaseType } from 'nocodb-sdk'; import type { BaseType } from 'nocodb-sdk';
@ -32,7 +33,7 @@ export class BasesController {
scope: 'org', scope: 'org',
}) })
@Get(['/api/v1/db/meta/projects/', '/api/v2/meta/bases/']) @Get(['/api/v1/db/meta/projects/', '/api/v2/meta/bases/'])
async list(@Query() queryParams: Record<string, any>, @Request() req) { async list(@Query() queryParams: Record<string, any>, @Req() req: Request) {
const bases = await this.projectsService.baseList({ const bases = await this.projectsService.baseList({
user: req.user, user: req.user,
query: queryParams, query: queryParams,
@ -76,7 +77,7 @@ export class BasesController {
async baseUpdate( async baseUpdate(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Body() body: Record<string, any>, @Body() body: Record<string, any>,
@Request() req, @Req() req: Request,
) { ) {
const base = await this.projectsService.baseUpdate({ const base = await this.projectsService.baseUpdate({
baseId, baseId,
@ -90,7 +91,7 @@ export class BasesController {
@Acl('baseDelete') @Acl('baseDelete')
@Delete(['/api/v1/db/meta/projects/:baseId', '/api/v2/meta/bases/:baseId']) @Delete(['/api/v1/db/meta/projects/:baseId', '/api/v2/meta/bases/:baseId'])
async baseDelete(@Param('baseId') baseId: string, @Request() req) { async baseDelete(@Param('baseId') baseId: string, @Req() req: Request) {
const deleted = await this.projectsService.baseSoftDelete({ const deleted = await this.projectsService.baseSoftDelete({
baseId, baseId,
user: req.user, user: req.user,
@ -105,7 +106,7 @@ export class BasesController {
}) })
@Post(['/api/v1/db/meta/projects', '/api/v2/meta/bases']) @Post(['/api/v1/db/meta/projects', '/api/v2/meta/bases'])
@HttpCode(200) @HttpCode(200)
async baseCreate(@Body() baseBody: ProjectReqType, @Request() req) { async baseCreate(@Body() baseBody: ProjectReqType, @Req() req: Request) {
const base = await this.projectsService.baseCreate({ const base = await this.projectsService.baseCreate({
base: baseBody, base: baseBody,
req, req,

17
packages/nocodb/src/controllers/bulk-data-alias.controller.ts

@ -6,10 +6,11 @@ import {
Param, Param,
Patch, Patch,
Post, Post,
Request, Req,
Response, Res,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request, Response } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { BulkDataAliasService } from '~/services/bulk-data-alias.service'; import { BulkDataAliasService } from '~/services/bulk-data-alias.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -24,8 +25,8 @@ export class BulkDataAliasController {
@HttpCode(200) @HttpCode(200)
@Acl('bulkDataInsert') @Acl('bulkDataInsert')
async bulkDataInsert( async bulkDataInsert(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Body() body: any, @Body() body: any,
@ -43,7 +44,7 @@ export class BulkDataAliasController {
@Patch(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName']) @Patch(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName'])
@Acl('bulkDataUpdate') @Acl('bulkDataUpdate')
async bulkDataUpdate( async bulkDataUpdate(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Body() body: any, @Body() body: any,
@ -60,7 +61,7 @@ export class BulkDataAliasController {
@Patch(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName/all']) @Patch(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName/all'])
@Acl('bulkDataUpdateAll') @Acl('bulkDataUpdateAll')
async bulkDataUpdateAll( async bulkDataUpdateAll(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Body() body: any, @Body() body: any,
@ -77,7 +78,7 @@ export class BulkDataAliasController {
@Delete(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName']) @Delete(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName'])
@Acl('bulkDataDelete') @Acl('bulkDataDelete')
async bulkDataDelete( async bulkDataDelete(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Body() body: any, @Body() body: any,
@ -95,7 +96,7 @@ export class BulkDataAliasController {
@Delete(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName/all']) @Delete(['/api/v1/db/data/bulk/:orgs/:baseName/:tableName/all'])
@Acl('bulkDataDeleteAll') @Acl('bulkDataDeleteAll')
async bulkDataDeleteAll( async bulkDataDeleteAll(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
) { ) {

11
packages/nocodb/src/controllers/columns.controller.ts

@ -7,9 +7,10 @@ import {
Param, Param,
Patch, Patch,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { ColumnReqType } from 'nocodb-sdk'; import { ColumnReqType } from 'nocodb-sdk';
import type { Column } from '~/models'; import type { Column } from '~/models';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
@ -31,7 +32,7 @@ export class ColumnsController {
async columnAdd( async columnAdd(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: ColumnReqType, @Body() body: ColumnReqType,
@Request() req: any, @Req() req: Request,
) { ) {
return await this.columnsService.columnAdd({ return await this.columnsService.columnAdd({
tableId, tableId,
@ -49,7 +50,7 @@ export class ColumnsController {
async columnUpdate( async columnUpdate(
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
@Body() body: ColumnReqType, @Body() body: ColumnReqType,
@Request() req: any, @Req() req: Request,
) { ) {
return await this.columnsService.columnUpdate({ return await this.columnsService.columnUpdate({
columnId: columnId, columnId: columnId,
@ -64,7 +65,7 @@ export class ColumnsController {
'/api/v2/meta/columns/:columnId', '/api/v2/meta/columns/:columnId',
]) ])
@Acl('columnDelete') @Acl('columnDelete')
async columnDelete(@Param('columnId') columnId: string, @Request() req: any) { async columnDelete(@Param('columnId') columnId: string, @Req() req: Request) {
return await this.columnsService.columnDelete({ return await this.columnsService.columnDelete({
columnId, columnId,
req, req,
@ -113,7 +114,7 @@ export class ColumnsController {
column: Partial<Column>; column: Partial<Column>;
}[]; }[];
}, },
@Request() req: any, @Req() req: Request,
) { ) {
return await this.columnsService.columnBulk(tableId, body, req); return await this.columnsService.columnBulk(tableId, body, req);
} }

7
packages/nocodb/src/controllers/data-alias-export.controller.ts

@ -1,4 +1,5 @@
import { Controller, Get, Request, Response, UseGuards } from '@nestjs/common'; import { Controller, Get, Req, Res, UseGuards } from '@nestjs/common';
import { Request, Response } from 'express';
import * as XLSX from 'xlsx'; import * as XLSX from 'xlsx';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { DatasService } from '~/services/datas.service'; import { DatasService } from '~/services/datas.service';
@ -17,7 +18,7 @@ export class DataAliasExportController {
'/api/v1/db/data/:orgs/:baseName/:tableName/views/:viewName/export/excel', '/api/v1/db/data/:orgs/:baseName/:tableName/views/:viewName/export/excel',
]) ])
@Acl('exportExcel') @Acl('exportExcel')
async excelDataExport(@Request() req, @Response() res) { async excelDataExport(@Req() req: Request, @Res() res: Response) {
const { model, view } = const { model, view } =
await this.datasService.getViewAndModelFromRequestByAliasOrId(req); await this.datasService.getViewAndModelFromRequestByAliasOrId(req);
let targetView = view; let targetView = view;
@ -44,7 +45,7 @@ export class DataAliasExportController {
'/api/v1/db/data/:orgs/:baseName/:tableName/export/csv', '/api/v1/db/data/:orgs/:baseName/:tableName/export/csv',
]) ])
@Acl('exportCsv') @Acl('exportCsv')
async csvDataExport(@Request() req, @Response() res) { async csvDataExport(@Req() req: Request, @Res() res: Response) {
const { model, view } = const { model, view } =
await this.datasService.getViewAndModelFromRequestByAliasOrId(req); await this.datasService.getViewAndModelFromRequestByAliasOrId(req);
let targetView = view; let targetView = view;

17
packages/nocodb/src/controllers/data-alias-nested.controller.ts

@ -5,9 +5,10 @@ import {
HttpCode, HttpCode,
Param, Param,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { DataAliasNestedService } from '~/services/data-alias-nested.service'; import { DataAliasNestedService } from '~/services/data-alias-nested.service';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -22,7 +23,7 @@ export class DataAliasNestedController {
@Get(['/api/v1/db/data/:orgs/:baseName/:tableName/:rowId/mm/:columnName']) @Get(['/api/v1/db/data/:orgs/:baseName/:tableName/:rowId/mm/:columnName'])
@Acl('mmList') @Acl('mmList')
async mmList( async mmList(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@ -42,7 +43,7 @@ export class DataAliasNestedController {
]) ])
@Acl('mmExcludedList') @Acl('mmExcludedList')
async mmExcludedList( async mmExcludedList(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@ -62,7 +63,7 @@ export class DataAliasNestedController {
]) ])
@Acl('hmExcludedList') @Acl('hmExcludedList')
async hmExcludedList( async hmExcludedList(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@ -82,7 +83,7 @@ export class DataAliasNestedController {
]) ])
@Acl('btExcludedList') @Acl('btExcludedList')
async btExcludedList( async btExcludedList(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@ -102,7 +103,7 @@ export class DataAliasNestedController {
@Get(['/api/v1/db/data/:orgs/:baseName/:tableName/:rowId/hm/:columnName']) @Get(['/api/v1/db/data/:orgs/:baseName/:tableName/:rowId/hm/:columnName'])
@Acl('hmList') @Acl('hmList')
async hmList( async hmList(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@ -122,7 +123,7 @@ export class DataAliasNestedController {
]) ])
@Acl('relationDataRemove') @Acl('relationDataRemove')
async relationDataRemove( async relationDataRemove(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@ -148,7 +149,7 @@ export class DataAliasNestedController {
@Acl('relationDataAdd') @Acl('relationDataAdd')
@HttpCode(200) @HttpCode(200)
async relationDataAdd( async relationDataAdd(
@Request() req, @Req() req: Request,
@Param('columnName') columnName: string, @Param('columnName') columnName: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,

33
packages/nocodb/src/controllers/data-alias.controller.ts

@ -8,10 +8,11 @@ import {
Patch, Patch,
Post, Post,
Query, Query,
Request, Req,
Response, Res,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request, Response } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { parseHrtimeToMilliSeconds } from '~/helpers'; import { parseHrtimeToMilliSeconds } from '~/helpers';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -30,8 +31,8 @@ export class DataAliasController {
]) ])
@Acl('dataList') @Acl('dataList')
async dataList( async dataList(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -62,7 +63,7 @@ export class DataAliasController {
]) ])
@Acl('dataFindOne') @Acl('dataFindOne')
async dataFindOne( async dataFindOne(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -81,7 +82,7 @@ export class DataAliasController {
]) ])
@Acl('dataGroupBy') @Acl('dataGroupBy')
async dataGroupBy( async dataGroupBy(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -100,8 +101,8 @@ export class DataAliasController {
]) ])
@Acl('dataCount') @Acl('dataCount')
async dataCount( async dataCount(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -123,7 +124,7 @@ export class DataAliasController {
@HttpCode(200) @HttpCode(200)
@Acl('dataInsert') @Acl('dataInsert')
async dataInsert( async dataInsert(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -146,7 +147,7 @@ export class DataAliasController {
]) ])
@Acl('dataUpdate') @Acl('dataUpdate')
async dataUpdate( async dataUpdate(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -170,7 +171,7 @@ export class DataAliasController {
]) ])
@Acl('dataDelete') @Acl('dataDelete')
async dataDelete( async dataDelete(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -191,7 +192,7 @@ export class DataAliasController {
]) ])
@Acl('dataRead') @Acl('dataRead')
async dataRead( async dataRead(
@Request() req, @Req() req: Request,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -216,8 +217,8 @@ export class DataAliasController {
]) ])
@Acl('dataExist') @Acl('dataExist')
async dataExist( async dataExist(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,
@ -242,8 +243,8 @@ export class DataAliasController {
]) ])
@Acl('groupedDataList') @Acl('groupedDataList')
async groupedDataList( async groupedDataList(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('baseName') baseName: string, @Param('baseName') baseName: string,
@Param('tableName') tableName: string, @Param('tableName') tableName: string,
@Param('viewName') viewName: string, @Param('viewName') viewName: string,

27
packages/nocodb/src/controllers/data-table.controller.ts

@ -8,10 +8,11 @@ import {
Patch, Patch,
Post, Post,
Query, Query,
Request, Req,
Response, Res,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request, Response } from 'express';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { DataTableService } from '~/services/data-table.service'; import { DataTableService } from '~/services/data-table.service';
import { parseHrtimeToMilliSeconds } from '~/helpers'; import { parseHrtimeToMilliSeconds } from '~/helpers';
@ -27,8 +28,8 @@ export class DataTableController {
@Get('/api/v2/tables/:modelId/records') @Get('/api/v2/tables/:modelId/records')
@Acl('dataList') @Acl('dataList')
async dataList( async dataList(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
) { ) {
@ -46,8 +47,8 @@ export class DataTableController {
@Get(['/api/v2/tables/:modelId/records/count']) @Get(['/api/v2/tables/:modelId/records/count'])
@Acl('dataCount') @Acl('dataCount')
async dataCount( async dataCount(
@Request() req, @Req() req: Request,
@Response() res, @Res() res: Response,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
) { ) {
@ -64,7 +65,7 @@ export class DataTableController {
@HttpCode(200) @HttpCode(200)
@Acl('dataInsert') @Acl('dataInsert')
async dataInsert( async dataInsert(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Body() body: any, @Body() body: any,
@ -80,7 +81,7 @@ export class DataTableController {
@Patch(['/api/v2/tables/:modelId/records']) @Patch(['/api/v2/tables/:modelId/records'])
@Acl('dataUpdate') @Acl('dataUpdate')
async dataUpdate( async dataUpdate(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Param('rowId') _rowId: string, @Param('rowId') _rowId: string,
@ -96,7 +97,7 @@ export class DataTableController {
@Delete(['/api/v2/tables/:modelId/records']) @Delete(['/api/v2/tables/:modelId/records'])
@Acl('dataDelete') @Acl('dataDelete')
async dataDelete( async dataDelete(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Param('rowId') _rowId: string, @Param('rowId') _rowId: string,
@ -112,7 +113,7 @@ export class DataTableController {
@Get(['/api/v2/tables/:modelId/records/:rowId']) @Get(['/api/v2/tables/:modelId/records/:rowId'])
@Acl('dataRead') @Acl('dataRead')
async dataRead( async dataRead(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@ -128,7 +129,7 @@ export class DataTableController {
@Get(['/api/v2/tables/:modelId/links/:columnId/records/:rowId']) @Get(['/api/v2/tables/:modelId/links/:columnId/records/:rowId'])
@Acl('nestedDataList') @Acl('nestedDataList')
async nestedDataList( async nestedDataList(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
@ -146,7 +147,7 @@ export class DataTableController {
@Post(['/api/v2/tables/:modelId/links/:columnId/records/:rowId']) @Post(['/api/v2/tables/:modelId/links/:columnId/records/:rowId'])
@Acl('nestedDataLink') @Acl('nestedDataLink')
async nestedLink( async nestedLink(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
@ -168,7 +169,7 @@ export class DataTableController {
@Delete(['/api/v2/tables/:modelId/links/:columnId/records/:rowId']) @Delete(['/api/v2/tables/:modelId/links/:columnId/records/:rowId'])
@Acl('nestedDataUnlink') @Acl('nestedDataUnlink')
async nestedUnlink( async nestedUnlink(
@Request() req, @Req() req: Request,
@Param('modelId') modelId: string, @Param('modelId') modelId: string,
@Query('viewId') viewId: string, @Query('viewId') viewId: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,

27
packages/nocodb/src/controllers/datas.controller.ts

@ -7,9 +7,10 @@ import {
Param, Param,
Patch, Patch,
Post, Post,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { DatasService } from '~/services/datas.service'; import { DatasService } from '~/services/datas.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -22,7 +23,7 @@ export class DatasController {
@Get('/data/:viewId/') @Get('/data/:viewId/')
@Acl('dataList') @Acl('dataList')
async dataList(@Request() req, @Param('viewId') viewId: string) { async dataList(@Req() req: Request, @Param('viewId') viewId: string) {
return await this.datasService.dataListByViewId({ return await this.datasService.dataListByViewId({
viewId: viewId, viewId: viewId,
query: req.query, query: req.query,
@ -32,7 +33,7 @@ export class DatasController {
@Get('/data/:viewId/:rowId/mm/:colId') @Get('/data/:viewId/:rowId/mm/:colId')
@Acl('mmList') @Acl('mmList')
async mmList( async mmList(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('colId') colId: string, @Param('colId') colId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@ -48,7 +49,7 @@ export class DatasController {
@Get('/data/:viewId/:rowId/mm/:colId/exclude') @Get('/data/:viewId/:rowId/mm/:colId/exclude')
@Acl('mmExcludedList') @Acl('mmExcludedList')
async mmExcludedList( async mmExcludedList(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('colId') colId: string, @Param('colId') colId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@ -64,7 +65,7 @@ export class DatasController {
@Get('/data/:viewId/:rowId/hm/:colId/exclude') @Get('/data/:viewId/:rowId/hm/:colId/exclude')
@Acl('hmExcludedList') @Acl('hmExcludedList')
async hmExcludedList( async hmExcludedList(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('colId') colId: string, @Param('colId') colId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@ -80,7 +81,7 @@ export class DatasController {
@Get('/data/:viewId/:rowId/bt/:colId/exclude') @Get('/data/:viewId/:rowId/bt/:colId/exclude')
@Acl('btExcludedList') @Acl('btExcludedList')
async btExcludedList( async btExcludedList(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('colId') colId: string, @Param('colId') colId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@ -96,7 +97,7 @@ export class DatasController {
@Get('/data/:viewId/:rowId/hm/:colId') @Get('/data/:viewId/:rowId/hm/:colId')
@Acl('hmList') @Acl('hmList')
async hmList( async hmList(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('colId') colId: string, @Param('colId') colId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@ -112,7 +113,7 @@ export class DatasController {
@Get('/data/:viewId/:rowId') @Get('/data/:viewId/:rowId')
@Acl('dataRead') @Acl('dataRead')
async dataRead( async dataRead(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
) { ) {
@ -127,7 +128,7 @@ export class DatasController {
@HttpCode(200) @HttpCode(200)
@Acl('dataInsert') @Acl('dataInsert')
async dataInsert( async dataInsert(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: any, @Body() body: any,
) { ) {
@ -141,7 +142,7 @@ export class DatasController {
@Patch('/data/:viewId/:rowId') @Patch('/data/:viewId/:rowId')
@Acl('dataUpdate') @Acl('dataUpdate')
async dataUpdate( async dataUpdate(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Body() body: any, @Body() body: any,
@ -157,7 +158,7 @@ export class DatasController {
@Delete('/data/:viewId/:rowId') @Delete('/data/:viewId/:rowId')
@Acl('dataDelete') @Acl('dataDelete')
async dataDelete( async dataDelete(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
) { ) {
@ -171,7 +172,7 @@ export class DatasController {
@Delete('/data/:viewId/:rowId/:relationType/:colId/:childId') @Delete('/data/:viewId/:rowId/:relationType/:colId/:childId')
@Acl('relationDataDelete') @Acl('relationDataDelete')
async relationDataDelete( async relationDataDelete(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('relationType') relationType: string, @Param('relationType') relationType: string,
@ -193,7 +194,7 @@ export class DatasController {
@HttpCode(200) @HttpCode(200)
@Acl('relationDataAdd') @Acl('relationDataAdd')
async relationDataAdd( async relationDataAdd(
@Request() req, @Req() req: Request,
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('relationType') relationType: string, @Param('relationType') relationType: string,

9
packages/nocodb/src/controllers/filters.controller.ts

@ -10,6 +10,7 @@ import {
Req, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { FilterReqType } from 'nocodb-sdk'; import { FilterReqType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
@ -44,7 +45,7 @@ export class FiltersController {
async filterCreate( async filterCreate(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: FilterReqType, @Body() body: FilterReqType,
@Req() req, @Req() req: Request,
) { ) {
const filter = await this.filtersService.filterCreate({ const filter = await this.filtersService.filterCreate({
filter: body, filter: body,
@ -64,7 +65,7 @@ export class FiltersController {
async hookFilterCreate( async hookFilterCreate(
@Param('hookId') hookId: string, @Param('hookId') hookId: string,
@Body() body: FilterReqType, @Body() body: FilterReqType,
@Req() req, @Req() req: Request,
) { ) {
const filter = await this.filtersService.hookFilterCreate({ const filter = await this.filtersService.hookFilterCreate({
filter: body, filter: body,
@ -102,7 +103,7 @@ export class FiltersController {
async filterUpdate( async filterUpdate(
@Param('filterId') filterId: string, @Param('filterId') filterId: string,
@Body() body: FilterReqType, @Body() body: FilterReqType,
@Req() req, @Req() req: Request,
) { ) {
const filter = await this.filtersService.filterUpdate({ const filter = await this.filtersService.filterUpdate({
filterId: filterId, filterId: filterId,
@ -118,7 +119,7 @@ export class FiltersController {
'/api/v2/meta/filters/:filterId', '/api/v2/meta/filters/:filterId',
]) ])
@Acl('filterDelete') @Acl('filterDelete')
async filterDelete(@Param('filterId') filterId: string, @Req() req) { async filterDelete(@Param('filterId') filterId: string, @Req() req: Request) {
const filter = await this.filtersService.filterDelete({ const filter = await this.filtersService.filterDelete({
req, req,
filterId, filterId,

5
packages/nocodb/src/controllers/form-columns.controller.ts

@ -3,9 +3,10 @@ import {
Controller, Controller,
Param, Param,
Patch, Patch,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { FormColumnsService } from '~/services/form-columns.service'; import { FormColumnsService } from '~/services/form-columns.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
@ -27,7 +28,7 @@ export class FormColumnsController {
@Param('formViewColumnId') formViewColumnId: string, @Param('formViewColumnId') formViewColumnId: string,
@Body() formViewColumnbody: FormColumnUpdateReqType, @Body() formViewColumnbody: FormColumnUpdateReqType,
@Request() req: any, @Req() req: Request,
) { ) {
return await this.formColumnsService.columnUpdate({ return await this.formColumnsService.columnUpdate({
formViewColumnId, formViewColumnId,

4
packages/nocodb/src/controllers/forms.controller.ts

@ -39,7 +39,7 @@ export class FormsController {
async formViewCreate( async formViewCreate(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: ViewCreateReqType, @Body() body: ViewCreateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
const view = await this.formsService.formViewCreate({ const view = await this.formsService.formViewCreate({
body, body,
@ -57,7 +57,7 @@ export class FormsController {
async formViewUpdate( async formViewUpdate(
@Param('formViewId') formViewId: string, @Param('formViewId') formViewId: string,
@Body() body, @Body() body,
@Request() req: any, @Req() req: Request,
) { ) {
return await this.formsService.formViewUpdate({ return await this.formsService.formViewUpdate({
formViewId, formViewId,

4
packages/nocodb/src/controllers/galleries.controller.ts

@ -40,7 +40,7 @@ export class GalleriesController {
async galleryViewCreate( async galleryViewCreate(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: ViewCreateReqType, @Body() body: ViewCreateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.galleriesService.galleryViewCreate({ return await this.galleriesService.galleryViewCreate({
gallery: body, gallery: body,
@ -60,7 +60,7 @@ export class GalleriesController {
@Param('galleryViewId') galleryViewId: string, @Param('galleryViewId') galleryViewId: string,
@Body() body: GalleryUpdateReqType, @Body() body: GalleryUpdateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.galleriesService.galleryViewUpdate({ return await this.galleriesService.galleryViewUpdate({
galleryViewId, galleryViewId,

2
packages/nocodb/src/controllers/grid-columns.controller.ts

@ -37,7 +37,7 @@ export class GridColumnsController {
@Param('gridViewColumnId') gridViewColumnId: string, @Param('gridViewColumnId') gridViewColumnId: string,
@Body() body: GridColumnReqType, @Body() body: GridColumnReqType,
@Req() req: any, @Req() req: Request,
) { ) {
return this.gridColumnsService.gridColumnUpdate({ return this.gridColumnsService.gridColumnUpdate({
gridViewColumnId, gridViewColumnId,

4
packages/nocodb/src/controllers/grids.controller.ts

@ -28,7 +28,7 @@ export class GridsController {
async gridViewCreate( async gridViewCreate(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: ViewCreateReqType, @Body() body: ViewCreateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
const view = await this.gridsService.gridViewCreate({ const view = await this.gridsService.gridViewCreate({
grid: body, grid: body,
@ -42,7 +42,7 @@ export class GridsController {
async gridViewUpdate( async gridViewUpdate(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body, @Body() body,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.gridsService.gridViewUpdate({ return await this.gridsService.gridViewUpdate({
viewId, viewId,

10
packages/nocodb/src/controllers/hooks.controller.ts

@ -41,7 +41,7 @@ export class HooksController {
async hookCreate( async hookCreate(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: HookReqType, @Body() body: HookReqType,
@Request() req: any, @Req() req: Request,
) { ) {
const hook = await this.hooksService.hookCreate({ const hook = await this.hooksService.hookCreate({
hook: body, hook: body,
@ -53,7 +53,7 @@ export class HooksController {
@Delete(['/api/v1/db/meta/hooks/:hookId', '/api/v2/meta/hooks/:hookId']) @Delete(['/api/v1/db/meta/hooks/:hookId', '/api/v2/meta/hooks/:hookId'])
@Acl('hookDelete') @Acl('hookDelete')
async hookDelete(@Param('hookId') hookId: string, @Request() req: any) { async hookDelete(@Param('hookId') hookId: string, @Req() req: Request) {
return await this.hooksService.hookDelete({ hookId, req }); return await this.hooksService.hookDelete({ hookId, req });
} }
@ -62,7 +62,7 @@ export class HooksController {
async hookUpdate( async hookUpdate(
@Param('hookId') hookId: string, @Param('hookId') hookId: string,
@Body() body: HookReqType, @Body() body: HookReqType,
@Request() req: any, @Req() req: Request,
) { ) {
return await this.hooksService.hookUpdate({ hookId, hook: body, req }); return await this.hooksService.hookUpdate({ hookId, hook: body, req });
} }
@ -73,7 +73,7 @@ export class HooksController {
]) ])
@HttpCode(200) @HttpCode(200)
@Acl('hookTest') @Acl('hookTest')
async hookTest(@Body() body: HookTestReqType, @Request() req: any) { async hookTest(@Body() body: HookTestReqType, @Req() req: Request) {
try { try {
await this.hooksService.hookTest({ await this.hooksService.hookTest({
hookTest: { hookTest: {
@ -115,7 +115,7 @@ export class HooksController {
'/api/v2/meta/hooks/:hookId/logs', '/api/v2/meta/hooks/:hookId/logs',
]) ])
@Acl('hookLogList') @Acl('hookLogList')
async hookLogList(@Param('hookId') hookId: string, @Request() req: any) { async hookLogList(@Param('hookId') hookId: string, @Req() req: Request) {
return new PagedResponseImpl( return new PagedResponseImpl(
await this.hooksService.hookLogList({ await this.hooksService.hookLogList({
query: req.query, query: req.query,

4
packages/nocodb/src/controllers/kanbans.controller.ts

@ -40,7 +40,7 @@ export class KanbansController {
async kanbanViewCreate( async kanbanViewCreate(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: ViewCreateReqType, @Body() body: ViewCreateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.kanbansService.kanbanViewCreate({ return await this.kanbansService.kanbanViewCreate({
tableId, tableId,
@ -59,7 +59,7 @@ export class KanbansController {
@Param('kanbanViewId') kanbanViewId: string, @Param('kanbanViewId') kanbanViewId: string,
@Body() body, @Body() body,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.kanbansService.kanbanViewUpdate({ return await this.kanbansService.kanbanViewUpdate({
kanbanViewId, kanbanViewId,

4
packages/nocodb/src/controllers/maps.controller.ts

@ -35,7 +35,7 @@ export class MapsController {
async mapViewCreate( async mapViewCreate(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: ViewCreateReqType, @Body() body: ViewCreateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
const view = await this.mapsService.mapViewCreate({ const view = await this.mapsService.mapViewCreate({
tableId, tableId,
@ -52,7 +52,7 @@ export class MapsController {
@Param('mapViewId') mapViewId: string, @Param('mapViewId') mapViewId: string,
@Body() body: MapUpdateReqType, @Body() body: MapUpdateReqType,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.mapsService.mapViewUpdate({ return await this.mapsService.mapViewUpdate({
mapViewId: mapViewId, mapViewId: mapViewId,

2
packages/nocodb/src/controllers/model-visibilities.controller.ts

@ -30,7 +30,7 @@ export class ModelVisibilitiesController {
async xcVisibilityMetaSetAll( async xcVisibilityMetaSetAll(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Body() body: any, @Body() body: any,
@Req() req: any, @Req() req: Request,
) { ) {
await this.modelVisibilitiesService.xcVisibilityMetaSetAll({ await this.modelVisibilitiesService.xcVisibilityMetaSetAll({
visibilityRule: body, visibilityRule: body,

2
packages/nocodb/src/controllers/notifications.controller.ts

@ -22,7 +22,7 @@ export class NotificationsController {
@Get('/api/v1/notifications') @Get('/api/v1/notifications')
// @Acl('notificationList') // @Acl('notificationList')
async notificationList(@Request() req) { async notificationList(@Req() req: Request) {
return this.notificationsService.notificationList({ return this.notificationsService.notificationList({
user: req.user, user: req.user,
is_deleted: false, is_deleted: false,

2
packages/nocodb/src/controllers/org-tokens.controller.ts

@ -30,7 +30,7 @@ export class OrgTokensController {
scope: 'org', scope: 'org',
blockApiTokenAccess: true, blockApiTokenAccess: true,
}) })
async apiTokenList(@Request() req) { async apiTokenList(@Req() req: Request) {
return await getConditionalHandler( return await getConditionalHandler(
this.orgTokensService.apiTokenList, this.orgTokensService.apiTokenList,
this.orgTokensEeService.apiTokenListEE, this.orgTokensEeService.apiTokenListEE,

2
packages/nocodb/src/controllers/org-users.controller.ts

@ -29,7 +29,7 @@ export class OrgUsersController {
allowedRoles: [OrgUserRoles.SUPER_ADMIN], allowedRoles: [OrgUserRoles.SUPER_ADMIN],
blockApiTokenAccess: true, blockApiTokenAccess: true,
}) })
async userList(@Request() req) { async userList(@Req() req: Request) {
return new PagedResponseImpl( return new PagedResponseImpl(
await this.orgUsersService.userList({ await this.orgUsersService.userList({
query: req.query, query: req.query,

4
packages/nocodb/src/controllers/plugins.controller.ts

@ -48,7 +48,7 @@ export class PluginsController {
@Acl('pluginTest', { @Acl('pluginTest', {
scope: 'org', scope: 'org',
}) })
async pluginTest(@Body() body: any, @Req() req: any) { async pluginTest(@Body() body: any, @Req() req: Request) {
return await this.pluginsService.pluginTest({ body: body, req }); return await this.pluginsService.pluginTest({ body: body, req });
} }
@ -70,7 +70,7 @@ export class PluginsController {
async pluginUpdate( async pluginUpdate(
@Body() body: any, @Body() body: any,
@Param('pluginId') pluginId: string, @Param('pluginId') pluginId: string,
@Req() req: any, @Req() req: Request,
) { ) {
const plugin = await this.pluginsService.pluginUpdate({ const plugin = await this.pluginsService.pluginUpdate({
pluginId: pluginId, pluginId: pluginId,

19
packages/nocodb/src/controllers/public-datas.controller.ts

@ -4,10 +4,11 @@ import {
HttpCode, HttpCode,
Param, Param,
Post, Post,
Request, Req,
UseGuards, UseGuards,
UseInterceptors, UseInterceptors,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { AnyFilesInterceptor } from '@nestjs/platform-express'; import { AnyFilesInterceptor } from '@nestjs/platform-express';
import { PublicDatasService } from '~/services/public-datas.service'; import { PublicDatasService } from '~/services/public-datas.service';
import { PublicApiLimiterGuard } from '~/guards/public-api-limiter.guard'; import { PublicApiLimiterGuard } from '~/guards/public-api-limiter.guard';
@ -22,7 +23,7 @@ export class PublicDatasController {
'/api/v2/public/shared-view/:sharedViewUuid/rows', '/api/v2/public/shared-view/:sharedViewUuid/rows',
]) ])
async dataList( async dataList(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
) { ) {
const pagedResponse = await this.publicDatasService.dataList({ const pagedResponse = await this.publicDatasService.dataList({
@ -38,7 +39,7 @@ export class PublicDatasController {
'/api/v2/public/shared-view/:sharedViewUuid/groupby', '/api/v2/public/shared-view/:sharedViewUuid/groupby',
]) ])
async dataGroupBy( async dataGroupBy(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
) { ) {
return await this.publicDatasService.dataGroupBy({ return await this.publicDatasService.dataGroupBy({
@ -53,7 +54,7 @@ export class PublicDatasController {
'/api/v2/public/shared-view/:sharedViewUuid/group/:columnId', '/api/v2/public/shared-view/:sharedViewUuid/group/:columnId',
]) ])
async groupedDataList( async groupedDataList(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
) { ) {
@ -73,7 +74,7 @@ export class PublicDatasController {
@HttpCode(200) @HttpCode(200)
@UseInterceptors(AnyFilesInterceptor()) @UseInterceptors(AnyFilesInterceptor())
async dataInsert( async dataInsert(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
) { ) {
const insertResult = await this.publicDatasService.dataInsert({ const insertResult = await this.publicDatasService.dataInsert({
@ -81,7 +82,7 @@ export class PublicDatasController {
password: req.headers?.['xc-password'] as string, password: req.headers?.['xc-password'] as string,
body: req.body?.data, body: req.body?.data,
siteUrl: (req as any).ncSiteUrl, siteUrl: (req as any).ncSiteUrl,
files: req.files, files: req.files as any[],
}); });
return insertResult; return insertResult;
@ -92,7 +93,7 @@ export class PublicDatasController {
'/api/v2/public/shared-view/:sharedViewUuid/nested/:columnId', '/api/v2/public/shared-view/:sharedViewUuid/nested/:columnId',
]) ])
async relDataList( async relDataList(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
) { ) {
@ -111,7 +112,7 @@ export class PublicDatasController {
'/api/v2/public/shared-view/:sharedViewUuid/rows/:rowId/mm/:columnId', '/api/v2/public/shared-view/:sharedViewUuid/rows/:rowId/mm/:columnId',
]) ])
async publicMmList( async publicMmList(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
@ -131,7 +132,7 @@ export class PublicDatasController {
'/api/v2/public/shared-view/:sharedViewUuid/rows/:rowId/hm/:columnId', '/api/v2/public/shared-view/:sharedViewUuid/rows/:rowId/hm/:columnId',
]) ])
async publicHmList( async publicHmList(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
@Param('rowId') rowId: string, @Param('rowId') rowId: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,

2
packages/nocodb/src/controllers/public-metas.controller.ts

@ -12,7 +12,7 @@ export class PublicMetasController {
'/api/v2/public/shared-view/:sharedViewUuid/meta', '/api/v2/public/shared-view/:sharedViewUuid/meta',
]) ])
async viewMetaGet( async viewMetaGet(
@Request() req, @Req() req: Request,
@Param('sharedViewUuid') sharedViewUuid: string, @Param('sharedViewUuid') sharedViewUuid: string,
) { ) {
return await this.publicMetasService.viewMetaGet({ return await this.publicMetasService.viewMetaGet({

2
packages/nocodb/src/controllers/shared-bases.controller.ts

@ -70,7 +70,7 @@ export class SharedBasesController {
@Acl('disableSharedBaseLink') @Acl('disableSharedBaseLink')
async disableSharedBaseLink( async disableSharedBaseLink(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Request() req: any, @Req() req: Request,
): Promise<any> { ): Promise<any> {
const sharedBase = await this.sharedBasesService.disableSharedBaseLink({ const sharedBase = await this.sharedBasesService.disableSharedBaseLink({
baseId, baseId,

6
packages/nocodb/src/controllers/sorts.controller.ts

@ -44,7 +44,7 @@ export class SortsController {
async sortCreate( async sortCreate(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: SortReqType, @Body() body: SortReqType,
@Req() req, @Req() req: Request,
) { ) {
const sort = await this.sortsService.sortCreate({ const sort = await this.sortsService.sortCreate({
sort: body, sort: body,
@ -68,7 +68,7 @@ export class SortsController {
async sortUpdate( async sortUpdate(
@Param('sortId') sortId: string, @Param('sortId') sortId: string,
@Body() body: SortReqType, @Body() body: SortReqType,
@Req() req, @Req() req: Request,
) { ) {
const sort = await this.sortsService.sortUpdate({ const sort = await this.sortsService.sortUpdate({
sortId, sortId,
@ -80,7 +80,7 @@ export class SortsController {
@Delete(['/api/v1/db/meta/sorts/:sortId', '/api/v2/meta/sorts/:sortId']) @Delete(['/api/v1/db/meta/sorts/:sortId', '/api/v2/meta/sorts/:sortId'])
@Acl('sortDelete') @Acl('sortDelete')
async sortDelete(@Param('sortId') sortId: string, @Req() req) { async sortDelete(@Param('sortId') sortId: string, @Req() req: Request) {
const sort = await this.sortsService.sortDelete({ const sort = await this.sortsService.sortDelete({
sortId, sortId,
req, req,

5
packages/nocodb/src/controllers/sources.controller.ts

@ -4,9 +4,10 @@ import {
Get, Get,
Param, Param,
Patch, Patch,
Request, Req,
UseGuards, UseGuards,
} from '@nestjs/common'; } from '@nestjs/common';
import { Request } from 'express';
import { BaseReqType } from 'nocodb-sdk'; import { BaseReqType } from 'nocodb-sdk';
import { GlobalGuard } from '~/guards/global/global.guard'; import { GlobalGuard } from '~/guards/global/global.guard';
import { PagedResponseImpl } from '~/helpers/PagedResponse'; import { PagedResponseImpl } from '~/helpers/PagedResponse';
@ -45,7 +46,7 @@ export class SourcesController {
@Param('sourceId') sourceId: string, @Param('sourceId') sourceId: string,
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Body() body: BaseReqType, @Body() body: BaseReqType,
@Request() req: any, @Req() req: Request,
) { ) {
const source = await this.sourcesService.baseUpdate({ const source = await this.sourcesService.baseUpdate({
sourceId, sourceId,

6
packages/nocodb/src/controllers/sync.controller.ts

@ -48,7 +48,7 @@ export class SyncController {
async syncCreate( async syncCreate(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Body() body: any, @Body() body: any,
@Req() req, @Req() req: Request,
@Param('sourceId') sourceId?: string, @Param('sourceId') sourceId?: string,
) { ) {
return await this.syncService.syncCreate({ return await this.syncService.syncCreate({
@ -62,7 +62,7 @@ export class SyncController {
@Delete(['/api/v1/db/meta/syncs/:syncId', '/api/v2/meta/syncs/:syncId']) @Delete(['/api/v1/db/meta/syncs/:syncId', '/api/v2/meta/syncs/:syncId'])
@Acl('syncSourceDelete') @Acl('syncSourceDelete')
async syncDelete(@Param('syncId') syncId: string, @Req() req: any) { async syncDelete(@Param('syncId') syncId: string, @Req() req: Request) {
return await this.syncService.syncDelete({ return await this.syncService.syncDelete({
syncId: syncId, syncId: syncId,
req, req,
@ -74,7 +74,7 @@ export class SyncController {
async syncUpdate( async syncUpdate(
@Param('syncId') syncId: string, @Param('syncId') syncId: string,
@Body() body: any, @Body() body: any,
@Req() req: any, @Req() req: Request,
) { ) {
return await this.syncService.syncUpdate({ return await this.syncService.syncUpdate({
syncId: syncId, syncId: syncId,

2
packages/nocodb/src/controllers/utils.controller.ts

@ -63,7 +63,7 @@ export class UtilsController {
'/api/v2/meta/nocodb/info', '/api/v2/meta/nocodb/info',
'/api/v1/meta/nocodb/info', '/api/v1/meta/nocodb/info',
]) ])
async appInfo(@Request() req) { async appInfo(@Req() req: Request) {
return await this.utilsService.appInfo({ return await this.utilsService.appInfo({
req: { req: {
ncSiteUrl: (req as any).ncSiteUrl, ncSiteUrl: (req as any).ncSiteUrl,

4
packages/nocodb/src/controllers/view-columns.controller.ts

@ -43,7 +43,7 @@ export class ViewColumnsController {
async columnAdd( async columnAdd(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: ViewColumnReqType, @Body() body: ViewColumnReqType,
@Req() req: any, @Req() req: Request,
) { ) {
const viewColumn = await this.viewColumnsService.columnAdd({ const viewColumn = await this.viewColumnsService.columnAdd({
viewId, viewId,
@ -62,7 +62,7 @@ export class ViewColumnsController {
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Param('columnId') columnId: string, @Param('columnId') columnId: string,
@Body() body: ViewColumnReqType, @Body() body: ViewColumnReqType,
@Req() req: any, @Req() req: Request,
) { ) {
const result = await this.viewColumnsService.columnUpdate({ const result = await this.viewColumnsService.columnUpdate({
viewId, viewId,

6
packages/nocodb/src/controllers/views.controller.ts

@ -28,7 +28,7 @@ export class ViewsController {
'/api/v2/meta/tables/:tableId/views', '/api/v2/meta/tables/:tableId/views',
]) ])
@Acl('viewList') @Acl('viewList')
async viewList(@Param('tableId') tableId: string, @Request() req) { async viewList(@Param('tableId') tableId: string, @Req() req: Request) {
return new PagedResponseImpl( return new PagedResponseImpl(
await this.viewsService.viewList({ await this.viewsService.viewList({
tableId, tableId,
@ -42,7 +42,7 @@ export class ViewsController {
async viewUpdate( async viewUpdate(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: ViewUpdateReqType, @Body() body: ViewUpdateReqType,
@Request() req, @Req() req: Request,
) { ) {
const result = await this.viewsService.viewUpdate({ const result = await this.viewsService.viewUpdate({
viewId, viewId,
@ -55,7 +55,7 @@ export class ViewsController {
@Delete(['/api/v1/db/meta/views/:viewId', '/api/v2/meta/views/:viewId']) @Delete(['/api/v1/db/meta/views/:viewId', '/api/v2/meta/views/:viewId'])
@Acl('viewDelete') @Acl('viewDelete')
async viewDelete(@Param('viewId') viewId: string, @Request() req) { async viewDelete(@Param('viewId') viewId: string, @Req() req: Request) {
const result = await this.viewsService.viewDelete({ const result = await this.viewsService.viewDelete({
viewId, viewId,
user: req.user, user: req.user,

9
packages/nocodb/src/interface/config.ts

@ -1,3 +1,4 @@
import type { ReqId } from 'pino-http';
import type { Handler } from 'express'; import type { Handler } from 'express';
import type * as e from 'express'; import type * as e from 'express';
import type { Knex } from 'knex'; import type { Knex } from 'knex';
@ -319,3 +320,11 @@ export interface AppConfig {
mainSubDomain: string; mainSubDomain: string;
dashboardPath: string; dashboardPath: string;
} }
export interface NcRequest {
id?: ReqId;
user?: Record<string, any>;
ncWorkspaceId?: string;
ncProjectId?: string;
headers?: Record<string, string | undefined> | IncomingHttpHeaders;
}

2
packages/nocodb/src/modules/jobs/jobs.controller.ts

@ -47,7 +47,7 @@ export class JobsController implements OnModuleInit {
@HttpCode(200) @HttpCode(200)
async listen( async listen(
@Response() res, @Response() res,
@Request() req, @Req() req: Request,
@Body() body: { _mid: number; data: { id: string } }, @Body() body: { _mid: number; data: { id: string } },
) { ) {
const { _mid = 0, data } = body; const { _mid = 0, data } = body;

2
packages/nocodb/src/modules/jobs/jobs/at-import/at-import.controller.ts

@ -24,7 +24,7 @@ export class AtImportController {
]) ])
@Acl('airtableImport') @Acl('airtableImport')
@HttpCode(200) @HttpCode(200)
async triggerSync(@Request() req) { async triggerSync(@Req() req: Request) {
const jobs = await this.jobsService.jobList(); const jobs = await this.jobsService.jobList();
const fnd = jobs.find((j) => j.data.syncId === req.params.syncId); const fnd = jobs.find((j) => j.data.syncId === req.params.syncId);

6
packages/nocodb/src/modules/jobs/jobs/export-import/duplicate.controller.ts

@ -34,7 +34,7 @@ export class DuplicateController {
scope: 'org', scope: 'org',
}) })
public async duplicateSharedBase( public async duplicateSharedBase(
@Request() req, @Req() req: Request,
@Param('workspaceId') _workspaceId: string, @Param('workspaceId') _workspaceId: string,
@Param('sharedBaseId') sharedBaseId: string, @Param('sharedBaseId') sharedBaseId: string,
@Body() @Body()
@ -101,7 +101,7 @@ export class DuplicateController {
@HttpCode(200) @HttpCode(200)
@Acl('duplicateBase') @Acl('duplicateBase')
async duplicateBase( async duplicateBase(
@Request() req, @Req() req: Request,
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Param('sourceId') sourceId?: string, @Param('sourceId') sourceId?: string,
@Body() @Body()
@ -168,7 +168,7 @@ export class DuplicateController {
@HttpCode(200) @HttpCode(200)
@Acl('duplicateModel') @Acl('duplicateModel')
async duplicateModel( async duplicateModel(
@Request() req, @Req() req: Request,
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Param('modelId') modelId?: string, @Param('modelId') modelId?: string,
@Body() @Body()

4
packages/nocodb/src/modules/jobs/jobs/meta-sync/meta-sync.controller.ts

@ -24,7 +24,7 @@ export class MetaSyncController {
]) ])
@HttpCode(200) @HttpCode(200)
@Acl('metaDiffSync') @Acl('metaDiffSync')
async metaDiffSync(@Param('baseId') baseId: string, @Request() req) { async metaDiffSync(@Param('baseId') baseId: string, @Req() req: Request) {
const jobs = await this.jobsService.jobList(); const jobs = await this.jobsService.jobList();
const fnd = jobs.find( const fnd = jobs.find(
(j) => j.name === JobTypes.MetaSync && j.data.baseId === baseId, (j) => j.name === JobTypes.MetaSync && j.data.baseId === baseId,
@ -57,7 +57,7 @@ export class MetaSyncController {
async baseMetaDiffSync( async baseMetaDiffSync(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Param('sourceId') sourceId: string, @Param('sourceId') sourceId: string,
@Request() req, @Req() req: Request,
) { ) {
const jobs = await this.jobsService.jobList(); const jobs = await this.jobsService.jobList();
const fnd = jobs.find( const fnd = jobs.find(

2
packages/nocodb/src/modules/jobs/jobs/source-create/source-create.controller.ts

@ -29,7 +29,7 @@ export class SourceCreateController {
async baseCreate( async baseCreate(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Body() body: BaseReqType, @Body() body: BaseReqType,
@Req() req, @Req() req: Request,
) { ) {
const jobs = await this.jobsService.jobList(); const jobs = await this.jobsService.jobList();
const fnd = jobs.find( const fnd = jobs.find(

2
packages/nocodb/src/modules/jobs/jobs/source-delete/source-delete.controller.ts

@ -26,7 +26,7 @@ export class SourceDeleteController {
'/api/v2/meta/bases/:baseId/sources/:sourceId', '/api/v2/meta/bases/:baseId/sources/:sourceId',
]) ])
@Acl('baseDelete') @Acl('baseDelete')
async baseDelete(@Param('sourceId') sourceId: string, @Req() req) { async baseDelete(@Param('sourceId') sourceId: string, @Req() req: Request) {
const jobs = await this.jobsService.jobList(); const jobs = await this.jobsService.jobList();
const fnd = jobs.find( const fnd = jobs.find(
(j) => j.name === JobTypes.BaseDelete && j.data.sourceId === sourceId, (j) => j.name === JobTypes.BaseDelete && j.data.sourceId === sourceId,

26
packages/nocodb/src/types/express.d.ts vendored

@ -0,0 +1,26 @@
import * as express from 'express';
import { Express } from 'express-serve-static-core';
// declare global {
// namespace Express {
// interface Request {
// id?: string;
// ncWorkspaceId?: string;
// ncProjectId?: string;
// user?: any;
// }
// }
// }
//
// interface TokenData {
// userId: string;
// iat: string;
// }
declare module 'express-serve-static-core' {
interface Request {
// id?: string;
// ncWorkspaceId?: string;
// ncProjectId?: string;
user: any;
}
}

3
packages/nocodb/tsconfig.json

@ -26,6 +26,7 @@
"src/*": ["./src/*"], "src/*": ["./src/*"],
"~/*": ["./src/*"], "~/*": ["./src/*"],
"@/*": ["./src/*"] "@/*": ["./src/*"]
} },
"typeRoots": ["./src/types","./node_modules/@types", ]
} }
} }

Loading…
Cancel
Save