@@ -24,19 +24,42 @@ const routes = express.Router();
24
24
25
25
// Enables CORS on those routes according config above
26
26
// ToDo configure CORS for set of our trusted domains
27
- routes . use ( cors ( ) ) ;
28
- routes . options ( '*' , cors ( ) ) ;
29
-
30
- routes . get ( '/jobs' , ( req , res , next ) => new RecruitCRMService ( ) . getAllJobs ( req , res , next ) ) ;
31
- routes . get ( '/jobs/cache' , ( req , res , next ) => new RecruitCRMService ( ) . getJobsCacheStats ( req , res , next ) ) ;
32
- routes . get ( '/jobs/cache/flush' , ( req , res , next ) => authenticator ( authenticatorOptions ) ( req , res , next ) , ( req , res , next ) => new RecruitCRMService ( ) . getJobsCacheFlush ( req , res , next ) ) ;
33
- routes . get ( '/jobs/search' , ( req , res , next ) => new RecruitCRMService ( ) . getJobs ( req , res , next ) ) ;
34
- routes . get ( '/jobs/:id' , ( req , res , next ) => new RecruitCRMService ( ) . getJob ( req , res , next ) ) ;
35
- routes . post ( '/jobs/:id/apply' , ( req , res , next ) => authenticator ( authenticatorOptions ) ( req , res , next ) , upload . single ( 'resume' ) , ( req , res , next ) => new RecruitCRMService ( ) . applyForJob ( req , res , next ) ) ;
36
- routes . get ( '/candidates/search' , ( req , res , next ) => new RecruitCRMService ( ) . searchCandidates ( req , res , next ) ) ;
27
+ // routes.use(cors());
28
+ // routes.options('*', cors());
29
+
30
+ routes . options ( '/jobs' , cors ( ) ) ;
31
+ routes . get ( '/jobs' , cors ( ) , ( req , res , next ) => new RecruitCRMService ( ) . getAllJobs ( req , res , next ) ) ;
32
+
33
+ routes . options ( '/jobs/cache' , cors ( ) ) ;
34
+ routes . get ( '/jobs/cache' , cors ( ) , ( req , res , next ) => new RecruitCRMService ( ) . getJobsCacheStats ( req , res , next ) ) ;
35
+
36
+ routes . options ( '/jobs/cache/flush' , cors ( ) ) ;
37
+ routes . get ( '/jobs/cache/flush' , cors ( ) , ( req , res , next ) => authenticator ( authenticatorOptions ) ( req , res , next ) , ( req , res , next ) => new RecruitCRMService ( ) . getJobsCacheFlush ( req , res , next ) ) ;
38
+
39
+ routes . options ( '/jobs/search' , cors ( ) ) ;
40
+ routes . get ( '/jobs/search' , cors ( ) , ( req , res , next ) => new RecruitCRMService ( ) . getJobs ( req , res , next ) ) ;
41
+
42
+ routes . options ( '/jobs/:id' , cors ( ) ) ;
43
+ routes . get ( '/jobs/:id' , cors ( ) , ( req , res , next ) => new RecruitCRMService ( ) . getJob ( req , res , next ) ) ;
44
+
45
+ const applyOptions = {
46
+ origin : true ,
47
+ methods : [ 'POST' ] ,
48
+ credentials : true ,
49
+ maxAge : 3600 ,
50
+ allowedHeaders : [ 'Content-Type' , 'Authorization' ] ,
51
+ } ;
52
+ routes . options ( '/jobs/:id/apply' , cors ( applyOptions ) ) ;
53
+ routes . post ( '/jobs/:id/apply' , cors ( applyOptions ) , ( req , res , next ) => authenticator ( authenticatorOptions ) ( req , res , next ) , upload . single ( 'resume' ) , ( req , res , next ) => new RecruitCRMService ( ) . applyForJob ( req , res , next ) ) ;
54
+
55
+ routes . options ( '/candidates/search' , cors ( ) ) ;
56
+ routes . get ( '/candidates/search' , cors ( ) , ( req , res , next ) => new RecruitCRMService ( ) . searchCandidates ( req , res , next ) ) ;
37
57
// new router added
38
- routes . get ( '/profile' , ( req , res , next ) => authenticator ( authenticatorOptions ) ( req , res , next ) , ( req , res , next ) => new RecruitCRMService ( ) . getProfile ( req , res , next ) ) ;
39
- routes . post ( '/profile' , ( req , res , next ) => authenticator ( authenticatorOptions ) ( req , res , next ) , upload . single ( 'resume' ) , ( req , res , next ) => new RecruitCRMService ( ) . updateProfile ( req , res , next ) ) ;
40
- routes . get ( '/taasjobs' , ( req , res , next ) => new RecruitCRMService ( ) . getJobsFromTaas ( req , res , next ) ) ;
58
+ routes . options ( '/profile' , cors ( ) ) ;
59
+ routes . get ( '/profile' , cors ( ) , ( req , res , next ) => authenticator ( authenticatorOptions ) ( req , res , next ) , ( req , res , next ) => new RecruitCRMService ( ) . getProfile ( req , res , next ) ) ;
60
+ routes . post ( '/profile' , cors ( ) , ( req , res , next ) => authenticator ( authenticatorOptions ) ( req , res , next ) , upload . single ( 'resume' ) , ( req , res , next ) => new RecruitCRMService ( ) . updateProfile ( req , res , next ) ) ;
61
+
62
+ routes . options ( '/taasjobs' , cors ( ) ) ;
63
+ routes . get ( '/taasjobs' , cors ( ) , ( req , res , next ) => new RecruitCRMService ( ) . getJobsFromTaas ( req , res , next ) ) ;
41
64
42
65
export default routes ;
0 commit comments