@@ -16,6 +16,11 @@ import loadOpenApiFile from "./openapi/openapi_loader";
1616import resource_routes from './routes/resources_routes' ;
1717import resume_routes from './routes/resume_routes' ;
1818import githubRoutes from './routes/github_routes' ;
19+ import linkedinRoutes from './routes/linkedin_routes' ;
20+ import session from 'express-session' ;
21+ import passport from 'passport' ;
22+ import cookieParser from 'cookie-parser' ;
23+ import ( './config/passport' ) ;
1924
2025const specs = swaggerJsdoc ( options ) ;
2126
@@ -40,6 +45,22 @@ const removeUndefinedOrEmptyFields = (req: Request, res: Response, next: NextFun
4045 next ( ) ;
4146} ;
4247
48+
49+ app . use ( cookieParser ( ) ) ;
50+ app . use ( session ( {
51+ secret : 'your-secret' ,
52+ resave : false ,
53+ saveUninitialized : false ,
54+ } ) ) ;
55+
56+ // Initialize Passport
57+ app . use ( passport . initialize ( ) ) ;
58+ app . use ( passport . session ( ) ) ;
59+
60+ // Load Passport config
61+ import ( './config/passport' ) ;
62+
63+
4364app . use ( bodyParser . json ( ) ) ;
4465app . use ( removeUndefinedOrEmptyFields ) ;
4566app . use ( bodyParser . urlencoded ( { extended : true } ) ) ;
@@ -60,12 +81,18 @@ app.use(authenticateToken.unless({
6081 { url : '/comment' , methods : [ 'GET' ] } ,
6182 { url : '/post' , methods : [ 'GET' ] } , // Allow GET to /post
6283 { url : / ^ \/ r e s o u r c e \/ i m a g e \/ [ ^ \/ ] + $ / , methods : [ 'GET' ] } , // Allow GET to /resource/image/{anything}
84+ { url : '/linkedin/auth' } ,
85+ { url : '/linkedin/callback' } ,
6386 ]
6487} ) ) ;
6588
6689// Add AUTH middleware for params queries
6790// To block queries without Authentication
68- app . use ( authenticateTokenForParams ) ;
91+ app . use ( authenticateTokenForParams . unless ( {
92+ path : [
93+ { url : '/linkedin/callback' }
94+ ]
95+ } ) ) ;
6996
7097app . use ( '/auth' , authRoutes ) ;
7198app . use ( '/comment' , commentsRoutes ) ;
@@ -76,5 +103,6 @@ app.use('/resource', resource_routes);
76103app . use ( '/room' , roomsRoutes ) ;
77104app . use ( '/resume' , resume_routes ) ;
78105app . use ( '/github' , githubRoutes ) ;
106+ app . use ( '/linkedin' , linkedinRoutes ) ;
79107
80108export { app , corsOptions } ;
0 commit comments