mirror of
https://github.com/nestjs/nest.git
synced 2026-02-21 23:11:44 +00:00
sample(@nestjs) move public and views dirs outside of the src
This commit is contained in:
2220
sample/15-mvc/package-lock.json
generated
2220
sample/15-mvc/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
0
sample/15-mvc/public/.gitkeep
Normal file
0
sample/15-mvc/public/.gitkeep
Normal file
@@ -1,11 +1,12 @@
|
||||
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(__dirname + '/public');
|
||||
app.setBaseViewsDir(__dirname + '/views');
|
||||
app.useStaticAssets(join(__dirname + './../public'));
|
||||
app.setBaseViewsDir(join(__dirname + './../views'));
|
||||
app.setViewEngine('hbs');
|
||||
|
||||
await app.listen(3000);
|
||||
|
||||
2564
sample/17-mvc-fastify/package-lock.json
generated
2564
sample/17-mvc-fastify/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
0
sample/17-mvc-fastify/public/.gitkeep
Normal file
0
sample/17-mvc-fastify/public/.gitkeep
Normal file
@@ -1,18 +1,18 @@
|
||||
import { NestFactory, FastifyAdapter } from '@nestjs/core';
|
||||
import { ApplicationModule } from './app.module';
|
||||
import { FastifyAdapter, NestFactory } from '@nestjs/core';
|
||||
import { join } from 'path';
|
||||
import { ApplicationModule } from './app.module';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(ApplicationModule, new FastifyAdapter());
|
||||
app.useStaticAssets({
|
||||
root: join(__dirname, 'public'),
|
||||
root: join(__dirname, './../public'),
|
||||
prefix: '/public/',
|
||||
});
|
||||
app.setViewEngine({
|
||||
engine: {
|
||||
handlebars: require('handlebars'),
|
||||
},
|
||||
templates: join(__dirname, 'views'),
|
||||
templates: join(__dirname, './../views'),
|
||||
});
|
||||
await app.listen(3000);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user