Skip to content

Commit ae622c5

Browse files
committed
refactor: update TypeScript configuration and adjust import paths for module resolution
1 parent 3dfb2ba commit ae622c5

File tree

4 files changed

+10
-9
lines changed

4 files changed

+10
-9
lines changed

src/app.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import express from "express";
2-
import indexRouter from "./routes/index.routes";
3-
import userRoute from "./routes/users.routes";
4-
import globalErrorHandler from "./middlewares/globalErrorHandler";
2+
import indexRouter from "@/routes/index.routes";
3+
import userRoute from "@/routes/users.routes";
4+
import globalErrorHandler from "@/middlewares/globalErrorHandler";
55

66
// Initialize the express app
77
const app = express();
@@ -13,7 +13,6 @@ app.use(express.json());
1313
app.use("/", indexRouter);
1414
app.use("/users", userRoute);
1515

16-
1716
// global error handler
1817
app.use(globalErrorHandler);
1918

src/middlewares/globalErrorHandler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { ErrorRequestHandler } from "express";
2-
import { env } from "../configs/envConfig";
2+
import { env } from "@/configs/envConfig";
33

44
const globalErrorHandler: ErrorRequestHandler = (err, _req, res, _next) => {
55
const statusCode = err.statusCode || 500;

src/server.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import app from "./app";
2-
import { env } from "./configs/envConfig";
1+
import app from "@/app";
2+
import { env } from "@/configs/envConfig";
33

44
const server = app.listen(env.PORT, () => {
55
console.log(

tsconfig.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@
2929
"module": "commonjs" /* Specify what module code is generated. */,
3030
"rootDir": "src" /* Specify the root folder within your source files. */,
3131
// "moduleResolution": "node10", /* Specify how TypeScript looks up a file from a given module specifier. */
32-
// "baseUrl": "./", /* Specify the base directory to resolve non-relative module names. */
33-
// "paths": {}, /* Specify a set of entries that re-map imports to additional lookup locations. */
32+
"baseUrl": "./src" /* Specify the base directory to resolve non-relative module names. */,
33+
"paths": {
34+
"@/*": ["*"]
35+
} /* Specify a set of entries that re-map imports to additional lookup locations. */,
3436
// "rootDirs": [], /* Allow multiple folders to be treated as one when resolving modules. */
3537
// "typeRoots": [], /* Specify multiple folders that act like './node_modules/@types'. */
3638
// "types": [], /* Specify type package names to be included without being referenced in a source file. */

0 commit comments

Comments
 (0)