add host, port to config, rename session
This commit is contained in:
parent
b4befa02fc
commit
6195f879db
15
src/main.ts
15
src/main.ts
@ -10,20 +10,22 @@ import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||
import { NestExpressApplication } from '@nestjs/platform-express';
|
||||
import { AdminApiModule } from './modules/api/admin/admin.module';
|
||||
import { OAuth2RouterModule } from './modules/static-front-end/oauth2-router/oauth2-router.module';
|
||||
import { ConfigurationService } from './modules/config/config.service';
|
||||
|
||||
dotenv.config();
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create<NestExpressApplication>(AppModule);
|
||||
const config = app.get(ConfigurationService);
|
||||
|
||||
const config = new DocumentBuilder()
|
||||
const docBuilder = new DocumentBuilder()
|
||||
.setTitle('Icy Network Authentication Server')
|
||||
.setDescription('Central authentication and management server')
|
||||
.setVersion('1.0')
|
||||
.addTag('admin')
|
||||
.addTag('oauth2')
|
||||
.build();
|
||||
const document = SwaggerModule.createDocument(app, config, {
|
||||
const document = SwaggerModule.createDocument(app, docBuilder, {
|
||||
include: [AdminApiModule, OAuth2RouterModule],
|
||||
});
|
||||
SwaggerModule.setup('api', app, document);
|
||||
@ -47,7 +49,8 @@ async function bootstrap() {
|
||||
app.use(
|
||||
/\/((?!api).)*/,
|
||||
session({
|
||||
secret: process.env.SESSION_SECRET,
|
||||
name: config.get<string>('app.session_name'),
|
||||
secret: config.get<string>('app.session_secret'),
|
||||
resave: true,
|
||||
saveUninitialized: false,
|
||||
store: new RedisStore({ client: redisClient }),
|
||||
@ -65,8 +68,10 @@ async function bootstrap() {
|
||||
app.setViewEngine('pug');
|
||||
|
||||
await app.listen(
|
||||
parseInt(process.env.NEST_PORT, 10) || 3000,
|
||||
process.env.NEST_HOST || '0.0.0.0',
|
||||
parseInt(process.env.NEST_PORT, 10) ||
|
||||
config.get<number>('app.port') ||
|
||||
3000,
|
||||
process.env.NEST_HOST || config.get<string>('app.host') || '0.0.0.0',
|
||||
);
|
||||
}
|
||||
bootstrap();
|
||||
|
@ -17,6 +17,9 @@ export const configProviders: Provider<any>[] = [
|
||||
useValue: {
|
||||
app: {
|
||||
base_url: 'http://localhost:3000',
|
||||
host: '0.0.0.0',
|
||||
port: 3000,
|
||||
session_name: '__sid',
|
||||
// generate the following with crypto.randomBytes(256 / 8).toString('hex')
|
||||
session_secret: 'change me!',
|
||||
challenge_secret: 'change me!',
|
||||
@ -46,11 +49,11 @@ export const configProviders: Provider<any>[] = [
|
||||
username: 'root',
|
||||
password: 'root',
|
||||
database: 'icyauth',
|
||||
entities: [__dirname + '/../**/*.entity{.ts,.js}'],
|
||||
entities: ['dist/**/*.entity.js'],
|
||||
synchronize: true,
|
||||
migrations: ['migration/*.js'],
|
||||
migrations: ['dist/migration/*.js'],
|
||||
cli: {
|
||||
migrationsDir: 'migration',
|
||||
migrationsDir: 'src/migration',
|
||||
},
|
||||
},
|
||||
} as Configuration,
|
||||
|
Reference in New Issue
Block a user