-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.module.ts
47 lines (45 loc) · 1.92 KB
/
app.module.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
import { Module, OnModuleInit } from '@nestjs/common';
import { HttpModule } from '@nestjs/axios';
import { AppController } from './app.controller';
import { AuthModule, AuthService, FacebookAdapter, GoogleAdapter, LinkedInAdapter } from 'quick-social-auth';
import { HttpService } from './http.service';
import 'dotenv/config';
import { DbAdapter } from './adapters/db.adapter';
import { UserRepository } from './user.repository';
import { UserController } from './user.controller';
@Module({
imports: [
HttpModule,
AuthModule.forRoot({
redirectUri: 'http://localhost:8080/dashboard.html',
authPath: '/auth/token'
})
],
controllers: [AppController, UserController],
providers: [HttpService, UserRepository]
})
export class AppModule implements OnModuleInit {
public constructor(
private readonly httpService: HttpService,
private readonly authService: AuthService,
private readonly userRepository: UserRepository
) { }
public onModuleInit(): void {
this.authService.addAdapter(new LinkedInAdapter({
clientId: process.env.AUTH_LINKEDIN_CLIENT_ID,
clientSecret: process.env.AUTH_LINKEDIN_CLIENT_SECRET,
redirectUri: process.env.AUTH_REDIRECT_URI
}, this.httpService));
this.authService.addAdapter(new GoogleAdapter({
clientId: process.env.AUTH_GOOGLE_CLIENT_ID,
clientSecret: process.env.AUTH_GOOGLE_CLIENT_SECRET,
redirectUri: process.env.AUTH_REDIRECT_URI
}, this.httpService));
this.authService.addAdapter(new FacebookAdapter({
appId: process.env.AUTH_FACEBOOK_CLIENT_ID,
appSecret: process.env.AUTH_FACEBOOK_CLIENT_SECRET,
redirectUri: process.env.AUTH_REDIRECT_URI
}, this.httpService));
this.authService.addAdapter(new DbAdapter({ jwtSecret: process.env.JWT_SECRET }, this.userRepository));
}
}