add user module and jwt
This commit is contained in:
parent
d7d9777d1a
commit
afe44ab68a
@ -1,4 +1,42 @@
|
|||||||
import { Module } from '@nestjs/common';
|
import { DynamicModule, Module } from '@nestjs/common';
|
||||||
|
|
||||||
|
import { PassportModule } from '@nestjs/passport';
|
||||||
|
|
||||||
|
import { Configure } from '@/modules/config/configure';
|
||||||
|
|
||||||
|
import { DatabaseModule } from '@/modules/database/database.module';
|
||||||
|
import { addEntities, addSubscribers } from '@/modules/database/utils';
|
||||||
|
|
||||||
|
import * as entities from './entities';
|
||||||
|
import * as guards from './guards';
|
||||||
|
import * as interceptors from './interceptors';
|
||||||
|
import * as repositories from './repositories';
|
||||||
|
import * as services from './services';
|
||||||
|
import * as strategies from './strategies';
|
||||||
|
import * as subscribers from './subscribers';
|
||||||
|
|
||||||
@Module({})
|
@Module({})
|
||||||
export class UserModule {}
|
export class UserModule {
|
||||||
|
static async forRoot(configure: Configure): Promise<DynamicModule> {
|
||||||
|
return {
|
||||||
|
module: UserModule,
|
||||||
|
imports: [
|
||||||
|
PassportModule,
|
||||||
|
services.TokenService.JwtModuleFactory(configure),
|
||||||
|
await addEntities(configure, Object.values(entities)),
|
||||||
|
DatabaseModule.forRepository(Object.values(repositories)),
|
||||||
|
],
|
||||||
|
providers: [
|
||||||
|
...Object.values(interceptors),
|
||||||
|
...Object.values(services),
|
||||||
|
...Object.values(strategies),
|
||||||
|
...Object.values(guards),
|
||||||
|
...(await addSubscribers(configure, Object.values(subscribers))),
|
||||||
|
],
|
||||||
|
exports: [
|
||||||
|
...Object.values(services),
|
||||||
|
DatabaseModule.forRepository(Object.values(repositories)),
|
||||||
|
],
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -7,6 +7,9 @@ import { FastifyAdapter, NestFastifyApplication } from '@nestjs/platform-fastify
|
|||||||
import { existsSync } from 'fs-extra';
|
import { existsSync } from 'fs-extra';
|
||||||
import { isNil } from 'lodash';
|
import { isNil } from 'lodash';
|
||||||
|
|
||||||
|
import { JwtAuthGuard } from '@/modules/user/guards';
|
||||||
|
import { UserModule } from '@/modules/user/user.module';
|
||||||
|
|
||||||
import * as configs from './config';
|
import * as configs from './config';
|
||||||
import { ContentModule } from './modules/content/content.module';
|
import { ContentModule } from './modules/content/content.module';
|
||||||
import { CreateOptions } from './modules/core/types';
|
import { CreateOptions } from './modules/core/types';
|
||||||
@ -16,7 +19,6 @@ import { MeiliModule } from './modules/meilisearch/meili.module';
|
|||||||
import { Restful } from './modules/restful/restful';
|
import { Restful } from './modules/restful/restful';
|
||||||
import { RestfulModule } from './modules/restful/restful.module';
|
import { RestfulModule } from './modules/restful/restful.module';
|
||||||
import { ApiConfig } from './modules/restful/types';
|
import { ApiConfig } from './modules/restful/types';
|
||||||
import { JwtAuthGuard } from './modules/user/guards/jwt.auth.guard';
|
|
||||||
|
|
||||||
export const createOptions: CreateOptions = {
|
export const createOptions: CreateOptions = {
|
||||||
commands: () => [...Object.values(dbCommands)],
|
commands: () => [...Object.values(dbCommands)],
|
||||||
@ -26,6 +28,7 @@ export const createOptions: CreateOptions = {
|
|||||||
await MeiliModule.forRoot(configure),
|
await MeiliModule.forRoot(configure),
|
||||||
await RestfulModule.forRoot(configure),
|
await RestfulModule.forRoot(configure),
|
||||||
await ContentModule.forRoot(configure),
|
await ContentModule.forRoot(configure),
|
||||||
|
await UserModule.forRoot(configure),
|
||||||
],
|
],
|
||||||
globals: { guard: JwtAuthGuard },
|
globals: { guard: JwtAuthGuard },
|
||||||
builder: async ({ configure, BootModule }) => {
|
builder: async ({ configure, BootModule }) => {
|
||||||
|
Loading…
Reference in New Issue
Block a user