diff --git a/jest.config.js b/jest.config.js index 18ff4ca..af1c229 100644 --- a/jest.config.js +++ b/jest.config.js @@ -5,14 +5,15 @@ const { pathsToModuleNameMapper } = require("ts-jest"); /** @type {import('ts-jest').JestConfigWithTsJest} */ module.exports = { - roots: ["/src"], + preset: "ts-jest", testEnvironment: "node", testMatch: ["**/*.(test|spec).ts"], transform: { ".+\\.ts$": "ts-jest", }, - preset: "ts-jest", - modulePaths: [tsconfig.compilerOptions.baseUrl], - moduleNameMapper: pathsToModuleNameMapper(tsconfig.compilerOptions.paths), + modulePaths: [""], + moduleNameMapper: pathsToModuleNameMapper(tsconfig.compilerOptions.paths, { + prefix: "", + }), coverageReporters: ["html", "text"], }; diff --git a/package.json b/package.json index 19a6a11..48c163a 100644 --- a/package.json +++ b/package.json @@ -9,7 +9,7 @@ "codegen:init": "npx graphql-code-generator init", "prettier:fix": "npx prettier '**/*.ts' --write", "lint:fix": "npx eslint . --ext .ts --fix", - "build": "tsc -p tsconfig.json", + "build": "tsc -p tsconfig.json && tsc-alias", "prepare": "husky install", "test": "jest --passWithNoTests --no-cache", "test:watch": "jest --watch", @@ -41,6 +41,7 @@ "ts-jest": "^29.1.1", "ts-node": "^10.9.1", "ts-node-dev": "^2.0.0", + "tsc-alias": "^1.8.8", "tsconfig-paths": "^4.2.0", "typescript": "^5.2.2" }, diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 5ac8eeb..8c529de 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -82,6 +82,9 @@ devDependencies: ts-node-dev: specifier: ^2.0.0 version: 2.0.0(@types/node@20.6.4)(typescript@5.2.2) + tsc-alias: + specifier: ^1.8.8 + version: 1.8.8 tsconfig-paths: specifier: ^4.2.0 version: 4.2.0 @@ -3313,6 +3316,11 @@ packages: engines: {node: '>=14'} dev: true + /commander@9.5.0: + resolution: {integrity: sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ==} + engines: {node: ^12.20.0 || >=14} + dev: true + /common-tags@1.8.2: resolution: {integrity: sha512-gk/Z852D2Wtb//0I+kRFNKKE9dIIVirjoqPoA1wJU+XePVXZfGeBpk45+A1rKO4Q43prqWBNY/MiIeRLbPWUaA==} engines: {node: '>=4.0.0'} @@ -6132,6 +6140,11 @@ packages: resolution: {integrity: sha512-nnbWWOkoWyUsTjKrhgD0dcz22mdkSnpYqbEjIm2nhwhuxlSkpywJmBo8h0ZqJdkp73mb90SssHkN4rsRaBAfAA==} dev: true + /mylas@2.1.13: + resolution: {integrity: sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg==} + engines: {node: '>=12.0.0'} + dev: true + /nanoid@3.3.7: resolution: {integrity: sha512-eSRppjcPIatRIMC1U6UngP8XFcz8MQWGQdt1MTBQ7NaAmvXDfvNxbvWV3x2y6CdEUciCSsDHDQZbhYaB8QEo2g==} engines: {node: ^10 || ^12 || ^13.7 || ^14 || >=15.0.1} @@ -6580,6 +6593,13 @@ packages: find-up: 4.1.0 dev: true + /plimit-lit@1.6.1: + resolution: {integrity: sha512-B7+VDyb8Tl6oMJT9oSO2CW8XC/T4UcJGrwOVoNGwOQsQYhlpfajmrMj5xeejqaASq3V/EqThyOeATEOMuSEXiA==} + engines: {node: '>=12'} + dependencies: + queue-lit: 1.5.2 + dev: true + /portscanner@2.2.0: resolution: {integrity: sha512-IFroCz/59Lqa2uBvzK3bKDbDDIEaAY8XJ1jFxcLWTqosrsc32//P4VuSB2vZXoHiHqOmx8B5L5hnKOxL/7FlPw==} engines: {node: '>=0.4', npm: '>=1.0.0'} @@ -6702,6 +6722,11 @@ packages: side-channel: 1.0.4 dev: true + /queue-lit@1.5.2: + resolution: {integrity: sha512-tLc36IOPeMAubu8BkW8YDBV+WyIgKlYU7zUNs0J5Vk9skSZ4JfGlPOqplP0aHdfv7HL0B2Pg6nwiq60Qc6M2Hw==} + engines: {node: '>=12'} + dev: true + /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} dev: true @@ -7604,6 +7629,18 @@ packages: yn: 3.1.1 dev: true + /tsc-alias@1.8.8: + resolution: {integrity: sha512-OYUOd2wl0H858NvABWr/BoSKNERw3N9GTi3rHPK8Iv4O1UyUXIrTTOAZNHsjlVpXFOhpJBVARI1s+rzwLivN3Q==} + hasBin: true + dependencies: + chokidar: 3.5.3 + commander: 9.5.0 + globby: 11.1.0 + mylas: 2.1.13 + normalize-path: 3.0.0 + plimit-lit: 1.6.1 + dev: true + /tsconfig-paths@4.2.0: resolution: {integrity: sha512-NoZ4roiN7LnbKn9QqE1amc9DJfzvZXxF4xDavcOWt1BPkdx+m+0gJuPM+S0vCe7zTJMYUP0R8pO2XMr+Y8oLIg==} engines: {node: '>=6'} diff --git a/src/graphql/errors/tmdb-api/tmdb-api-error.ts b/src/graphql/errors/tmdb-api/tmdb-api-error.ts index c523fcc..a9b3454 100644 --- a/src/graphql/errors/tmdb-api/tmdb-api-error.ts +++ b/src/graphql/errors/tmdb-api/tmdb-api-error.ts @@ -1,4 +1,4 @@ -import { GraphQLError } from "graphql"; +import { GraphQLError } from "../../../../node_modules/graphql"; export default class TMDBApiError extends GraphQLError { extensions: Record = {}; diff --git a/tsconfig.json b/tsconfig.json index 13f78f8..a47b4bb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -3,9 +3,8 @@ "target": "es2016", "lib": ["es6"], "module": "commonjs", - "rootDirs": ["src", "__tests__"], "outDir": "build", - "baseUrl": "src", + "baseUrl": ".", "resolveJsonModule": true, "allowJs": true, "esModuleInterop": true, @@ -14,21 +13,25 @@ "noImplicitAny": true, "skipLibCheck": true, "paths": { - "@news-api/*": ["graphql/datasources/news-api/*"], - "@open-trivia-api/*": ["graphql/datasources/open-trivia-api/*"], - "@tmdb-api/*": ["graphql/datasources/the-movie-db-api/*"], - "@generated-types": ["generated/graphql.ts"], - "@types": ["types/index.ts"], - "@errors": ["graphql/errors"], - "@/*": ["*"] + "@news-api/*": ["./src/graphql/datasources/news-api/*"], + "@open-trivia-api/*": ["./src/graphql/datasources/open-trivia-api/*"], + "@tmdb-api/*": ["./src/graphql/datasources/the-movie-db-api/*"], + "@generated-types": ["./src/generated/graphql.ts"], + "@types": ["./src/types/index.ts"], + "@errors": ["./src/graphql/errors"], + "@/*": ["./src/*"] } }, "exclude": [ + "__test__", "node_modules", "src/**/*.test.ts", + "src/**/*.spec.ts", "jest.config.js", "coverage", "build", - "jest-*.js" + "jest-*.js", + "static", + "docs" ] }