Skip to content

Commit a7e280e

Browse files
authored
Merge pull request #91 from w3tecch/feature/update_dependencies
Feature/update dependencies
2 parents cf5bce8 + 20d8466 commit a7e280e

File tree

11 files changed

+1093
-653
lines changed

11 files changed

+1093
-653
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,7 +156,7 @@ All script are defined in the `package-scripts.js` file, but the most important
156156

157157
### Database Migration
158158

159-
- Run `typeorm migrations:create -n <migration-file-name>` to create a new migration file.
159+
- Run `typeorm migration:create -n <migration-file-name>` to create a new migration file.
160160
- Try `typeorm -h` to see more useful cli commands like generating migration out of your models.
161161
- To migrate your database run `npm start db.migrate`.
162162
- To revert your latest migration run `npm start db.revert`.

package-scripts.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -124,15 +124,15 @@ module.exports = {
124124
script: series(
125125
'nps banner.migrate',
126126
'nps config',
127-
runFast('./node_modules/typeorm/cli.js migrations:run')
127+
runFast('./node_modules/typeorm/cli.js migration:run')
128128
),
129129
description: 'Migrates the database to newest version available'
130130
},
131131
revert: {
132132
script: series(
133133
'nps banner.revert',
134134
'nps config',
135-
runFast('./node_modules/typeorm/cli.js migrations:revert')
135+
runFast('./node_modules/typeorm/cli.js migration:revert')
136136
),
137137
description: 'Downgrades the database'
138138
},
@@ -267,11 +267,11 @@ function copy(source, target) {
267267
}
268268

269269
function run(path) {
270-
return `ts-node --typeCheck ${path}`;
270+
return `ts-node ${path}`;
271271
}
272272

273273
function runFast(path) {
274-
return `ts-node ${path}`;
274+
return `ts-node --transpileOnly ${path}`;
275275
}
276276

277277
function tslint(path) {

package.json

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -49,21 +49,21 @@
4949
"@types/helmet": "^0.0.37",
5050
"@types/lodash": "^4.14.80",
5151
"@types/morgan": "^1.7.35",
52-
"@types/reflect-metadata": "0.0.5",
52+
"@types/reflect-metadata": "0.1.0",
5353
"@types/request": "^2.0.8",
5454
"@types/serve-favicon": "^2.2.29",
5555
"@types/supertest": "^2.0.4",
5656
"@types/uuid": "^3.4.3",
5757
"@types/winston": "^2.3.7",
5858
"body-parser": "^1.18.2",
5959
"chalk": "^2.3.0",
60-
"class-validator": "^0.7.3",
60+
"class-validator": "^0.8.5",
6161
"commander": "^2.11.0",
6262
"compression": "^1.7.1",
63-
"copyfiles": "^1.2.0",
63+
"copyfiles": "^2.0.0",
6464
"cors": "^2.8.4",
6565
"dataloader": "^1.3.0",
66-
"dotenv": "^4.0.0",
66+
"dotenv": "^5.0.1",
6767
"event-dispatch": "^0.4.1",
6868
"express": "^4.16.2",
6969
"express-basic-auth": "^1.1.3",
@@ -72,7 +72,7 @@
7272
"faker": "^4.1.0",
7373
"figlet": "^1.2.0",
7474
"glob": "^7.1.2",
75-
"graphql": "^0.11.7",
75+
"graphql": "^0.13.2",
7676
"helmet": "^3.9.0",
7777
"jsonfile": "^4.0.0",
7878
"lodash": "^4.17.4",
@@ -88,13 +88,13 @@
8888
"routing-controllers": "^0.7.6",
8989
"serve-favicon": "^2.4.5",
9090
"supertest": "^3.0.0",
91-
"swagger-ui-express": "^2.0.10",
92-
"ts-node": "^3.3.0",
91+
"swagger-ui-express": "^3.0.8",
92+
"ts-node": "^6.0.0",
9393
"tslint": "^5.8.0",
94-
"typedi": "^0.5.2",
95-
"typeorm": "^0.1.3",
96-
"typeorm-typedi-extensions": "^0.1.1",
97-
"typescript": "2.6.2",
94+
"typedi": "^0.7.2",
95+
"typeorm": "^0.2.1",
96+
"typeorm-typedi-extensions": "^0.2.1",
97+
"typescript": "2.8.3",
9898
"uuid": "^3.1.0",
9999
"winston": "^2.4.0"
100100
},
@@ -114,14 +114,14 @@
114114
},
115115
"license": "MIT",
116116
"devDependencies": {
117-
"@types/jest": "^21.1.5",
118-
"@types/nock": "^8.2.1",
117+
"@types/jest": "^22.2.3",
118+
"@types/nock": "^9.1.3",
119119
"cross-env": "^5.1.1",
120-
"jest": "^21.2.1",
120+
"jest": "^22.4.3",
121121
"mock-express-request": "^0.2.0",
122122
"mock-express-response": "^0.2.1",
123123
"nock": "^9.1.4",
124-
"sqlite3": "^3.1.13",
125-
"ts-jest": "^21.1.4"
124+
"sqlite3": "^4.0.0",
125+
"ts-jest": "^22.4.4"
126126
}
127127
}

src/api/services/PetService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,10 @@ export class PetService {
4949
return this.petRepository.save(pet);
5050
}
5151

52-
public delete(id: string): Promise<void> {
52+
public async delete(id: string): Promise<void> {
5353
this.log.info('Delete a pet');
54-
return this.petRepository.removeById(id);
54+
await this.petRepository.delete(id);
55+
return;
5556
}
5657

5758
}

src/api/services/UserService.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,10 @@ export class UserService {
3939
return this.userRepository.save(user);
4040
}
4141

42-
public delete(id: string): Promise<void> {
42+
public async delete(id: string): Promise<void> {
4343
this.log.info('Delete a user');
44-
return this.userRepository.removeById(id);
44+
await this.userRepository.delete(id);
45+
return;
4546
}
4647

4748
}

src/auth/AuthService.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import * as express from 'express';
22
import * as request from 'request';
3-
import { Require, Service } from 'typedi';
3+
import { Service } from 'typedi';
44

55
import { Logger, LoggerInterface } from '../decorators/Logger';
66
import { env } from '../env';
@@ -12,10 +12,9 @@ export class AuthService {
1212
private httpRequest: typeof request;
1313

1414
constructor(
15-
@Require('request') r: any,
1615
@Logger(__filename) private log: LoggerInterface
1716
) {
18-
this.httpRequest = r;
17+
this.httpRequest = request;
1918
}
2019

2120
public parseTokenFromRequest(req: express.Request): string | undefined {

src/database/migrations/1511105183653-CreateUserTable.ts

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,36 @@ import { MigrationInterface, QueryRunner, Table } from 'typeorm';
33
export class CreateUserTable1511105183653 implements MigrationInterface {
44

55
public async up(queryRunner: QueryRunner): Promise<any> {
6-
const table = new Table('user', [
7-
{
8-
name: 'id',
9-
type: 'varchar',
10-
length: 255,
11-
isPrimary: true,
12-
isNullable: false,
13-
}, {
14-
name: 'first_name',
15-
type: 'varchar',
16-
length: 255,
17-
isPrimary: false,
18-
isNullable: false,
19-
}, {
20-
name: 'last_name',
21-
type: 'varchar',
22-
length: 255,
23-
isPrimary: false,
24-
isNullable: false,
25-
}, {
26-
name: 'email',
27-
type: 'varchar',
28-
length: 255,
29-
isPrimary: false,
30-
isNullable: false,
31-
},
32-
]);
6+
const table = new Table({
7+
name: 'user',
8+
columns: [
9+
{
10+
name: 'id',
11+
type: 'varchar',
12+
length: '255',
13+
isPrimary: true,
14+
isNullable: false,
15+
}, {
16+
name: 'first_name',
17+
type: 'varchar',
18+
length: '255',
19+
isPrimary: false,
20+
isNullable: false,
21+
}, {
22+
name: 'last_name',
23+
type: 'varchar',
24+
length: '255',
25+
isPrimary: false,
26+
isNullable: false,
27+
}, {
28+
name: 'email',
29+
type: 'varchar',
30+
length: '255',
31+
isPrimary: false,
32+
isNullable: false,
33+
},
34+
],
35+
});
3336
await queryRunner.createTable(table);
3437
}
3538

src/database/migrations/1512663524808-CreatePetTable.ts

Lines changed: 30 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -3,33 +3,36 @@ import { MigrationInterface, QueryRunner, Table } from 'typeorm';
33
export class CreatePetTable1512663524808 implements MigrationInterface {
44

55
public async up(queryRunner: QueryRunner): Promise<any> {
6-
const table = new Table('pet', [
7-
{
8-
name: 'id',
9-
type: 'varchar',
10-
length: 255,
11-
isPrimary: true,
12-
isNullable: false,
13-
}, {
14-
name: 'name',
15-
type: 'varchar',
16-
length: 255,
17-
isPrimary: false,
18-
isNullable: false,
19-
}, {
20-
name: 'age',
21-
type: 'int',
22-
length: 11,
23-
isPrimary: false,
24-
isNullable: false,
25-
}, {
26-
name: 'user_id',
27-
type: 'varchar',
28-
length: 255,
29-
isPrimary: false,
30-
isNullable: true,
31-
},
32-
]);
6+
const table = new Table({
7+
name: 'pet',
8+
columns: [
9+
{
10+
name: 'id',
11+
type: 'varchar',
12+
length: '255',
13+
isPrimary: true,
14+
isNullable: false,
15+
}, {
16+
name: 'name',
17+
type: 'varchar',
18+
length: '255',
19+
isPrimary: false,
20+
isNullable: false,
21+
}, {
22+
name: 'age',
23+
type: 'int',
24+
length: '11',
25+
isPrimary: false,
26+
isNullable: false,
27+
}, {
28+
name: 'user_id',
29+
type: 'varchar',
30+
length: '255',
31+
isPrimary: false,
32+
isNullable: true,
33+
},
34+
],
35+
});
3336
await queryRunner.createTable(table);
3437
}
3538

src/database/migrations/1512663990063-AddUserRelationToPetTable.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@ import { MigrationInterface, QueryRunner, TableForeignKey } from 'typeorm';
22

33
export class AddUserRelationToPetTable1512663990063 implements MigrationInterface {
44

5-
private tableForeignKey = new TableForeignKey(
6-
'fk_user_pet',
7-
['user_id'],
8-
['id'],
9-
'user',
10-
''
11-
);
5+
private tableForeignKey = new TableForeignKey({
6+
name: 'fk_user_pet',
7+
columnNames: ['user_id'],
8+
referencedColumnNames: ['id'],
9+
referencedTableName: 'user',
10+
onDelete: 'CASCADE',
11+
});
1212

1313
public async up(queryRunner: QueryRunner): Promise<any> {
1414
await queryRunner.createForeignKey('pet', this.tableForeignKey);

test/unit/auth/AuthService.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ describe('AuthService', () => {
1313
let log: LogMock;
1414
beforeEach(() => {
1515
log = new LogMock();
16-
authService = new AuthService(request, log);
16+
authService = new AuthService(log);
1717
});
1818

1919
describe('parseTokenFromRequest', () => {

0 commit comments

Comments
 (0)