Nest JS和Stencil

时间:2018-09-15 20:17:03

标签: javascript nestjs stenciljs

我正在学习Nest Framework,我想在Fron-End中添加Stencil JS。 我该如何做才能使服务器端代表模板js?

MVC在Nest中的实现是:

import { NestFactory } from '@nestjs/core';
import { join } from 'path';
import { ApplicationModule } from './app.module';

async function bootstrap() {
const app = await NestFactory.create(ApplicationModule);

app.useStaticAssets(join(__dirname, '..', 'public'));
app.setBaseViewsDir(join(__dirname, '..', 'views'));
app.setViewEngine('hbs');

await app.listen(3000);
}
bootstrap();

模板中的SSR是:

const express = require('express');
const stencil = require('@stencil/core/server');

// create the express app
const app = express();

// load the stencil config and
// express serve-side rendering middleware
const { wwwDir, logger } = stencil.initApp({
  app: app,
  configPath: __dirname
});

// serve static files
app.use(express.static(wwwDir));

// set which port express it will be listening on
const port = 3030;

// start listening and handling requests
app.listen(port, () => logger.info(`server-side rendering listening on port

我可以合并这些代码吗?

0 个答案:

没有答案