-
Notifications
You must be signed in to change notification settings - Fork 210
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Because: - We want to be able to leverage our nest services held in libs This Commit: - Initializes nest DI in hapi - Setups typeDi container with nest services - Switch over to using notfier service from libs - Switch over to using StatsD service from libs
- Loading branch information
Showing
11 changed files
with
603 additions
and
262 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/* This Source Code Form is subject to the terms of the Mozilla Public | ||
* License, v. 2.0. If a copy of the MPL was not distributed with this | ||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ | ||
|
||
import { Module } from '@nestjs/common'; | ||
import { NestFactory } from '@nestjs/core'; | ||
import { ConfigModule } from '@nestjs/config'; | ||
import { Container } from 'typedi'; | ||
import { MozLoggerService } from '@fxa/shared/mozlog'; | ||
import { | ||
LegacyStatsDProvider, | ||
StatsD, | ||
StatsDService, | ||
} from '@fxa/shared/metrics/statsd'; | ||
import { NotifierService, NotifierSnsFactory } from '@fxa/shared/notifier'; | ||
|
||
import config, { ConfigType } from '../config'; | ||
import { AppConfig } from './types'; | ||
|
||
@Module({ | ||
imports: [ | ||
ConfigModule.forRoot({ | ||
load: [(): ConfigType => config.getProperties()], | ||
isGlobal: true, | ||
}), | ||
], | ||
controllers: [], | ||
providers: [ | ||
MozLoggerService, | ||
NotifierSnsFactory, | ||
NotifierService, | ||
LegacyStatsDProvider, | ||
], | ||
}) | ||
export class AppModule {} | ||
|
||
export async function getAppModuleInstance() { | ||
return await NestFactory.createApplicationContext(AppModule); | ||
} | ||
|
||
export async function bridgeTypeDi() { | ||
const appInstance = await getAppModuleInstance(); | ||
|
||
// Setup type di container for backwards compatibility | ||
Container.set(AppConfig, config.getProperties()); | ||
Container.set(StatsD, appInstance.get(StatsDService)); | ||
Container.set(MozLoggerService, appInstance.resolve(MozLoggerService)); | ||
Container.set(NotifierService, appInstance.get(NotifierService)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.