Skip to content

Commit 9a36d5a

Browse files
author
hirsch88
committed
Move custom types to src
1 parent 9e61a05 commit 9a36d5a

File tree

4 files changed

+94
-3
lines changed

4 files changed

+94
-3
lines changed

src/types/auth0.d.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
declare module 'auth0' {
2+
3+
interface User {
4+
user_id: string;
5+
email: string;
6+
email_verified: boolean;
7+
picture: string;
8+
created_at: Date;
9+
updated_at: Date;
10+
clientID?: string;
11+
nickname?: string;
12+
name?: string;
13+
global_client_id?: string;
14+
identities?: UserIdentities[];
15+
}
16+
17+
interface UserIdentities {
18+
user_id: string;
19+
provider: string;
20+
connection: string;
21+
isSocial: boolean;
22+
}
23+
24+
interface Body {
25+
client_id: string;
26+
client_secret: string;
27+
audience: string;
28+
grant_type: string;
29+
}
30+
31+
}

src/types/dto/user.d.ts

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
declare module 'dto' {
2+
3+
interface User {
4+
id: string;
5+
firstName: string;
6+
lastName: string;
7+
email: string;
8+
auth0UserId: string;
9+
picture: string;
10+
createdAt: Date;
11+
updatedAt: Date;
12+
}
13+
14+
}

src/types/my-express.d.ts

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
declare module 'my-express' {
2+
3+
import * as express from 'express';
4+
import * as auth0 from 'auth0';
5+
import * as dto from 'dto';
6+
7+
namespace my {
8+
9+
interface Application extends express.Application {
10+
}
11+
12+
interface NextFunction extends express.NextFunction {
13+
}
14+
15+
interface Request extends express.Request {
16+
tokeninfo: auth0.User;
17+
user: dto.User;
18+
}
19+
20+
interface Response extends express.Response {
21+
ok<T>(data: T, options?: ResponseOptions): void;
22+
created<T>(data: T, options?: ResponseOptions): void;
23+
found<T>(data: T, options?: ResponseOptions): void;
24+
updated<T>(data: T, options?: ResponseOptions): void;
25+
destroyed<T>(options?: ResponseOptions): void;
26+
failed<T>(status: number, message: string, error?: any): void;
27+
}
28+
29+
interface ResponseOptions {
30+
message?: string;
31+
links?: ResponseLinks[];
32+
}
33+
34+
interface ResponseLinks {
35+
name: string;
36+
url: string;
37+
}
38+
}
39+
40+
}

tsconfig.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@
66
"moduleResolution": "node",
77
"sourceMap": true,
88
"baseUrl": ".",
9+
"outDir": "dist",
910
"alwaysStrict": true,
1011
"experimentalDecorators": true,
11-
"emitDecoratorMetadata": true
12+
"emitDecoratorMetadata": true,
13+
"paths": {
14+
"*": [
15+
"node_modules/*",
16+
"src/types/*"
17+
]
18+
}
1219
},
1320
"include": [
14-
"src/**/*",
15-
"typings/**/*.d.ts"
21+
"src/**/*"
1622
]
1723
}

0 commit comments

Comments
 (0)