Created
August 14, 2018 05:24
-
-
Save makemek/a44e0549237e1969698052868ffc309c to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Get, Controller, Render } from '@nestjs/common' | |
import { Module } from '@nestjs/common' | |
import { FastifyAdapter, NestFactory } from '@nestjs/core' | |
import * as hbs from 'handlebars' | |
@Controller() | |
class AppController { | |
@Get() | |
@Render('bad.handlebars') | |
root() { | |
return {} | |
} | |
} | |
@Module({ | |
imports: [], | |
controllers: [AppController], | |
providers: [], | |
}) | |
class AppModule {} | |
async function bootstrap() { | |
const app = await NestFactory.create(AppModule, new FastifyAdapter()) | |
hbs.registerHelper({ | |
boom: () => { | |
console.log('Running bad helper'); | |
// something went wrong | |
throw new Error('boom') | |
} | |
}) | |
app.setViewEngine({ | |
engine: { | |
handlebars: hbs, | |
}, | |
templates: __dirname, | |
}) | |
await app.listen(3000) | |
} | |
bootstrap() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name": "repli-nest-fastify", | |
"version": "1.0.0", | |
"description": "", | |
"main": "index.js", | |
"scripts": { | |
"start": "ts-node -r tsconfig-paths/register main.ts" | |
}, | |
"keywords": [], | |
"author": "", | |
"license": "ISC", | |
"dependencies": { | |
"@nestjs/common": "^5.0.0", | |
"@nestjs/core": "^5.0.0", | |
"fastify": "^1.9.0", | |
"fastify-formbody": "^2.0.0", | |
"point-of-view": "^1.1.0", | |
"reflect-metadata": "^0.1.12", | |
"rxjs": "^6.0.0", | |
"typescript": "^2.6.2" | |
}, | |
"devDependencies": { | |
"@types/handlebars": "^4.0.39", | |
"handlebars": "^4.0.11", | |
"ts-node": "^7.0.1", | |
"tsconfig-paths": "^3.5.0" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"compilerOptions": { | |
"module": "commonjs", | |
"declaration": false, | |
"noImplicitAny": false, | |
"removeComments": true, | |
"noLib": false, | |
"allowSyntheticDefaultImports": true, | |
"emitDecoratorMetadata": true, | |
"experimentalDecorators": true, | |
"target": "es6", | |
"sourceMap": true, | |
"allowJs": true, | |
"outDir": "./dist", | |
"baseUrl": "./src" | |
}, | |
"include": [ | |
"src/**/*" | |
], | |
"exclude": [ | |
"node_modules", | |
"**/*.spec.ts" | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment