Skip to content

Commit

Permalink
fix: auto require reflect-metadata
Browse files Browse the repository at this point in the history
  • Loading branch information
cxtom committed Mar 29, 2021
1 parent a745e8c commit 935e55f
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 2 deletions.
7 changes: 6 additions & 1 deletion example/hoth-quickstart/src/controller/app/app.controller.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
import {Controller, GET, Hook} from '@hoth/decorators';
import {Controller, GET, Hook, Inject} from '@hoth/decorators';
import {FastifyReply, FastifyRequest} from 'fastify';
import Calculator from '../../lib/calculator/index.service';

@Controller('/app')
export default class AppController {

@Inject(Calculator)
private readonly service!: Calculator;

@Hook('preHandler')
async preHandler() {
console.log('in controller');
Expand All @@ -16,6 +20,7 @@ export default class AppController {
reply.log.warn('test error');
reply.log.addNotice('foo', 'test');
reply.log.addPerformance('foo', 1.3322);
console.log(this.service.add(1, 1));
reply.send('ok');
}
}
8 changes: 8 additions & 0 deletions example/hoth-quickstart/src/lib/calculator/index.service.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
import {Service} from '@hoth/decorators';

@Service()
export default class Calculator {
add(a: number, b: number) {
return a + b;
}
}
1 change: 1 addition & 0 deletions packages/decorators/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"homepage": "https://github.com/cxtom/hoth#readme",
"dependencies": {
"fastify-decorators": "~3.8.0",
"reflect-metadata": "^0.1.13",
"tslib": "^2.1.0"
},
"files": [
Expand Down
4 changes: 3 additions & 1 deletion packages/decorators/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
/* eslint-disable @typescript-eslint/no-require-imports, @typescript-eslint/no-var-requires */

import 'reflect-metadata';

import type {FastifyInstance} from 'fastify';
import type {AutoLoadConfig} from 'fastify-decorators/interfaces/bootstrap-config';

import type {AutoLoadConfig} from 'fastify-decorators/interfaces/bootstrap-config';
import {bootstrap as bootstrapInner} from 'fastify-decorators';

export {
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -5862,6 +5862,11 @@ redent@^3.0.0:
indent-string "^4.0.0"
strip-indent "^3.0.0"

reflect-metadata@^0.1.13:
version "0.1.13"
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.13.tgz#67ae3ca57c972a2aa1642b10fe363fe32d49dc08"
integrity sha512-Ts1Y/anZELhSsjMcU605fU9RE4Oi3p5ORujwbIKXfWa+0Zxs510Qrmrce5/Jowq3cHSZSJqBjypxmHarc+vEWg==

regenerator-runtime@^0.13.4:
version "0.13.7"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.7.tgz#cac2dacc8a1ea675feaabaeb8ae833898ae46f55"
Expand Down

0 comments on commit 935e55f

Please sign in to comment.