mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-28 11:21:18 +00:00
40 lines
1.3 KiB
TypeScript
40 lines
1.3 KiB
TypeScript
import { DynamicModule, Module } from "@nestjs/common";
|
|
|
|
import { IamBaselineSeeder } from "./iam-baseline.seeder";
|
|
import { IAM_SEED_OPTIONS } from "./iam-seed.constants";
|
|
import { IamSeedOptions } from "./iam-seed.types";
|
|
|
|
/**
|
|
* Provides `IamBaselineSeeder`. The app calls `run()` itself — usually from
|
|
* `onApplicationBootstrap`, after whatever seeder creates the organization the
|
|
* super admin attaches to.
|
|
*
|
|
* IamSeedModule.forRoot({
|
|
* superAdmin: {
|
|
* username: "superadmin",
|
|
* name: { am: "ሱፐር አድሚን", en: "Super Admin" },
|
|
* roleKey: "super_admin",
|
|
* organizationKey: "edr_freight",
|
|
* unitKey: "edr_freight_app",
|
|
* fallbackEmail: "superadmin@tria.com",
|
|
* },
|
|
* })
|
|
*
|
|
* Any section left out keeps the value from `DEFAULT_IAM_BASELINE_SEED`. The
|
|
* seeder needs a TypeORM `DataSource` that can reach the `iam` schema; the app's
|
|
* default one is used, so `TypeOrmModule.forRoot*` must be registered.
|
|
*/
|
|
@Module({})
|
|
export class IamSeedModule {
|
|
static forRoot(options: IamSeedOptions = {}): DynamicModule {
|
|
return {
|
|
module: IamSeedModule,
|
|
providers: [
|
|
{ provide: IAM_SEED_OPTIONS, useValue: options },
|
|
IamBaselineSeeder,
|
|
],
|
|
exports: [IamBaselineSeeder],
|
|
};
|
|
}
|
|
}
|