@@ -5,26 +5,35 @@ import { CommonRoutesConfig } from "@backend/common/common.routes.config";
5
5
import authController from "./controllers/auth.controller" ;
6
6
import authMiddleware from "./middleware/auth.middleware" ;
7
7
8
+ /**
9
+ * Routes with the verifyIsDev middleware are
10
+ * only available when running the app in dev,
11
+ * as they are not called by production code.
12
+ */
8
13
export class AuthRoutes extends CommonRoutesConfig {
9
14
constructor ( app : express . Application ) {
10
15
super ( app , "AuthRoutes" ) ;
11
16
}
12
17
13
18
configureRoutes ( ) : express . Application {
14
19
/**
15
- * Convenience routes for debugging (eg via Postman)
16
- *
17
- * Production code shouldn't call these
18
- * directly, which is why they're limited to devs only
20
+ * Checks whether user's google access token is still valid
19
21
*/
22
+ this . app . route ( `/api/auth/google` ) . get ( [
23
+ verifySession ( ) ,
24
+ //@ts -expect-error res.promise is not returning response types correctly
25
+ authController . verifyGToken ,
26
+ ] ) ;
27
+
20
28
this . app
21
29
. route ( `/api/auth/session` )
22
30
. all ( authMiddleware . verifyIsDev )
23
- //@ts -ignore
31
+ //@ts -expect-error res.promise is not returning response types correctly
32
+ // eslint-disable-next-line @typescript-eslint/no-misused-promises
24
33
. post ( authController . createSession )
25
34
. get ( [
26
35
verifySession ( ) ,
27
- //@ts -ignore
36
+ //@ts -expect-error res.promise is not returning response types correctly
28
37
authController . getUserIdFromSession ,
29
38
] ) ;
30
39
@@ -38,20 +47,10 @@ export class AuthRoutes extends CommonRoutesConfig {
38
47
*/
39
48
this . app . route ( `/api/oauth/google` ) . post ( [
40
49
authMiddleware . verifyGoogleOauthCode ,
41
- //@ts -ignore
50
+ //@ts -expect-error res.promise is not returning response types correctly
42
51
authController . loginOrSignup ,
43
52
] ) ;
44
53
45
- /**
46
- * Ensures a user's google session is still valid, since
47
- * we need to occasionally sync events
48
- */
49
- this . app . route ( `/api/auth/session/gauth/verify` ) . get ( [
50
- verifySession ( ) ,
51
- //@ts -expect-error TODO: fix TS for this and other controller methods in this file
52
- authController . verifyGAuthSession ,
53
- ] ) ;
54
-
55
54
return this . app ;
56
55
}
57
56
}
0 commit comments