Skip to content

Commit 9083772

Browse files
author
hirsch88
committed
🐛 Fix file paths
1 parent 9e51a4b commit 9083772

File tree

6 files changed

+17
-12
lines changed

6 files changed

+17
-12
lines changed

.env.example

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ TYPEORM_LOGGING=false
4242
#
4343
TYPEORM_MIGRATIONS=src/database/migrations/**/*.ts
4444
TYPEORM_MIGRATIONS_DIR=src/database/migrations
45-
TYPEORM_ENTITIES=src/api/models/**/*{.js,.ts}.ts
46-
TYPEORM_SUBSCRIBERS=src/api/subscribers/**/*Subscriber{.js,.ts}
45+
TYPEORM_ENTITIES=src/api/models/**/*.ts,src/api/models/**/*.js
46+
TYPEORM_ENTITIES_DIR=src/api/models
47+
TYPEORM_SUBSCRIBERS=src/api/subscribers/**/*Subscriber.ts,src/api/subscribers/**/*Subscriber.js
48+
TYPEORM_SUBSCRIBERS_DIR=src/api/subscribers
4749
CONTROLLERS=src/api/controllers/**/*Controller{.js,.ts}
4850
MIDDLEWARES=src/api/middlewares/**/*Middleware{.js,.ts}
4951
INTERCEPTORS=src/api/interceptors/**/*Interceptor{.js,.ts}

.env.test

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,15 +37,16 @@ TYPEORM_LOGGING=false
3737
#
3838
TYPEORM_MIGRATIONS=src/database/migrations/**/*.ts
3939
TYPEORM_MIGRATIONS_DIR=src/database/migrations
40-
TYPEORM_ENTITIES=src/api/models/**/*{.js,.ts}.ts
41-
TYPEORM_SUBSCRIBERS=src/api/subscribers/**/*Subscriber{.js,.ts}
40+
TYPEORM_ENTITIES=src/api/models/**/*.ts,src/api/models/**/*.js
41+
TYPEORM_ENTITIES_DIR=src/api/models
42+
TYPEORM_SUBSCRIBERS=src/api/subscribers/**/*Subscriber.ts,src/api/subscribers/**/*Subscriber.js
43+
TYPEORM_SUBSCRIBERS_DIR=src/api/subscribers
4244
CONTROLLERS=src/api/controllers/**/*Controller{.js,.ts}
4345
MIDDLEWARES=src/api/middlewares/**/*Middleware{.js,.ts}
4446
INTERCEPTORS=src/api/interceptors/**/*Interceptor{.js,.ts}
4547
QUERIES=src/api/queries/**/*Query{.js,.ts}
4648
MUTATIONS=src/api/mutations/**/*Mutation{.js,.ts}
4749

48-
4950
#
5051
# GraphQL
5152
#

src/lib/env/utils.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ export function getOsEnv(key: string): string {
22
return process.env[key] as string;
33
}
44

5-
export function getOsEnvArray(key: string, delimiter: string = ','): string[] | boolean {
6-
return process.env[key] && process.env[key].split(delimiter) || false;
5+
export function getOsEnvArray(key: string, delimiter: string = ','): string[] {
6+
return process.env[key] && process.env[key].split(delimiter) || [];
77
}
88

99
export function toNumber(value: string): number {

src/lib/graphql/importClassesFromDirectories.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ export function importClassesFromDirectories(directories: string[], formats: str
2727
return formats.indexOf(path.extname(file)) !== -1 && dtsExtension !== '.d.ts';
2828
})
2929
.map(file => {
30-
return require(file);
30+
return require(path.join(process.cwd(), file));
3131
});
3232

3333
return loadFileClasses(dirs, []);

src/loaders/eventDispatchLoader.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import * as glob from 'glob';
22
import { MicroframeworkLoader, MicroframeworkSettings } from 'microframework-w3tec';
3+
import * as path from 'path';
34

45
import { env } from '../env';
56

@@ -15,7 +16,7 @@ export const eventDispatchLoader: MicroframeworkLoader = (settings: Microframewo
1516
patterns.forEach((pattern) => {
1617
glob(pattern, (err: any, files: string[]) => {
1718
for (const file of files) {
18-
require(file);
19+
require(path.join(process.cwd(), file));
1920
}
2021
});
2122
});

src/loaders/expressLoader.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { Application } from 'express';
22
import { MicroframeworkLoader, MicroframeworkSettings } from 'microframework-w3tec';
3+
import * as path from 'path';
34
import { createExpressServer } from 'routing-controllers';
45

56
import { authorizationChecker } from '../auth/authorizationChecker';
@@ -23,9 +24,9 @@ export const expressLoader: MicroframeworkLoader = (settings: MicroframeworkSett
2324
* We can add options about how routing-controllers should configure itself.
2425
* Here we specify what controllers should be registered in our express server.
2526
*/
26-
controllers: env.app.dirs.controllers,
27-
middlewares: env.app.dirs.middlewares,
28-
interceptors: env.app.dirs.interceptors,
27+
controllers: env.app.dirs.controllers.map(controller => path.join(process.cwd(), controller)),
28+
middlewares: env.app.dirs.middlewares.map(middleware => path.join(process.cwd(), middleware)),
29+
interceptors: env.app.dirs.interceptors.map(interceptor => path.join(process.cwd(), interceptor)),
2930

3031
/**
3132
* Authorization features

0 commit comments

Comments
 (0)