mirror of https://github.com/nocodb/nocodb
mertmit
6 months ago
19 changed files with 159 additions and 204 deletions
@ -1,16 +0,0 @@
|
||||
import { forwardRef, Module } from '@nestjs/common'; |
||||
import { PassportModule } from '@nestjs/passport'; |
||||
import { GoogleStrategyProvider } from '~/strategies/google.strategy/google.strategy'; |
||||
import { UsersService } from '~/services/users/users.service'; |
||||
import { AuthController } from '~/controllers/auth/auth.controller'; |
||||
import { MetasModule } from '~/modules/metas/metas.module'; |
||||
|
||||
@Module({ |
||||
imports: [PassportModule, forwardRef(() => MetasModule)], |
||||
controllers: [ |
||||
...(process.env.NC_WORKER_CONTAINER !== 'true' ? [AuthController] : []), |
||||
], |
||||
providers: [UsersService, GoogleStrategyProvider], |
||||
exports: [UsersService], |
||||
}) |
||||
export class AuthModule {} |
@ -1,71 +0,0 @@
|
||||
import { Module } from '@nestjs/common'; |
||||
import { MulterModule } from '@nestjs/platform-express'; |
||||
import multer from 'multer'; |
||||
import { NC_ATTACHMENT_FIELD_SIZE } from '~/constants'; |
||||
import { DataTableController } from '~/controllers/data-table.controller'; |
||||
import { DataTableService } from '~/services/data-table.service'; |
||||
import { DataAliasController } from '~/controllers/data-alias.controller'; |
||||
import { PublicDatasExportController } from '~/controllers/public-datas-export.controller'; |
||||
import { PublicDatasController } from '~/controllers/public-datas.controller'; |
||||
import { DatasService } from '~/services/datas.service'; |
||||
import { DatasController } from '~/controllers/datas.controller'; |
||||
import { BulkDataAliasController } from '~/controllers/bulk-data-alias.controller'; |
||||
import { DataAliasExportController } from '~/controllers/data-alias-export.controller'; |
||||
import { DataAliasNestedController } from '~/controllers/data-alias-nested.controller'; |
||||
import { OldDatasController } from '~/controllers/old-datas/old-datas.controller'; |
||||
import { BulkDataAliasService } from '~/services/bulk-data-alias.service'; |
||||
import { DataAliasNestedService } from '~/services/data-alias-nested.service'; |
||||
import { OldDatasService } from '~/controllers/old-datas/old-datas.service'; |
||||
import { PublicDatasExportService } from '~/services/public-datas-export.service'; |
||||
import { PublicDatasService } from '~/services/public-datas.service'; |
||||
import { CalendarDatasController } from '~/controllers/calendars-datas.controller'; |
||||
import { CalendarDatasService } from '~/services/calendar-datas.service'; |
||||
|
||||
export const dataModuleMetadata = { |
||||
imports: [ |
||||
MulterModule.register({ |
||||
storage: multer.diskStorage({}), |
||||
limits: { |
||||
fieldSize: NC_ATTACHMENT_FIELD_SIZE, |
||||
}, |
||||
}), |
||||
], |
||||
controllers: [ |
||||
...(process.env.NC_WORKER_CONTAINER !== 'true' |
||||
? [ |
||||
DataTableController, |
||||
DatasController, |
||||
CalendarDatasController, |
||||
BulkDataAliasController, |
||||
DataAliasController, |
||||
DataAliasNestedController, |
||||
DataAliasExportController, |
||||
OldDatasController, |
||||
PublicDatasController, |
||||
PublicDatasExportController, |
||||
] |
||||
: []), |
||||
], |
||||
providers: [ |
||||
DataTableService, |
||||
DatasService, |
||||
BulkDataAliasService, |
||||
DataAliasNestedService, |
||||
CalendarDatasService, |
||||
OldDatasService, |
||||
PublicDatasService, |
||||
PublicDatasExportService, |
||||
], |
||||
exports: [ |
||||
DatasService, |
||||
BulkDataAliasService, |
||||
CalendarDatasService, |
||||
DataAliasNestedService, |
||||
OldDatasService, |
||||
PublicDatasService, |
||||
PublicDatasExportService, |
||||
], |
||||
}; |
||||
|
||||
@Module(dataModuleMetadata) |
||||
export class DatasModule {} |
@ -1,67 +0,0 @@
|
||||
import { forwardRef, Global, Module } from '@nestjs/common'; |
||||
import { ExtractJwt } from 'passport-jwt'; |
||||
import type { Provider } from '@nestjs/common'; |
||||
import { InitMetaServiceProvider } from '~/modules/global/init-meta-service.provider'; |
||||
import { EventEmitterModule } from '~/modules/event-emitter/event-emitter.module'; |
||||
import { SocketGateway } from '~/gateways/socket.gateway'; |
||||
import { GlobalGuard } from '~/guards/global/global.guard'; |
||||
import { MetaService } from '~/meta/meta.service'; |
||||
import Noco from '~/Noco'; |
||||
import { AppHooksService } from '~/services/app-hooks/app-hooks.service'; |
||||
import { JwtStrategy } from '~/strategies/jwt.strategy'; |
||||
import { UsersService } from '~/services/users/users.service'; |
||||
import { TelemetryService } from '~/services/telemetry.service'; |
||||
import { AppHooksListenerService } from '~/services/app-hooks-listener.service'; |
||||
import { HookHandlerService } from '~/services/hook-handler.service'; |
||||
import { UsersModule } from '~/modules/users/users.module'; |
||||
import { JobsModule } from '~/modules/jobs/jobs.module'; |
||||
|
||||
export const JwtStrategyProvider: Provider = { |
||||
provide: JwtStrategy, |
||||
useFactory: async (usersService: UsersService, metaService: MetaService) => { |
||||
const config = metaService.config; |
||||
|
||||
await Noco.initJwt(); |
||||
|
||||
const options = { |
||||
// ignoreExpiration: false,
|
||||
jwtFromRequest: ExtractJwt.fromHeader('xc-auth'), |
||||
// expiresIn: '10h',
|
||||
passReqToCallback: true, |
||||
secretOrKey: config.auth.jwt.secret, |
||||
...config.auth.jwt.options, |
||||
}; |
||||
|
||||
return new JwtStrategy(options, usersService); |
||||
}, |
||||
inject: [UsersService, MetaService], |
||||
}; |
||||
|
||||
export const globalModuleMetadata = { |
||||
imports: [EventEmitterModule, forwardRef(() => UsersModule), JobsModule], |
||||
providers: [ |
||||
InitMetaServiceProvider, |
||||
AppHooksService, |
||||
JwtStrategyProvider, |
||||
GlobalGuard, |
||||
SocketGateway, |
||||
AppHooksService, |
||||
AppHooksListenerService, |
||||
TelemetryService, |
||||
HookHandlerService, |
||||
], |
||||
exports: [ |
||||
MetaService, |
||||
JwtStrategyProvider, |
||||
GlobalGuard, |
||||
AppHooksService, |
||||
AppHooksListenerService, |
||||
TelemetryService, |
||||
HookHandlerService, |
||||
...(process.env.NC_WORKER_CONTAINER !== 'true' ? [SocketGateway] : []), |
||||
], |
||||
}; |
||||
|
||||
@Global() |
||||
@Module(globalModuleMetadata) |
||||
export class GlobalModule {} |
@ -1,15 +0,0 @@
|
||||
import { forwardRef, Module } from '@nestjs/common'; |
||||
import { PassportModule } from '@nestjs/passport'; |
||||
import { UsersService } from '~/services/users/users.service'; |
||||
import { UsersController } from '~/controllers/users/users.controller'; |
||||
import { MetasModule } from '~/modules/metas/metas.module'; |
||||
|
||||
@Module({ |
||||
imports: [PassportModule, forwardRef(() => MetasModule)], |
||||
controllers: [ |
||||
...(process.env.NC_WORKER_CONTAINER !== 'true' ? [UsersController] : []), |
||||
], |
||||
providers: [UsersService], |
||||
exports: [UsersService], |
||||
}) |
||||
export class UsersModule {} |
@ -0,0 +1,27 @@
|
||||
import { ExtractJwt } from 'passport-jwt'; |
||||
import type { Provider } from '@nestjs/common'; |
||||
import { MetaService } from '~/meta/meta.service'; |
||||
import { UsersService } from '~/services/users/users.service'; |
||||
import { JwtStrategy } from '~/strategies/jwt.strategy'; |
||||
import Noco from '~/Noco'; |
||||
|
||||
export const JwtStrategyProvider: Provider = { |
||||
provide: JwtStrategy, |
||||
useFactory: async (usersService: UsersService, metaService: MetaService) => { |
||||
const config = metaService.config; |
||||
|
||||
await Noco.initJwt(); |
||||
|
||||
const options = { |
||||
// ignoreExpiration: false,
|
||||
jwtFromRequest: ExtractJwt.fromHeader('xc-auth'), |
||||
// expiresIn: '10h',
|
||||
passReqToCallback: true, |
||||
secretOrKey: config.auth.jwt.secret, |
||||
...config.auth.jwt.options, |
||||
}; |
||||
|
||||
return new JwtStrategy(options, usersService); |
||||
}, |
||||
inject: [UsersService, MetaService], |
||||
}; |
Loading…
Reference in new issue