Skip to content

Commit

Permalink
fix(core): mark Module as Global
Browse files Browse the repository at this point in the history
Fixes #106

Signed-off-by: Will Soto <[email protected]>
  • Loading branch information
willsoto committed Jun 7, 2019
1 parent 2581b45 commit 6042ce9
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/core.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DynamicModule, Provider } from "@nestjs/common";
/* eslint-disable new-cap */
import { DynamicModule, Global, Module, Provider } from "@nestjs/common";
import Knex from "knex";
import { Model } from "objection";
import {
Expand All @@ -13,10 +14,11 @@ import {
ObjectionModuleOptionsFactory
} from "./interfaces";

@Global()
@Module({})
export class ObjectionCoreModule {
public static forRoot(options: ObjectionModuleOptions): DynamicModule {
const BaseModel = options.Model || Model;
// eslint-disable-next-line new-cap
const connection = Knex(options.config);

BaseModel.knex(connection);
Expand Down Expand Up @@ -54,7 +56,6 @@ export class ObjectionCoreModule {
provide: KNEX_CONNECTION,
inject: [OBJECTION_MODULE_OPTIONS],
useFactory(objectionModuleOptions: ObjectionModuleOptions): Knex {
// eslint-disable-next-line new-cap
return Knex(objectionModuleOptions.config);
}
};
Expand Down
2 changes: 1 addition & 1 deletion lib/module.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
/* eslint-disable new-cap */
import { DynamicModule, Module } from "@nestjs/common";
import { ObjectionCoreModule } from "./core";
import {
ObjectionModuleAsyncOptions,
ObjectionModuleOptions
} from "./interfaces";

// eslint-disable-next-line new-cap
@Module({})
export class ObjectionModule {
public static forRoot(options: ObjectionModuleOptions): DynamicModule {
Expand Down

0 comments on commit 6042ce9

Please sign in to comment.