Skip to content

Commit 1994f31

Browse files
author
hirsch88
committed
Update typescript libs
1 parent f94afeb commit 1994f31

File tree

9 files changed

+77
-229
lines changed

9 files changed

+77
-229
lines changed

package.json

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@
7878
"@types/jsonwebtoken": "^7.2.1",
7979
"@types/knex": "0.0.52",
8080
"@types/lodash": "^4.14.67",
81-
"@types/mkdirp": "^0.3.29",
8281
"@types/morgan": "^1.7.32",
8382
"@types/pluralize": "^0.0.27",
8483
"@types/reflect-metadata": "0.0.5",
@@ -106,11 +105,9 @@
106105
"inquirer": "^3.1.1",
107106
"inversify": "^4.1.1",
108107
"inversify-express-utils": "^3.5.1",
109-
"jest": "^20.0.3",
110108
"jsonwebtoken": "^7.4.1",
111109
"knex": "^0.12.0",
112110
"lodash": "^4.17.4",
113-
"mkdirp": "^0.5.1",
114111
"morgan": "^1.7.0",
115112
"mysql": "^2.13.0",
116113
"nodemon": "^1.11.0",
@@ -119,16 +116,12 @@
119116
"reflect-metadata": "^0.1.10",
120117
"request": "^2.81.0",
121118
"request-promise": "^4.2.1",
122-
"require-dir": "^0.3.2",
123-
"rimraf": "^2.6.1",
124-
"run-sequence": "^1.2.2",
125119
"serve-favicon": "^2.4.3",
126120
"swagger-jsdoc": "^1.9.5",
127121
"swagger-ui-express": "^2.0.0",
128122
"trash-cli": "^1.4.0",
129-
"ts-jest": "^20.0.6",
130-
"ts-node": "^3.1.0",
131-
"tslint": "^5.4.3",
123+
"ts-node": "^3.2.0",
124+
"tslint": "^5.5.0",
132125
"typescript": "^2.4.1",
133126
"winston": "^2.3.1"
134127
},
@@ -148,6 +141,8 @@
148141
},
149142
"license": "MIT",
150143
"devDependencies": {
151-
"cross-env": "^5.0.1"
144+
"cross-env": "^5.0.1",
145+
"jest": "^20.0.3",
146+
"ts-jest": "^20.0.7"
152147
}
153148
}

src/console/lib/utils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ export const buildFilePath = (targetPath: string, fileName: string, isTest = fal
4040

4141
export const inputIsRequired = (value: any) => !!value;
4242

43-
export const existsFile = async (path: string, stop: boolean = false, isTest = false) => {
43+
export const existsFile = async (filePath: string, stop: boolean = false, isTest = false) => {
4444
const prompt = inquirer.createPromptModule();
4545
return new Promise((resolve, reject) => {
46-
fs.exists(path, async (exists) => {
46+
fs.exists(filePath, async (exists) => {
4747

4848
if (exists) {
49-
let fileName = path.split('/src/')[1];
49+
let fileName = filePath.split('/src/')[1];
5050
if (isTest) {
51-
fileName = path.split('/test/')[1];
51+
fileName = filePath.split('/test/')[1];
5252
}
5353
const answer = await prompt([
5454
{

src/core/IoC.ts

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import { Types, Core, Targets } from '../constants';
1313
import { events, EventEmitter } from './api/events';
1414
import { Logger } from './Logger';
1515
import { IocConfig } from '../config/IocConfig';
16-
import { getFolderwrapping } from './helpers/Path';
16+
import { getFolderWrapping } from './helpers/Path';
1717

1818

1919
export class IoC {
@@ -122,16 +122,16 @@ export class IoC {
122122
.whenTargetNamed(name);
123123
}
124124

125-
private bindFiles(path: string, target: any, callback: (name: any, value: any) => void): Promise<void> {
125+
private bindFiles(filePath: string, target: any, callback: (name: any, value: any) => void): Promise<void> {
126126
return new Promise<void>((resolve) => {
127-
this.getFiles(path, (files: string[]) => {
127+
this.getFiles(filePath, (files: string[]) => {
128128
files.forEach((file: any) => {
129129
let fileExport;
130130
let fileClass;
131131
let fileTarget;
132132
const isRecursive = file.name.indexOf('.') > 0;
133133
try {
134-
fileExport = require(`${file.path}`);
134+
fileExport = require(`${file.filePath}`);
135135
} catch (e) {
136136
this.log.warn(e.message);
137137
return;
@@ -185,32 +185,31 @@ export class IoC {
185185
}
186186

187187
private getBasePath(): string {
188-
const baseFolder = __dirname.indexOf(getFolderwrapping('src')) >= 0 ? getFolderwrapping('src') : getFolderwrapping('dist');
188+
const baseFolder = __dirname.indexOf(getFolderWrapping('src')) >= 0 ? getFolderWrapping('src') : getFolderWrapping('dist');
189189
const baseRoot = __dirname.substring(0, __dirname.indexOf(baseFolder));
190190
return path.join(baseRoot, baseFolder, 'api');
191191
}
192192

193-
private getFiles(path: string, done: (files: any[]) => void): void {
194-
const isTypeScript = __dirname.indexOf(getFolderwrapping('src')) >= 0;
193+
private getFiles(filePath: string, done: (files: any[]) => void): void {
194+
const isTypeScript = __dirname.indexOf(getFolderWrapping('src')) >= 0;
195195
if (!isTypeScript) {
196-
path = path.replace('.ts', '.js');
196+
filePath = filePath.replace('.ts', '.js');
197197
}
198-
glob(this.getBasePath() + path, (err: any, files: string[]) => {
198+
glob(this.getBasePath() + filePath, (err: any, files: string[]) => {
199199
if (err) {
200-
this.log.warn(`Could not read the folder ${path}!`);
200+
this.log.warn(`Could not read the folder ${filePath}!`);
201201
return;
202202
}
203203
done(files.map((p: string) => this.parseFilePath(p)));
204204
});
205205
}
206206

207-
private parseFilePath(path: string): any {
208-
const filePath = path.substring(this.getBasePath().length + 1);
209-
const dir = filePath.split('/')[0];
210-
const file = filePath.substr(dir.length + 1);
207+
private parseFilePath(filePath: string): any {
208+
const p = filePath.substring(this.getBasePath().length + 1);
209+
const dir = p.split('/')[0];
210+
const file = p.substr(dir.length + 1);
211211
const name = file.replace('/', '.').substring(0, file.length - 3);
212212
return {
213-
path,
214213
filePath,
215214
dir,
216215
file,

src/core/Logger.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { getFolderwrapping, isWindows } from './helpers/Path';
1+
import { getFolderWrapping, isWindows } from './helpers/Path';
22

33
/**
44
* core.log.Log
@@ -35,8 +35,8 @@ export class Logger {
3535
const pathDelimiter = isWindows() ? '\\' : '/';
3636
if (path.indexOf(pathDelimiter) >= 0) {
3737
path = path.replace(process.cwd(), '');
38-
path = path.replace(getFolderwrapping('src'), '');
39-
path = path.replace(getFolderwrapping('dist'), '');
38+
path = path.replace(getFolderWrapping('src'), '');
39+
path = path.replace(getFolderWrapping('dist'), '');
4040
path = path.replace('.ts', '');
4141
path = path.replace('.js', '');
4242
path = path.replace(/\//g, ':');

src/core/SwaggerUI.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as express from 'express';
22
import * as path from 'path';
33
import * as swaggerUi from 'swagger-ui-express';
44
import { Environment } from './helpers/Environment';
5-
import { getFolderwrapping } from './helpers/Path';
5+
import { getFolderWrapping } from './helpers/Path';
66

77

88
export class SwaggerUI {
@@ -13,7 +13,7 @@ export class SwaggerUI {
1313

1414
public setup(app: express.Application): void {
1515
if (Environment.isTruthy(process.env.SWAGGER_ENABLED)) {
16-
const baseFolder = __dirname.indexOf(getFolderwrapping('src')) >= 0 ? getFolderwrapping('src') : getFolderwrapping('dist');
16+
const baseFolder = __dirname.indexOf(getFolderWrapping('src')) >= 0 ? getFolderWrapping('src') : getFolderWrapping('dist');
1717
const basePath = __dirname.substring(0, __dirname.indexOf(baseFolder));
1818
const swaggerFile = require(path.join(basePath, process.env.SWAGGER_FILE));
1919
const packageJson = require(path.join(basePath, 'package.json'));

src/core/api/extendExpressResponse.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,8 +74,8 @@ export const extendExpressResponse = (req: myExpress.Request, res: myExpress.Res
7474
export function bodySuccessful<T>(data: T, options: myExpress.ResponseOptions = {}): any {
7575
return {
7676
success: true,
77-
...message(options.message),
78-
...links(options.links),
77+
...prepareMessage(options.message),
78+
...prepareLinks(options.links),
7979
data
8080
};
8181
}
@@ -92,14 +92,14 @@ export function bodyFailed(message: string, error?: any): any {
9292
}
9393

9494
///////////////////////////////////////////////////////
95-
function message(value?: string): any {
95+
function prepareMessage(value?: string): any {
9696
if (value) {
9797
return { message: value };
9898
}
9999
return;
100100
}
101101

102-
function links(values?: myExpress.ResponseLinks[]): any {
102+
function prepareLinks(values?: myExpress.ResponseLinks[]): any {
103103
if (values) {
104104
return { links: values };
105105
}

src/core/database/Factory.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* ------------------------------------------------
44
*/
55

6-
import * as faker from 'faker';
6+
import * as Faker from 'faker';
77
import * as bookshelf from 'bookshelf';
88
import { BluePrint } from './BluePrint';
99
import { ModelFactory } from './ModelFactory';
@@ -13,7 +13,7 @@ export class Factory {
1313

1414
public static getInstance(): Factory {
1515
if (!Factory.instance) {
16-
Factory.instance = new Factory(faker);
16+
Factory.instance = new Factory(Faker);
1717
}
1818
return Factory.instance;
1919
}

src/core/helpers/Path.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,3 @@
11
export const isWindows = (): boolean => /^win/.test(process.platform);
2-
export const getFolderwrapping = (input: string): string => isWindows() ? `\\${input}\\` : `/${input}/`;
2+
3+
export const getFolderWrapping = (input: string): string => isWindows() ? `\\${input}\\` : `/${input}/`;

0 commit comments

Comments
 (0)