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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -7,9 +7,10 @@ import {
Param,
Patch,
Post,
Request,
Req,
UseGuards,
} from '@nestjs/common';
import { Request } from 'express';
import { ColumnReqType } from 'nocodb-sdk';
import type { Column } from '~/models';
import { GlobalGuard } from '~/guards/global/global.guard';
@ -31,7 +32,7 @@ export class ColumnsController {
async columnAdd(
@Param('tableId') tableId: string,
@Body() body: ColumnReqType,
@Request() req: any,
@Req() req: Request,
) {
return await this.columnsService.columnAdd({
tableId,
@ -49,7 +50,7 @@ export class ColumnsController {
async columnUpdate(
@Param('columnId') columnId: string,
@Body() body: ColumnReqType,
@Request() req: any,
@Req() req: Request,
) {
return await this.columnsService.columnUpdate({
columnId: columnId,
@ -64,7 +65,7 @@ export class ColumnsController {
'/api/v2/meta/columns/:columnId',
])
@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({
columnId,
req,
@ -113,7 +114,7 @@ export class ColumnsController {
column: Partial<Column>;
}[];
},
@Request() req: any,
@Req() req: Request,
) {
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 { GlobalGuard } from '~/guards/global/global.guard';
import { DatasService } from '~/services/datas.service';
@ -17,7 +18,7 @@ export class DataAliasExportController {
'/api/v1/db/data/:orgs/:baseName/:tableName/views/:viewName/export/excel',
])
@Acl('exportExcel')
async excelDataExport(@Request() req, @Response() res) {
async excelDataExport(@Req() req: Request, @Res() res: Response) {
const { model, view } =
await this.datasService.getViewAndModelFromRequestByAliasOrId(req);
let targetView = view;
@ -44,7 +45,7 @@ export class DataAliasExportController {
'/api/v1/db/data/:orgs/:baseName/:tableName/export/csv',
])
@Acl('exportCsv')
async csvDataExport(@Request() req, @Response() res) {
async csvDataExport(@Req() req: Request, @Res() res: Response) {
const { model, view } =
await this.datasService.getViewAndModelFromRequestByAliasOrId(req);
let targetView = view;

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

@ -28,7 +28,7 @@ export class ViewsController {
'/api/v2/meta/tables/:tableId/views',
])
@Acl('viewList')
async viewList(@Param('tableId') tableId: string, @Request() req) {
async viewList(@Param('tableId') tableId: string, @Req() req: Request) {
return new PagedResponseImpl(
await this.viewsService.viewList({
tableId,
@ -42,7 +42,7 @@ export class ViewsController {
async viewUpdate(
@Param('viewId') viewId: string,
@Body() body: ViewUpdateReqType,
@Request() req,
@Req() req: Request,
) {
const result = await this.viewsService.viewUpdate({
viewId,
@ -55,7 +55,7 @@ export class ViewsController {
@Delete(['/api/v1/db/meta/views/:viewId', '/api/v2/meta/views/:viewId'])
@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({
viewId,
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 * as e from 'express';
import type { Knex } from 'knex';
@ -319,3 +320,11 @@ export interface AppConfig {
mainSubDomain: 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)
async listen(
@Response() res,
@Request() req,
@Req() req: Request,
@Body() body: { _mid: number; data: { id: string } },
) {
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')
@HttpCode(200)
async triggerSync(@Request() req) {
async triggerSync(@Req() req: Request) {
const jobs = await this.jobsService.jobList();
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',
})
public async duplicateSharedBase(
@Request() req,
@Req() req: Request,
@Param('workspaceId') _workspaceId: string,
@Param('sharedBaseId') sharedBaseId: string,
@Body()
@ -101,7 +101,7 @@ export class DuplicateController {
@HttpCode(200)
@Acl('duplicateBase')
async duplicateBase(
@Request() req,
@Req() req: Request,
@Param('baseId') baseId: string,
@Param('sourceId') sourceId?: string,
@Body()
@ -168,7 +168,7 @@ export class DuplicateController {
@HttpCode(200)
@Acl('duplicateModel')
async duplicateModel(
@Request() req,
@Req() req: Request,
@Param('baseId') baseId: string,
@Param('modelId') modelId?: string,
@Body()

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

@ -24,7 +24,7 @@ export class MetaSyncController {
])
@HttpCode(200)
@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 fnd = jobs.find(
(j) => j.name === JobTypes.MetaSync && j.data.baseId === baseId,
@ -57,7 +57,7 @@ export class MetaSyncController {
async baseMetaDiffSync(
@Param('baseId') baseId: string,
@Param('sourceId') sourceId: string,
@Request() req,
@Req() req: Request,
) {
const jobs = await this.jobsService.jobList();
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(
@Param('baseId') baseId: string,
@Body() body: BaseReqType,
@Req() req,
@Req() req: Request,
) {
const jobs = await this.jobsService.jobList();
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',
])
@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 fnd = jobs.find(
(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/*"]
}
},
"typeRoots": ["./src/types","./node_modules/@types", ]
}
}

Loading…
Cancel
Save