Skip to content

Commit 4ff1bf8

Browse files
Improve express typing and build config (#61)
1 parent 70aa708 commit 4ff1bf8

File tree

6 files changed

+15
-15
lines changed

6 files changed

+15
-15
lines changed

@types/express.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import type { RequestUser } from '@/domain/models/request-user';
2+
3+
declare module 'express-serve-static-core' {
4+
interface Request {
5+
user?: RequestUser | null;
6+
}
7+
}

@types/express/index.d.ts

Lines changed: 0 additions & 7 deletions
This file was deleted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ The project contains Github templates and workflows. If you don't want to keep t
218218

219219
| Name | Description |
220220
| --------------------------------------------- | --------------------------------------------- |
221-
| **@types/** | Global types definitions |
221+
| **@types/** | Types definitions |
222222
| **build/** | Compiled source files will be placed here |
223223
| **coverage/** | Jest coverage results will be placed here |
224224
| **src/** | Source files |

src/domain/models/request-user.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,13 @@ export class RequestUser {
77
id: UserId;
88
username: string;
99
email: string;
10+
1011
constructor(params: {
11-
id: string;
12+
id: UserId;
1213
username: string;
1314
email: string;
1415
}) {
15-
this.id = params.id as UserId;
16+
this.id = params.id;
1617
this.username = params.username;
1718
this.email = params.email;
1819
}

tsconfig.build.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"extends": "./tsconfig",
3+
"include": ["src/**/*", "@types/**/*"],
34
"exclude": ["node_modules", "build", "src/tests/**/*"],
45
"compilerOptions": {
56
"types": ["node"]

tsconfig.json

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,14 +27,12 @@
2727
/* Linting */
2828
"strict": true,
2929
"noFallthroughCasesInSwitch": true,
30-
"typeRoots": ["@types", "./node_modules/@types"],
3130

3231
/* Paths */
3332
"paths": {
3433
"@/*": ["./src/*"]
34+
},
3535
},
36-
},
37-
"include": ["src/**/*", "src/tests/**/*"],
38-
"exclude": ["node_modules", "build"],
39-
"files": ["@types/express/index.d.ts"]
36+
"include": ["src/**/*", "src/tests/**/*", "@types/**/*"],
37+
"exclude": ["node_modules", "build"]
4038
}

0 commit comments

Comments
 (0)