Skip to content

Commit

Permalink
chore(knex): upgrade to v0.95.x of Knex
Browse files Browse the repository at this point in the history
BREAKING CHANGE: Knex typings have changed a lot, so probably breaking for people
until they upgrade

Signed-off-by: Will Soto <willsoto@users.noreply.github.com>
  • Loading branch information
willsoto committed Mar 13, 2021
1 parent 5cc017a commit c8dc357
Show file tree
Hide file tree
Showing 9 changed files with 146 additions and 3,002 deletions.
3,119 changes: 133 additions & 2,986 deletions package-lock.json

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@
"eslint-config-prettier": "~8.1.0",
"eslint-plugin-mocha": "~8.1.0",
"husky": "4",
"knex": "~0.21.5",
"knex": "~0.95.2",
"lint-staged": "~10.5.4",
"markdown-toc": "~1.2.0",
"mocha": "~8.3.2",
Expand All @@ -155,7 +155,7 @@
"peerDependencies": {
"@nestjs/common": "^7.0.0",
"@nestjs/core": "^7.0.0",
"knex": ">=0.16.0",
"knex": ">=0.95.0",
"objection": "^2.0.0"
},
"volta": {
Expand Down
6 changes: 3 additions & 3 deletions src/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
ValueProvider,
} from "@nestjs/common";
import { ModuleRef } from "@nestjs/core";
import * as Knex from "knex";
import { knex, Knex } from "knex";
import { Model } from "objection";
import {
KNEX_CONNECTION,
Expand All @@ -34,7 +34,7 @@ export class ObjectionCoreModule implements OnApplicationShutdown {

public static register(options: ObjectionModuleOptions): DynamicModule {
const BaseModel = options.Model || Model;
const connection = Knex(options.config);
const connection = knex(options.config);

BaseModel.knex(connection);

Expand Down Expand Up @@ -73,7 +73,7 @@ export class ObjectionCoreModule implements OnApplicationShutdown {
provide: connectionToken,
inject: [OBJECTION_MODULE_OPTIONS],
useFactory(objectionModuleOptions: ObjectionModuleOptions): Knex {
return Knex(objectionModuleOptions.config);
return knex(objectionModuleOptions.config);
},
};

Expand Down
2 changes: 1 addition & 1 deletion src/interfaces.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Type } from "@nestjs/common";
import { ModuleMetadata } from "@nestjs/common/interfaces";
import * as Knex from "knex";
import { Knex } from "knex";
import { Model } from "objection";
export interface ObjectionModuleOptions {
/**
Expand Down
2 changes: 1 addition & 1 deletion test/core.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Injectable } from "@nestjs/common";
import { Test, TestingModule } from "@nestjs/testing";
import { expect } from "chai";
import * as Knex from "knex";
import { Knex } from "knex";
import { Model } from "objection";
import * as sinon from "sinon";
import {
Expand Down
2 changes: 1 addition & 1 deletion test/fixtures.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Inject, Injectable, Module } from "@nestjs/common";
import * as Knex from "knex";
import { Knex } from "knex";
import { Model } from "objection";
import { Connection, KNEX_CONNECTION, ObjectionModule } from "../src";
@Injectable()
Expand Down
8 changes: 2 additions & 6 deletions test/integration.spec.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
/* eslint-disable new-cap */
import { Test, TestingModule } from "@nestjs/testing";
import { expect } from "chai";
import * as Knex from "knex";
import { Knex } from "knex";
import { KNEX_CONNECTION } from "../src";
import { ConnectionCheck, ConnectionModule } from "./fixtures";

describe("Integration", function () {
let connectionCheck: ConnectionCheck;
let connection: Knex;
Expand All @@ -28,13 +29,8 @@ describe("Integration", function () {

it("the service is correctly initialized", function () {
expect(connectionCheck).to.be.ok;
});

it.skip("the connection correctly initialized", function () {
expect(connectionCheck.connection).to.be.ok;
});

it.skip("#pingCheck", function () {
return expect(connectionCheck.pingCheck()).to.eventually.eql([{ "1": 1 }]);
});
});
2 changes: 1 addition & 1 deletion test/module.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Test, TestingModule } from "@nestjs/testing";
import { expect } from "chai";
import * as Knex from "knex";
import { Knex } from "knex";
import { Model } from "objection";
import { KNEX_CONNECTION } from "../src/constants";
import { ObjectionModule } from "../src/module";
Expand Down
3 changes: 2 additions & 1 deletion test/multiple-connections.spec.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
import { Test, TestingModule } from "@nestjs/testing";
import { expect } from "chai";
import * as Knex from "knex";
import { Knex } from "knex";
import { Model } from "objection";
import { ObjectionCoreModule } from "../src/core";

describe("when registering multiple connections", function () {
let testingModule: TestingModule;
let connection1: Knex;
Expand Down

0 comments on commit c8dc357

Please sign in to comment.