【发布时间】:2019-11-24 15:13:20
【问题描述】:
我想弄清楚如何使用我的 ConfigService created as described here。在我的应用程序的最顶层。
我的main.js 文件如下所示:
import { NestFactory } from '@nestjs/core';
import { TypeormStore } from 'connect-typeorm';
import * as session from 'express-session';
import { getRepository } from 'typeorm';
import { Session } from '../../domains/session/Session';
import { AppModule } from './AppModule';
async function bootstrap() {
const app = await NestFactory.create(AppModule);
app.use(session({
resave: false,
saveUninitialized: false,
store: new TypeormStore({
cleanupLimit: 2,
ttl: 86400
}).connect(getRepository(Session)),
secret: process.env.COOKIE_SECRET as string
}))
await app.listen(3000);
}
bootstrap();
我想要将process.env.COOKIE_SECRET 移动到ConfigService 内的吸气剂。我可以访问此级别的服务吗?
【问题讨论】:
标签: javascript typescript middleware nestjs