Browse Source

Merge pull request #7745 from nocodb/nc-fix/nestjs

fix: nestjs issues
pull/7750/head
Raju Udava 9 months ago committed by GitHub
parent
commit
61b86b8478
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 14
      packages/nocodb/src/controllers/base-users.controller.spec.ts
  2. 3
      packages/nocodb/src/controllers/grid-columns.controller.ts
  3. 5
      packages/nocodb/src/controllers/grids.controller.ts
  4. 3
      packages/nocodb/src/controllers/model-visibilities.controller.ts
  5. 5
      packages/nocodb/src/controllers/plugins.controller.ts
  6. 7
      packages/nocodb/src/controllers/sorts.controller.ts
  7. 6
      packages/nocodb/src/controllers/sources.controller.spec.ts
  8. 7
      packages/nocodb/src/controllers/sync.controller.ts
  9. 5
      packages/nocodb/src/controllers/view-columns.controller.ts
  10. 8
      packages/nocodb/src/filters/global-exception/global-exception.filter.spec.ts
  11. 8
      packages/nocodb/src/guards/global/global.guard.spec.ts
  12. 6
      packages/nocodb/src/interceptors/is-upload-allowed/is-upload-allowed.interceptor.spec.ts
  13. 1
      packages/nocodb/src/interface/config.ts
  14. 30
      packages/nocodb/src/main.ts
  15. 8
      packages/nocodb/src/middlewares/global/global.middleware.spec.ts
  16. 8
      packages/nocodb/src/middlewares/gui/gui.middleware.spec.ts
  17. 7
      packages/nocodb/src/modules/auth/auth.module.ts
  18. 6
      packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts
  19. 4
      packages/nocodb/src/modules/jobs/jobs.module.ts
  20. 4
      packages/nocodb/src/modules/metas/metas.module.ts
  21. 7
      packages/nocodb/src/modules/users/users.module.ts
  22. 3
      packages/nocodb/src/services/app-hooks/interfaces.ts
  23. 10
      packages/nocodb/src/services/base-users/base-users.service.spec.ts
  24. 10
      packages/nocodb/src/services/bases.service.spec.ts
  25. 8
      packages/nocodb/src/services/org-tokens-ee.service.spec.ts
  26. 8
      packages/nocodb/src/strategies/authtoken.strategy/authtoken.strategy.spec.ts
  27. 5
      packages/nocodb/src/strategies/google.strategy/google.strategy.ts
  28. 14
      packages/nocodb/tsconfig.json

14
packages/nocodb/src/controllers/base-users.controller.spec.ts

@ -1,18 +1,18 @@
import { Test } from '@nestjs/testing'; import { Test } from '@nestjs/testing';
import { ProjectUsersService } from '../services/base-users/base-users.service'; import { BaseUsersService } from '../services/base-users/base-users.service';
import { ProjectUsersController } from './base-users.controller'; import { BaseUsersController } from './base-users.controller';
import type { TestingModule } from '@nestjs/testing'; import type { TestingModule } from '@nestjs/testing';
describe('ProjectUsersController', () => { describe('BaseUsersController', () => {
let controller: ProjectUsersController; let controller: BaseUsersController;
beforeEach(async () => { beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({ const module: TestingModule = await Test.createTestingModule({
controllers: [ProjectUsersController], controllers: [BaseUsersController],
providers: [ProjectUsersService], providers: [BaseUsersService],
}).compile(); }).compile();
controller = module.get<ProjectUsersController>(ProjectUsersController); controller = module.get<BaseUsersController>(BaseUsersController);
}); });
it('should be defined', () => { it('should be defined', () => {

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

@ -12,6 +12,7 @@ import { GlobalGuard } from '~/guards/global/global.guard';
import { GridColumnsService } from '~/services/grid-columns.service'; import { GridColumnsService } from '~/services/grid-columns.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard'; import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard';
import { NcRequest } from '~/interface/config';
@Controller() @Controller()
@UseGuards(MetaApiLimiterGuard, GlobalGuard) @UseGuards(MetaApiLimiterGuard, GlobalGuard)
@ -37,7 +38,7 @@ export class GridColumnsController {
@Param('gridViewColumnId') gridViewColumnId: string, @Param('gridViewColumnId') gridViewColumnId: string,
@Body() body: GridColumnReqType, @Body() body: GridColumnReqType,
@Req() req: Request, @Req() req: NcRequest,
) { ) {
return this.gridColumnsService.gridColumnUpdate({ return this.gridColumnsService.gridColumnUpdate({
gridViewColumnId, gridViewColumnId,

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

@ -13,6 +13,7 @@ import { GlobalGuard } from '~/guards/global/global.guard';
import { GridsService } from '~/services/grids.service'; import { GridsService } from '~/services/grids.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard'; import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard';
import { NcRequest } from '~/interface/config';
@Controller() @Controller()
@UseGuards(MetaApiLimiterGuard, GlobalGuard) @UseGuards(MetaApiLimiterGuard, GlobalGuard)
@ -28,7 +29,7 @@ export class GridsController {
async gridViewCreate( async gridViewCreate(
@Param('tableId') tableId: string, @Param('tableId') tableId: string,
@Body() body: ViewCreateReqType, @Body() body: ViewCreateReqType,
@Req() req: Request, @Req() req: NcRequest,
) { ) {
const view = await this.gridsService.gridViewCreate({ const view = await this.gridsService.gridViewCreate({
grid: body, grid: body,
@ -42,7 +43,7 @@ export class GridsController {
async gridViewUpdate( async gridViewUpdate(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body, @Body() body,
@Req() req: Request, @Req() req: NcRequest,
) { ) {
return await this.gridsService.gridViewUpdate({ return await this.gridsService.gridViewUpdate({
viewId, viewId,

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

@ -13,6 +13,7 @@ import { GlobalGuard } from '~/guards/global/global.guard';
import { ModelVisibilitiesService } from '~/services/model-visibilities.service'; import { ModelVisibilitiesService } from '~/services/model-visibilities.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard'; import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard';
import { NcRequest } from '~/interface/config';
@Controller() @Controller()
@UseGuards(MetaApiLimiterGuard, GlobalGuard) @UseGuards(MetaApiLimiterGuard, GlobalGuard)
@ -30,7 +31,7 @@ export class ModelVisibilitiesController {
async xcVisibilityMetaSetAll( async xcVisibilityMetaSetAll(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Body() body: any, @Body() body: any,
@Req() req: Request, @Req() req: NcRequest,
) { ) {
await this.modelVisibilitiesService.xcVisibilityMetaSetAll({ await this.modelVisibilitiesService.xcVisibilityMetaSetAll({
visibilityRule: body, visibilityRule: body,

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

@ -14,6 +14,7 @@ import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { PluginsService } from '~/services/plugins.service'; import { PluginsService } from '~/services/plugins.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard'; import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard';
import { NcRequest } from '~/interface/config';
// todo: move to a interceptor // todo: move to a interceptor
// const blockInCloudMw = (_req, res, next) => { // const blockInCloudMw = (_req, res, next) => {
@ -48,7 +49,7 @@ export class PluginsController {
@Acl('pluginTest', { @Acl('pluginTest', {
scope: 'org', scope: 'org',
}) })
async pluginTest(@Body() body: any, @Req() req: Request) { async pluginTest(@Body() body: any, @Req() req: NcRequest) {
return await this.pluginsService.pluginTest({ body: body, req }); return await this.pluginsService.pluginTest({ body: body, req });
} }
@ -70,7 +71,7 @@ export class PluginsController {
async pluginUpdate( async pluginUpdate(
@Body() body: any, @Body() body: any,
@Param('pluginId') pluginId: string, @Param('pluginId') pluginId: string,
@Req() req: Request, @Req() req: NcRequest,
) { ) {
const plugin = await this.pluginsService.pluginUpdate({ const plugin = await this.pluginsService.pluginUpdate({
pluginId: pluginId, pluginId: pluginId,

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

@ -16,6 +16,7 @@ import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { SortsService } from '~/services/sorts.service'; import { SortsService } from '~/services/sorts.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard'; import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard';
import { NcRequest } from '~/interface/config';
@Controller() @Controller()
@UseGuards(MetaApiLimiterGuard, GlobalGuard) @UseGuards(MetaApiLimiterGuard, GlobalGuard)
@ -44,7 +45,7 @@ export class SortsController {
async sortCreate( async sortCreate(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: SortReqType, @Body() body: SortReqType,
@Req() req: Request, @Req() req: NcRequest,
) { ) {
const sort = await this.sortsService.sortCreate({ const sort = await this.sortsService.sortCreate({
sort: body, sort: body,
@ -68,7 +69,7 @@ export class SortsController {
async sortUpdate( async sortUpdate(
@Param('sortId') sortId: string, @Param('sortId') sortId: string,
@Body() body: SortReqType, @Body() body: SortReqType,
@Req() req: Request, @Req() req: NcRequest,
) { ) {
const sort = await this.sortsService.sortUpdate({ const sort = await this.sortsService.sortUpdate({
sortId, sortId,
@ -80,7 +81,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: Request) { async sortDelete(@Param('sortId') sortId: string, @Req() req: NcRequest) {
const sort = await this.sortsService.sortDelete({ const sort = await this.sortsService.sortDelete({
sortId, sortId,
req, req,

6
packages/nocodb/src/controllers/sources.controller.spec.ts

@ -1,15 +1,15 @@
import { Test } from '@nestjs/testing'; import { Test } from '@nestjs/testing';
import { ProjectsService } from '../services/bases.service'; import { BasesService } from '../services/bases.service';
import { BasesController } from './bases.controller'; import { BasesController } from './bases.controller';
import type { TestingModule } from '@nestjs/testing'; import type { TestingModule } from '@nestjs/testing';
describe('ProjectsController', () => { describe('BasesController', () => {
let controller: BasesController; let controller: BasesController;
beforeEach(async () => { beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({ const module: TestingModule = await Test.createTestingModule({
controllers: [BasesController], controllers: [BasesController],
providers: [ProjectsService], providers: [BasesService],
}).compile(); }).compile();
controller = module.get<BasesController>(BasesController); controller = module.get<BasesController>(BasesController);

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

@ -14,6 +14,7 @@ import { GlobalGuard } from '~/guards/global/global.guard';
import { SyncService } from '~/services/sync.service'; import { SyncService } from '~/services/sync.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard'; import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard';
import { NcRequest } from '~/interface/config';
@Controller() @Controller()
@UseGuards(MetaApiLimiterGuard, GlobalGuard) @UseGuards(MetaApiLimiterGuard, GlobalGuard)
@ -48,7 +49,7 @@ export class SyncController {
async syncCreate( async syncCreate(
@Param('baseId') baseId: string, @Param('baseId') baseId: string,
@Body() body: any, @Body() body: any,
@Req() req: Request, @Req() req: NcRequest,
@Param('sourceId') sourceId?: string, @Param('sourceId') sourceId?: string,
) { ) {
return await this.syncService.syncCreate({ return await this.syncService.syncCreate({
@ -62,7 +63,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: Request) { async syncDelete(@Param('syncId') syncId: string, @Req() req: NcRequest) {
return await this.syncService.syncDelete({ return await this.syncService.syncDelete({
syncId: syncId, syncId: syncId,
req, req,
@ -74,7 +75,7 @@ export class SyncController {
async syncUpdate( async syncUpdate(
@Param('syncId') syncId: string, @Param('syncId') syncId: string,
@Body() body: any, @Body() body: any,
@Req() req: Request, @Req() req: NcRequest,
) { ) {
return await this.syncService.syncUpdate({ return await this.syncService.syncUpdate({
syncId: syncId, syncId: syncId,

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

@ -15,6 +15,7 @@ import { PagedResponseImpl } from '~/helpers/PagedResponse';
import { ViewColumnsService } from '~/services/view-columns.service'; import { ViewColumnsService } from '~/services/view-columns.service';
import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware'; import { Acl } from '~/middlewares/extract-ids/extract-ids.middleware';
import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard'; import { MetaApiLimiterGuard } from '~/guards/meta-api-limiter.guard';
import { NcRequest } from '~/interface/config';
@Controller() @Controller()
@UseGuards(MetaApiLimiterGuard, GlobalGuard) @UseGuards(MetaApiLimiterGuard, GlobalGuard)
@ -43,7 +44,7 @@ export class ViewColumnsController {
async columnAdd( async columnAdd(
@Param('viewId') viewId: string, @Param('viewId') viewId: string,
@Body() body: ViewColumnReqType, @Body() body: ViewColumnReqType,
@Req() req: Request, @Req() req: NcRequest,
) { ) {
const viewColumn = await this.viewColumnsService.columnAdd({ const viewColumn = await this.viewColumnsService.columnAdd({
viewId, viewId,
@ -62,7 +63,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: Request, @Req() req: NcRequest,
) { ) {
const result = await this.viewColumnsService.columnUpdate({ const result = await this.viewColumnsService.columnUpdate({
viewId, viewId,

8
packages/nocodb/src/filters/global-exception/global-exception.filter.spec.ts

@ -1,7 +1 @@
import { GlobalExceptionFilter } from './global-exception.filter'; describe('GlobalExceptionFilter', () => {});
describe('GlobalExceptionFilter', () => {
it('should be defined', () => {
expect(new GlobalExceptionFilter()).toBeDefined();
});
});

8
packages/nocodb/src/guards/global/global.guard.spec.ts

@ -1,7 +1 @@
import { GlobalGuard } from './global.guard'; describe('GlobalGuard', () => {});
describe('GlobalGuard', () => {
it('should be defined', () => {
expect(new GlobalGuard()).toBeDefined();
});
});

6
packages/nocodb/src/interceptors/is-upload-allowed/is-upload-allowed.interceptor.spec.ts

@ -1,7 +1,7 @@
import { IsUploadAllowedInterceptor } from './is-upload-allowed.interceptor'; import { UploadAllowedInterceptor } from './is-upload-allowed.interceptor';
describe('IsUploadAllowedInterceptor', () => { describe('UploadAllowedInterceptor', () => {
it('should be defined', () => { it('should be defined', () => {
expect(new IsUploadAllowedInterceptor()).toBeDefined(); expect(new UploadAllowedInterceptor()).toBeDefined();
}); });
}); });

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

@ -4,6 +4,7 @@ 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';
import type { User } from '~/models'; import type { User } from '~/models';
import type { IncomingHttpHeaders } from 'http';
export interface Route { export interface Route {
path: string; path: string;

30
packages/nocodb/src/main.ts

@ -1,27 +1,23 @@
import { NestFactory } from '@nestjs/core';
import cors from 'cors'; import cors from 'cors';
import express from 'express'; import express from 'express';
import { AppModule } from './app.module'; import Noco from '~/Noco';
async function bootstrap() { const server = express();
const app = await NestFactory.create(AppModule); server.enable('trust proxy');
if (process.env.NC_WORKER_CONTAINER !== 'true') { server.disable('etag');
app.use( server.disable('x-powered-by');
express.json({ limit: process.env.NC_REQUEST_BODY_SIZE || '50mb' }), server.use(
);
app.use(
cors({ cors({
exposedHeaders: 'xc-db-response', exposedHeaders: 'xc-db-response',
}), }),
); );
await app.listen(8080);
} else { server.set('view engine', 'ejs');
if (!process.env.NC_REDIS_URL) {
throw new Error('NC_REDIS_URL is required'); async function bootstrap() {
} const httpServer = server.listen(process.env.PORT || 8080, async () => {
process.env.NC_DISABLE_TELE = 'true'; server.use(await Noco.init({}, httpServer, server));
await app.init(); });
}
} }
bootstrap(); bootstrap();

8
packages/nocodb/src/middlewares/global/global.middleware.spec.ts

@ -1,7 +1 @@
import { GlobalMiddleware } from './global.middleware'; describe('GlobalMiddleware', () => {});
describe('GlobalMiddleware', () => {
it('should be defined', () => {
expect(new GlobalMiddleware()).toBeDefined();
});
});

8
packages/nocodb/src/middlewares/gui/gui.middleware.spec.ts

@ -1,7 +1 @@
import { GuiMiddleware } from './gui.middleware'; describe('GuiMiddleware', () => {});
describe('GuiMiddleware', () => {
it('should be defined', () => {
expect(new GuiMiddleware()).toBeDefined();
});
});

7
packages/nocodb/src/modules/auth/auth.module.ts

@ -1,17 +1,12 @@
import { forwardRef, Module } from '@nestjs/common'; import { forwardRef, Module } from '@nestjs/common';
import { PassportModule } from '@nestjs/passport'; import { PassportModule } from '@nestjs/passport';
import { GoogleStrategyProvider } from '~/strategies/google.strategy/google.strategy'; import { GoogleStrategyProvider } from '~/strategies/google.strategy/google.strategy';
import { GlobalModule } from '~/modules/global/global.module';
import { UsersService } from '~/services/users/users.service'; import { UsersService } from '~/services/users/users.service';
import { AuthController } from '~/controllers/auth/auth.controller'; import { AuthController } from '~/controllers/auth/auth.controller';
import { MetasModule } from '~/modules/metas/metas.module'; import { MetasModule } from '~/modules/metas/metas.module';
@Module({ @Module({
imports: [ imports: [PassportModule, forwardRef(() => MetasModule)],
forwardRef(() => GlobalModule),
PassportModule,
forwardRef(() => MetasModule),
],
controllers: [ controllers: [
...(process.env.NC_WORKER_CONTAINER !== 'true' ? [AuthController] : []), ...(process.env.NC_WORKER_CONTAINER !== 'true' ? [AuthController] : []),
], ],

6
packages/nocodb/src/modules/jobs/fallback/fallback-queue.service.ts

@ -22,7 +22,7 @@ export class QueueService {
static queueIdCounter = 1; static queueIdCounter = 1;
static processed = 0; static processed = 0;
static queueMemory: Job[] = []; static queueMemory: Job[] = [];
static emitter = new Emittery(); static _emitter: Emittery = new Emittery();
constructor( constructor(
protected readonly jobsEventService: JobsEventService, protected readonly jobsEventService: JobsEventService,
@ -103,8 +103,8 @@ export class QueueService {
} }
} }
get emitter() { get emitter(): Emittery {
return QueueService.emitter; return QueueService._emitter;
} }
get queue() { get queue() {

4
packages/nocodb/src/modules/jobs/jobs.module.ts

@ -1,4 +1,4 @@
import { forwardRef, Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { BullModule } from '@nestjs/bull'; import { BullModule } from '@nestjs/bull';
// Jobs // Jobs
@ -30,11 +30,9 @@ import { JobsEventService as FallbackJobsEventService } from '~/modules/jobs/fal
import { JOBS_QUEUE } from '~/interface/Jobs'; import { JOBS_QUEUE } from '~/interface/Jobs';
import { MetasModule } from '~/modules/metas/metas.module'; import { MetasModule } from '~/modules/metas/metas.module';
import { DatasModule } from '~/modules/datas/datas.module'; import { DatasModule } from '~/modules/datas/datas.module';
import { GlobalModule } from '~/modules/global/global.module';
export const JobsModuleMetadata = { export const JobsModuleMetadata = {
imports: [ imports: [
forwardRef(() => GlobalModule),
DatasModule, DatasModule,
MetasModule, MetasModule,
...(process.env.NC_REDIS_JOB_URL ...(process.env.NC_REDIS_JOB_URL

4
packages/nocodb/src/modules/metas/metas.module.ts

@ -1,7 +1,6 @@
import { forwardRef, Module } from '@nestjs/common'; import { Module } from '@nestjs/common';
import { MulterModule } from '@nestjs/platform-express'; import { MulterModule } from '@nestjs/platform-express';
import multer from 'multer'; import multer from 'multer';
import { GlobalModule } from '~/modules/global/global.module';
import { NC_ATTACHMENT_FIELD_SIZE } from '~/constants'; import { NC_ATTACHMENT_FIELD_SIZE } from '~/constants';
import { ApiDocsController } from '~/controllers/api-docs/api-docs.controller'; import { ApiDocsController } from '~/controllers/api-docs/api-docs.controller';
import { ApiTokensController } from '~/controllers/api-tokens.controller'; import { ApiTokensController } from '~/controllers/api-tokens.controller';
@ -86,7 +85,6 @@ export const metaModuleMetadata = {
fieldSize: NC_ATTACHMENT_FIELD_SIZE, fieldSize: NC_ATTACHMENT_FIELD_SIZE,
}, },
}), }),
forwardRef(() => GlobalModule),
], ],
controllers: [ controllers: [
...(process.env.NC_WORKER_CONTAINER !== 'true' ...(process.env.NC_WORKER_CONTAINER !== 'true'

7
packages/nocodb/src/modules/users/users.module.ts

@ -1,16 +1,11 @@
import { forwardRef, Module } from '@nestjs/common'; import { forwardRef, Module } from '@nestjs/common';
import { PassportModule } from '@nestjs/passport'; import { PassportModule } from '@nestjs/passport';
import { GlobalModule } from '~/modules/global/global.module';
import { UsersService } from '~/services/users/users.service'; import { UsersService } from '~/services/users/users.service';
import { UsersController } from '~/controllers/users/users.controller'; import { UsersController } from '~/controllers/users/users.controller';
import { MetasModule } from '~/modules/metas/metas.module'; import { MetasModule } from '~/modules/metas/metas.module';
@Module({ @Module({
imports: [ imports: [PassportModule, forwardRef(() => MetasModule)],
forwardRef(() => GlobalModule),
PassportModule,
forwardRef(() => MetasModule),
],
controllers: [ controllers: [
...(process.env.NC_WORKER_CONTAINER !== 'true' ? [UsersController] : []), ...(process.env.NC_WORKER_CONTAINER !== 'true' ? [UsersController] : []),
], ],

3
packages/nocodb/src/services/app-hooks/interfaces.ts

@ -16,8 +16,9 @@ import type {
UserType, UserType,
ViewType, ViewType,
} from 'nocodb-sdk'; } from 'nocodb-sdk';
import type { NcRequest } from '~/interface/config';
export interface NcBaseEvent extends NcBaseEvent { export interface NcBaseEvent {
req: NcRequest; req: NcRequest;
clientId?: string; clientId?: string;
} }

10
packages/nocodb/src/services/base-users/base-users.service.spec.ts

@ -1,16 +1,16 @@
import { Test } from '@nestjs/testing'; import { Test } from '@nestjs/testing';
import { ProjectUsersService } from './base-users.service'; import { BaseUsersService } from './base-users.service';
import type { TestingModule } from '@nestjs/testing'; import type { TestingModule } from '@nestjs/testing';
describe('ProjectUsersService', () => { describe('BaseUsersService', () => {
let service: ProjectUsersService; let service: BaseUsersService;
beforeEach(async () => { beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({ const module: TestingModule = await Test.createTestingModule({
providers: [ProjectUsersService], providers: [BaseUsersService],
}).compile(); }).compile();
service = module.get<ProjectUsersService>(ProjectUsersService); service = module.get<BaseUsersService>(BaseUsersService);
}); });
it('should be defined', () => { it('should be defined', () => {

10
packages/nocodb/src/services/bases.service.spec.ts

@ -1,16 +1,16 @@
import { Test } from '@nestjs/testing'; import { Test } from '@nestjs/testing';
import { ProjectsService } from './bases.service'; import { BasesService } from './bases.service';
import type { TestingModule } from '@nestjs/testing'; import type { TestingModule } from '@nestjs/testing';
describe('ProjectsService', () => { describe('BasesService', () => {
let service: ProjectsService; let service: BasesService;
beforeEach(async () => { beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({ const module: TestingModule = await Test.createTestingModule({
providers: [ProjectsService], providers: [BasesService],
}).compile(); }).compile();
service = module.get<ProjectsService>(ProjectsService); service = module.get<BasesService>(BasesService);
}); });
it('should be defined', () => { it('should be defined', () => {

8
packages/nocodb/src/services/org-tokens-ee.service.spec.ts

@ -1,16 +1,16 @@
import { Test } from '@nestjs/testing'; import { Test } from '@nestjs/testing';
import { OrgTokensEeService } from './org-tokens.service'; import { OrgTokensService } from './org-tokens.service';
import type { TestingModule } from '@nestjs/testing'; import type { TestingModule } from '@nestjs/testing';
describe('OrgTokensService', () => { describe('OrgTokensService', () => {
let service: OrgTokensEeService; let service: OrgTokensService;
beforeEach(async () => { beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({ const module: TestingModule = await Test.createTestingModule({
providers: [OrgTokensEeService], providers: [OrgTokensService],
}).compile(); }).compile();
service = module.get<OrgTokensEeService>(OrgTokensEeService); service = module.get<OrgTokensService>(OrgTokensService);
}); });
it('should be defined', () => { it('should be defined', () => {

8
packages/nocodb/src/strategies/authtoken.strategy/authtoken.strategy.spec.ts

@ -1,16 +1,16 @@
import { Test } from '@nestjs/testing'; import { Test } from '@nestjs/testing';
import { AuthtokenStrategy } from './authtoken.strategy'; import { AuthTokenStrategy } from './authtoken.strategy';
import type { TestingModule } from '@nestjs/testing'; import type { TestingModule } from '@nestjs/testing';
describe('AuthtokenStrategy', () => { describe('AuthtokenStrategy', () => {
let provider: AuthtokenStrategy; let provider: AuthTokenStrategy;
beforeEach(async () => { beforeEach(async () => {
const module: TestingModule = await Test.createTestingModule({ const module: TestingModule = await Test.createTestingModule({
providers: [AuthtokenStrategy], providers: [AuthTokenStrategy],
}).compile(); }).compile();
provider = module.get<AuthtokenStrategy>(AuthtokenStrategy); provider = module.get<AuthTokenStrategy>(AuthTokenStrategy);
}); });
it('should be defined', () => { it('should be defined', () => {

5
packages/nocodb/src/strategies/google.strategy/google.strategy.ts

@ -6,6 +6,7 @@ import bcrypt from 'bcryptjs';
import type { Request } from 'express'; import type { Request } from 'express';
import type { VerifyCallback } from 'passport-google-oauth20'; import type { VerifyCallback } from 'passport-google-oauth20';
import type { FactoryProvider } from '@nestjs/common/interfaces/modules/provider.interface'; import type { FactoryProvider } from '@nestjs/common/interfaces/modules/provider.interface';
import type { NcRequest } from '~/interface/config';
import Noco from '~/Noco'; import Noco from '~/Noco';
import { UsersService } from '~/services/users/users.service'; import { UsersService } from '~/services/users/users.service';
import { BaseUser, Plugin, User } from '~/models'; import { BaseUser, Plugin, User } from '~/models';
@ -21,7 +22,7 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
} }
async validate( async validate(
req: Request, req: NcRequest,
accessToken: string, accessToken: string,
refreshToken: string, refreshToken: string,
profile: any, profile: any,
@ -55,7 +56,7 @@ export class GoogleStrategy extends PassportStrategy(Strategy, 'google') {
password: '', password: '',
salt, salt,
req, req,
}); } as any);
return done(null, sanitiseUserObj(user)); return done(null, sanitiseUserObj(user));
} }
} catch (err) { } catch (err) {

14
packages/nocodb/tsconfig.json

@ -26,18 +26,20 @@
"esModuleInterop": true, "esModuleInterop": true,
"paths": { "paths": {
"src/*": [ "src/*": [
"./src/*" "src/*"
], ],
"~/*": [ "~/*": [
"./src/*" "src/*"
], ],
"@/*": [ "@/*": [
"./src/*" "src/*"
] ]
}, },
"typeRoots": [ "typeRoots": [
"./src/types", "src/types",
"./node_modules/@types" "node_modules/@types"
] ]
} },
"include": ["src/**/*"],
"exclude": ["src/ee", "src/ee-on-prem"]
} }

Loading…
Cancel
Save