From e44bc316bf10a3a95f2cf6a54ee44c7ef5a118a1 Mon Sep 17 00:00:00 2001 From: Moriz Wahl Date: Mon, 7 Mar 2022 21:35:23 +0100 Subject: [PATCH] refactor: Resolve Relative Paths in Backend --- backend/jest.config.js | 5 +++++ backend/package.json | 7 ++++++- backend/tsconfig.json | 7 ++++++- 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/backend/jest.config.js b/backend/jest.config.js index 0e4643c63..f61917b01 100644 --- a/backend/jest.config.js +++ b/backend/jest.config.js @@ -6,6 +6,11 @@ module.exports = { collectCoverageFrom: ['src/**/*.ts', '!**/node_modules/**'], setupFiles: ['/test/testSetup.ts'], moduleNameMapper: { + '@/(.*)': '/src/$1', + '@model/(.*)': '/src/graphql/model/$1', + '@arg/(.*)': '/src/graphql/arg/$1', + '@enum/(.*)': '/src/graphql/enum/$1', + '@repository/(.*)': '/src/typeorm/repository/$1', '@entity/(.*)': process.env.NODE_ENV === 'development' ? '/../database/entity/$1' diff --git a/backend/package.json b/backend/package.json index c27419ddb..710d73a8c 100644 --- a/backend/package.json +++ b/backend/package.json @@ -60,7 +60,12 @@ "typescript": "^4.3.4" }, "_moduleAliases": { + "@": "./src", + "@arg": "./src/graphql/arg", + "@dbTools": "../database/build/src", "@entity": "../database/build/entity", - "@dbTools": "../database/build/src" + "@enum": "./src/graphql/enum", + "@model": "./src/graphql/model", + "@repository": "./src/typeorm/repository" } } diff --git a/backend/tsconfig.json b/backend/tsconfig.json index eabdc75b0..26e3706fe 100644 --- a/backend/tsconfig.json +++ b/backend/tsconfig.json @@ -47,8 +47,13 @@ // "moduleResolution": "node", /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */ // "baseUrl": "./", /* Base directory to resolve non-absolute module names. */ "paths": { /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */ + "@/*": ["./src/*"], + "@arg/*": ["./src/graphql/arg/*"], + "@dbTools/*": ["../database/src/*"], "@entity/*": ["../database/entity/*"], - "@dbTools/*": ["../database/src/*"] + "@enum/*": ["./src/graphql/enum/*"], + "@model/*": ["./src/graphql/model/*"], + "@repository/*": ["./src/typeorm/repository/*"] }, // "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */ // "typeRoots": [], /* List of folders to include type definitions from. */