diff --git a/nodemon.json b/nodemon.json index 4140b0a..329f59b 100644 --- a/nodemon.json +++ b/nodemon.json @@ -2,5 +2,5 @@ "watch": ["src", "bin", "test", "scripts"], "ext": ".ts,.js,.pug,.css", "ignore": [], - "exec": "ts-node --transpile-only ./src/index.ts" + "exec": "ts-node -r tsconfig-paths/register --transpile-only ./src/index.ts" } \ No newline at end of file diff --git a/package-lock.json b/package-lock.json index 24635d6..7c61991 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1354,6 +1354,11 @@ "integrity": "sha512-k3RS5HyBPu4h+5hTmIEfPB2rl5P3LnGdQEZrV2b9OWTJVtsUQ2VBcedqYKGqxvZqle5UALUXdSfVA8nf3HfyWQ==", "dev": true }, + "@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=" + }, "@types/keygrip": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/@types/keygrip/-/keygrip-1.0.2.tgz", @@ -5340,8 +5345,7 @@ "minimist": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.0.tgz", - "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=", - "dev": true + "integrity": "sha1-o1AIsg9BOD7sH7kU9M1d95omQoQ=" }, "mixin-deep": { "version": "1.3.2", @@ -6781,6 +6785,11 @@ "ansi-regex": "^3.0.0" } }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=" + }, "strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", @@ -6965,6 +6974,27 @@ "yn": "3.1.1" } }, + "tsconfig-paths": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz", + "integrity": "sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw==", + "requires": { + "@types/json5": "^0.0.29", + "json5": "^1.0.1", + "minimist": "^1.2.0", + "strip-bom": "^3.0.0" + }, + "dependencies": { + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "requires": { + "minimist": "^1.2.0" + } + } + } + }, "tslib": { "version": "1.10.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.10.0.tgz", diff --git a/package.json b/package.json index 0360321..c8bbe97 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "scripts": { "build": "tsc", "start": "nodemon", - "get-refresh-token": "ts-node scripts/get-refresh-token.ts", + "get-refresh-token": "ts-node -r tsconfig-paths/register scripts/get-refresh-token.ts", "codegen": "graphql-codegen --config codegen.yml" }, "author": "", @@ -24,6 +24,7 @@ "apollo-server": "^2.10.1", "apollo-server-lambda": "^2.10.1", "axios": "^0.19.2", - "dotenv": "^8.2.0" + "dotenv": "^8.2.0", + "tsconfig-paths": "^3.9.0" } } diff --git a/scripts/get-refresh-token.ts b/scripts/get-refresh-token.ts index f69ac91..a3d51af 100644 --- a/scripts/get-refresh-token.ts +++ b/scripts/get-refresh-token.ts @@ -1,6 +1,6 @@ require('dotenv').config() -import { spotifyService } from '../src/modules/spotify/services' +import { spotifyService } from '@/modules/spotify/services' const args = process.argv; const providedCode = args.length === 3 && !!args[2] === true; diff --git a/src/modules/spotify/mappers/currentPlayingSongMap.ts b/src/modules/spotify/mappers/currentPlayingSongMap.ts index 802ecd1..fa991bb 100644 --- a/src/modules/spotify/mappers/currentPlayingSongMap.ts +++ b/src/modules/spotify/mappers/currentPlayingSongMap.ts @@ -1,6 +1,6 @@ -import { CurrentSongPlayingResult } from '../../../shared/infra/graphql/generated/types'; -import { Mapper } from '../../../shared/core/mapper'; +import { CurrentSongPlayingResult } from '@/shared/infra/graphql/generated/types'; +import { Mapper } from '@/shared/core/mapper'; export class CurrentSongPlayingResultMap implements Mapper { diff --git a/src/modules/spotify/services/spotifyService.ts b/src/modules/spotify/services/spotifyService.ts index 522b2dc..e1d03b7 100644 --- a/src/modules/spotify/services/spotifyService.ts +++ b/src/modules/spotify/services/spotifyService.ts @@ -1,6 +1,6 @@ import axios from 'axios' -import { CurrentSongPlayingResult } from '../../../shared/infra/graphql/generated/types'; +import { CurrentSongPlayingResult } from '@/shared/infra/graphql/generated/types'; import { CurrentSongPlayingResultMap } from '../mappers/currentPlayingSongMap'; type AccessToken = string; diff --git a/src/modules/spotify/useCases/getCurrentSongPlaying/GetCurrentSongPlaying.ts b/src/modules/spotify/useCases/getCurrentSongPlaying/GetCurrentSongPlaying.ts index 235c26e..d450f3e 100644 --- a/src/modules/spotify/useCases/getCurrentSongPlaying/GetCurrentSongPlaying.ts +++ b/src/modules/spotify/useCases/getCurrentSongPlaying/GetCurrentSongPlaying.ts @@ -1,8 +1,8 @@ -import { UseCase } from "../../../../shared/core/useCase"; -import { ISpotifyService } from "../../services/spotifyService"; +import { UseCase } from "@/shared/core/useCase"; +import { ISpotifyService } from "@/modules/spotify/services/spotifyService"; import { GetCurrentSongPlayingResult } from "./GetCurrentSongPlayingResult"; -import { right, left } from "../../../../shared/core/either"; +import { right, left } from "@/shared/core/either"; export class GetCurrentSong implements UseCase { diff --git a/src/modules/spotify/useCases/getCurrentSongPlaying/GetCurrentSongPlayingResult.ts b/src/modules/spotify/useCases/getCurrentSongPlaying/GetCurrentSongPlayingResult.ts index 866f5e6..b7577cc 100644 --- a/src/modules/spotify/useCases/getCurrentSongPlaying/GetCurrentSongPlayingResult.ts +++ b/src/modules/spotify/useCases/getCurrentSongPlaying/GetCurrentSongPlayingResult.ts @@ -1,5 +1,5 @@ -import { Either } from "../../../../shared/core/either"; -import { CurrentSongPlayingResult } from "../../../../shared/infra/graphql/generated/types"; +import { Either } from "@/shared/core/either"; +import { CurrentSongPlayingResult } from "@/shared/infra/graphql/generated/types"; export type GetCurrentSongPlayingResult = Either< null, diff --git a/src/shared/infra/graphql/server.ts b/src/shared/infra/graphql/server.ts index a4a17bb..db1e74a 100644 --- a/src/shared/infra/graphql/server.ts +++ b/src/shared/infra/graphql/server.ts @@ -1,7 +1,7 @@ import { ApolloServer as ApolloServerLambda } from 'apollo-server-lambda'; import { ApolloServer, gql } from 'apollo-server'; -import { getCurrentSong } from '../../../modules/spotify/useCases/getCurrentSongPlaying'; +import { getCurrentSong } from '@/modules/spotify/useCases/getCurrentSongPlaying'; const resolvers = { Query: { diff --git a/tsconfig.json b/tsconfig.json index 5b65c76..c966b52 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -13,12 +13,19 @@ "typeRoots" : ["./node_modules/@types", "./src/@types"], "experimentalDecorators": true, "emitDecoratorMetadata": true, - "esModuleInterop": true + "esModuleInterop": true, + "baseUrl": ".", + "paths": { + "@/*": [ + "src/*" + ] + } }, "include": [ "src/*.ts", "src/**/*.ts", - "src/**/*.js" + "src/**/*.js", + "scripts/**/*.ts" ], "exclude": [ "node_modules",