This is how my app.module.ts of my nestJS looks like:
@Module({
imports: [
ConfigModule.forRoot({ envFilePath: root + '.env' }),
GraphQLModule.forRoot<ApolloDriverConfig>({
driver: ApolloDriver,
cors: {
credentials: true,
origin: process.env.ORIGIN // <--
}
})
],
controllers: [AppController]
})
As the GraphQLModule parameter object gets a bit more complex, I would like to refactor it to a config function.
export default () => ({
driver: ApolloDriver,
cors: {
credentials: true,
origin: process.env.ORIGIN // <--
}
});
@Module({
imports: [
ConfigModule.forRoot({ envFilePath: root + '.env' }),
GraphQLModule.forRoot<ApolloDriverConfig>(graphQLConfig)
],
controllers: [AppController]
})
But how do I get access to the process.env variables which I imported within the ConfigModule envFilePath?