How to use @nestjs/jwt - 10 common examples

To help you get started, we’ve selected a few @nestjs/jwt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github mpcast / mpcast-server / packages / core / dist / service / service.module.js View on Github external
user_service_1.UserService,
];
let ServiceModule = class ServiceModule {
    async onModuleInit() {
    }
};
ServiceModule = __decorate([
    common_1.Module({
        imports: [
            event_bus_module_1.EventBusModule,
            typeorm_1.TypeOrmModule.forRoot(config_helpers_1.getConfig().dbConnectionOptions),
            cache_module_1.CacheModule,
            passport_1.PassportModule.register({
                defaultStrategy: 'jwt',
            }),
            jwt_1.JwtModule.register({
                secretOrPrivateKey: APP_CONFIG.AUTH.jwtTokenSecret,
                signOptions: { expiresIn: APP_CONFIG.AUTH.expiresIn },
            }),
        ],
        providers: [
            ...exportedProviders,
            password_ciper_1.PasswordCiper,
        ],
        exports: exportedProviders,
    })
], ServiceModule);
exports.ServiceModule = ServiceModule;
//# sourceMappingURL=service.module.js.map
github ahmetuysal / nest-hackathon-starter / src / auth / auth.module.ts View on Github external
import { MailSenderModule } from '../mail-sender/mail-sender.module';
import { EmailVerification } from './email-verification.entity';
import { EmailChange } from './email-change.entity';
import { PasswordReset } from './password-reset.entity';

@Module({
  imports: [
    TypeOrmModule.forFeature([
      User,
      EmailVerification,
      EmailChange,
      PasswordReset,
    ]),
    UserModule,
    PassportModule.register({ defaultStrategy: 'jwt' }),
    JwtModule.register({
      secret: config.jwt.secretOrKey,
      signOptions: {
        expiresIn: config.jwt.expiresIn,
      },
    }),
    MailSenderModule,
  ],
  providers: [AuthService, JwtStrategy],
  controllers: [AuthController],
})
export class AuthModule {}
github TimurRK / nestjs-example / src / oauth / oauth.module.ts View on Github external
import { OAuthStrategy } from './oauth.strategy';

import { UserModule } from '../core/user/user.module';
import { AuthModule } from './auth/auth.module';
import { ClientModule } from './client/client.module';

const jwtSettings = config.get('JWT_SETTINGS');

@Module({
  imports: [
    ClientModule,
    AuthModule,
    forwardRef(() => UserModule),
    forwardRef(() => DatabaseModule),
    PassportModule.register({ defaultStrategy: 'jwt' }),
    JwtModule.register({
      secretOrPrivateKey: jwtSettings.secretKey,
      signOptions: {
        expiresIn: jwtSettings.expiresIn,
      },
    }),
  ],
  providers: [
    OAuthService,
    OAuthStrategy,
    {
      provide: LoggerService,
      useValue: new LoggerService('OAuthController'),
    },
  ],
  controllers: [OAuthController],
  exports: [ClientModule, AuthModule],
github awesome-graphql-space / lina / src / server / auth / auth.module.ts View on Github external
import { Module } from '@nestjs/common';
import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt';
import { AuthService } from './auth.service';
import { HttpStrategy } from './http.strategy';
import { AuthController } from './auth.controller';
import { JwtStrategy } from './jwt.strategy';
import { UsersModule } from './../users/users.module';
import * as passport from 'passport';

@Module({
  imports: [
    PassportModule.register({ defaultStrategy: 'jwt' }),
    JwtModule.register({
      secretOrPrivateKey: 'secretKey',
      signOptions: {
        expiresIn: 3600,
      },
    }),
    UsersModule,
  ],
  controllers: [AuthController],
  providers: [
    AuthService,
    JwtStrategy,
    HttpStrategy,
  ],
})
export class AuthModule {}
github dzzzzzy / Nestjs-Learning / demo / todo / src / feature / auth / auth.module.ts View on Github external
import { Module, forwardRef } from '@nestjs/common';
import { AuthService } from './auth.service';
import { AuthController } from './auth.controller';
import { JwtStrategy } from './jwt.strategy';
import { PassportModule } from '@nestjs/passport';
import { JwtModule } from '@nestjs/jwt';
import { UsersModule } from '../users/users.module';

@Module({
  imports: [
    PassportModule.register({ defaultStrategy: 'jwt' }),
    JwtModule.register({
      secretOrPrivateKey: 'secretKey',
      signOptions: {
        expiresIn: 3600,
      },
    }),
    forwardRef(() => UsersModule),
  ],
  controllers: [AuthController],
  providers: [AuthService, JwtStrategy],
  exports: [PassportModule, AuthService],
})
export class AuthModule {}
github surmon-china / nodepress / src / modules / auth / auth.module.ts View on Github external
*/

import * as APP_CONFIG from '@app/app.config';
import * as jwt from 'jsonwebtoken';
import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { AuthController } from './auth.controller';
import { AuthProvider } from './auth.model';
import { AuthService } from './auth.service';
import { JwtStrategy } from './jwt.strategy';

@Module({
  imports: [
    PassportModule.register({ defaultStrategy: 'jwt' }),
    JwtModule.register({
      privateKey: APP_CONFIG.AUTH.jwtTokenSecret as jwt.Secret,
      signOptions: {
        expiresIn: APP_CONFIG.AUTH.expiresIn as number,
      },
    }),
  ],
  controllers: [AuthController],
  providers: [AuthProvider, AuthService, JwtStrategy],
  exports: [AuthService],
})
export class AuthModule {}
github fivethree-team / nestjs-prisma-starter / src / resolvers / auth / auth.module.ts View on Github external
import { PasswordService } from './../../services/password.service';
import { GqlAuthGuard } from '../../guards/gql-auth.guard';
import { PrismaModule } from '../../prisma/prisma.module';
import { AuthService } from '../../services/auth.service';
import { AuthResolver } from './auth.resolver';
import { Module } from '@nestjs/common';
import { JwtModule } from '@nestjs/jwt';
import { PassportModule } from '@nestjs/passport';
import { JwtStrategy } from './jwt.strategy';
import { authConstants } from './../../common/auth/constants';

@Module({
  imports: [
    PassportModule.register({ defaultStrategy: 'jwt' }),
    JwtModule.register({
      secret: authConstants.jwtSecret
    }),
    PrismaModule
  ],
  providers: [
    AuthService,
    AuthResolver,
    JwtStrategy,
    GqlAuthGuard,
    PasswordService
  ],
  exports: [GqlAuthGuard]
})
export class AuthModule {}
github mpcast / mpcast-server / packages / core / src / service / service.module.ts View on Github external
CommentService,
    UserService,
];

/**
 * 系统中所有业务服务的提供者
 */
@Module({
    imports: [
        EventBusModule,
        TypeOrmModule.forRoot(getConfig().dbConnectionOptions),
        CacheModule,
        PassportModule.register({
            defaultStrategy: 'jwt',
        }),
        JwtModule.register({
            secretOrPrivateKey: APP_CONFIG.AUTH.jwtTokenSecret as string,
            signOptions: { expiresIn: APP_CONFIG.AUTH.expiresIn } as object,
        }),
    ],

    providers: [
        ...exportedProviders,
        PasswordCiper,
    ],
    exports: exportedProviders,
})
export class ServiceModule implements OnModuleInit {
    constructor(
        private optionService: OptionService,
    ) {
    }

@nestjs/jwt

Nest - modern, fast, powerful node.js web framework (@jwt)

MIT
Latest version published 1 year ago

Package Health Score

82 / 100
Full package analysis