Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
import { applyDomino } from '@nestjs/ng-universal';
// Import module map for lazy loading
import { provideModuleMap } from '@nguniversal/module-map-ngfactory-loader';
import { existsSync, mkdirSync, readFileSync, writeFileSync } from 'fs';
import { join } from 'path';
import { ROUTES } from './static.paths';
// Faster server renders w/ Prod mode (dev mode never needed)
enableProdMode();
const BROWSER_FOLDER = join(process.cwd(), 'browser');
// Load the index.html file containing references to your application bundle.
const indexPath = join('browser', 'index.html');
// Ensure that we mock Window|Document etc
applyDomino(global, indexPath);
// * NOTE :: leave this as require() since this file is built Dynamically from webpack
const {
AppServerModuleNgFactory,
LAZY_MODULE_MAP,
} = require('./dist/server/main');
let previousRender = Promise.resolve();
// Iterate each route path
ROUTES.forEach(route => {
const fullPath = join(BROWSER_FOLDER, route);
// Make sure the directory structure is there
if (!existsSync(fullPath)) {
mkdirSync(fullPath);
import { Module } from '@nestjs/common';
import { AngularUniversalModule, applyDomino } from '@nestjs/ng-universal';
import { join } from 'path';
import { AppController } from './app.controller';
import { AppService } from './app.service';
const BROWSER_DIR = join(process.cwd(), 'dist', 'apps', 'ng-test-app');
applyDomino(global, join(BROWSER_DIR, 'index.html'));
@Module({
imports: [
AngularUniversalModule.forRoot({
viewsPath: BROWSER_DIR,
bundle: require('../../../../dist/apps/ng-test-app-server/main'),
liveReload: true
})
],
controllers: [AppController],
providers: [AppService]
})
export class AppModule {}
import { Module } from '@nestjs/common';
import { join } from 'path';
import { AngularUniversalModule, applyDomino } from '@nestjs/ng-universal';
const BROWSER_DIR = join(process.cwd(), process.env.DYNO ? 'browser' : 'demo/dist/browser');
applyDomino(global, join(BROWSER_DIR, 'index.html'));
@Module({
imports: [
AngularUniversalModule.forRoot({
viewsPath: BROWSER_DIR,
bundle: require('./../../demo/dist/server/main.js')
})
]
})
export class ApplicationModule {}
import { Module } from '@nestjs/common';
import { AngularUniversalModule, applyDomino } from '@nestjs/ng-universal';
import { join } from 'path';
import { AppController } from './app.controller';
const BROWSER_DIR = join(process.cwd(), 'dist/browser');
applyDomino(global, join(BROWSER_DIR, 'index.html'));
@Module({
imports: [
AngularUniversalModule.forRoot({
viewsPath: BROWSER_DIR,
bundle: require('../server/main'),
liveReload: true,
}),
],
controllers: [AppController],
})
export class ApplicationModule {}
import { join } from 'path';
import { Module } from '@nestjs/common';
import { AngularUniversalModule, applyDomino } from '@nestjs/ng-universal';
import { TypeOrmModule } from '@nestjs/typeorm';
import { UserModule } from './modules/user/user.module';
import { AuthModule } from './modules/authentication/auth.module';
import * as databaseConfig from './environments/database';
const BROWSER_DIR = join(process.cwd(), 'dist/browser');
applyDomino(global, join(BROWSER_DIR, 'index.html'));
@Module({
imports: [
AngularUniversalModule.forRoot({
viewsPath: BROWSER_DIR,
bundle: require('../server/main.js'),
liveReload: true
}),
TypeOrmModule.forRoot(databaseConfig),
UserModule,
AuthModule
]
})
export class ApplicationModule {}
import { Module } from '@nestjs/common';
import { AngularUniversalModule, applyDomino } from '@nestjs/ng-universal';
import { join } from 'path';
const BROWSER_DIR = join(process.cwd(), 'dist', 'browser');
applyDomino(global, join(BROWSER_DIR, 'index.html'));
@Module({
imports: [
AngularUniversalModule.forRoot({
viewsPath: BROWSER_DIR,
bundle: require('../server/main'),
liveReload: true
})
]
})
export class ApplicationModule {}