@@ -48,40 +48,50 @@ export class ApiRouting {
48
48
49
49
configBasicRoutes ( ) {
50
50
51
- this . router . get ( '/users' , this . getUsers . bind ( this ) ) ;
52
- this . router . post ( '/roles/:roleName/members' , this . secureApiHandler , this . addRoleMembers . bind ( this ) ) ;
53
- this . router . get ( '/roles/:roleName/members' , this . getRoleMembers . bind ( this ) ) ;
54
- this . router . get ( '/roles' , this . getRoles . bind ( this ) ) ;
55
- this . router . post ( '/roles' , this . secureApiHandler , this . addRole . bind ( this ) ) ;
56
- this . router . post ( '/users/register' , this . registerUser . bind ( this ) ) ;
57
- this . router . post ( '/login/token' , this . tokenLogin . bind ( this ) ) ;
58
- this . router . post ( '/login' , this . login . bind ( this ) ) ;
59
- this . router . get ( '/animals/questions/root' , this . getRootQuestion . bind ( this ) ) ;
60
- this . router . get ( '/animals/questions/:questionId' , this . getQuestion . bind ( this ) ) ;
61
- this . router . get ( '/animals/questions' , this . getAllQuestions . bind ( this ) ) ;
62
- this . router . post ( '/animals' , this . saveNewAnimal . bind ( this ) ) ;
63
- this . router . delete ( '/animals/:animalId' , this . secureApiHandler , this . deleteAnimal . bind ( this ) ) ;
64
- this . router . get ( '/celldata/people' , this . getPeople . bind ( this ) ) ;
65
- this . router . post ( '/celldata/people' , this . secureApiHandler , this . addPerson . bind ( this ) ) ;
66
- this . router . get ( '/celldata/cycles' , this . getCycles . bind ( this ) ) ;
67
- this . router . post ( '/celldata/cycles' , this . addCycle . bind ( this ) ) ;
68
- this . router . get ( '/celldata/usage/:personId' , this . getUsageForPerson . bind ( this ) ) ;
69
- this . router . get ( '/celldata/usage' , this . getUsage . bind ( this ) ) ;
70
- this . router . get ( '/celldata/periodusage' , this . getPeriodUsage . bind ( this ) ) ;
71
-
72
- this . router . get ( '/quiz/questions' , this . getQuizQuestions . bind ( this ) ) ;
73
- this . router . post ( '/quiz/questions' , this . secureApiHandler , this . saveNewQuizQuestion . bind ( this ) ) ;
74
- this . router . get ( '/quiz/questions/:questionId' , this . getQuizQuestion . bind ( this ) ) ;
75
- this . router . put ( '/quiz/questions/:questionId' , this . secureApiHandler , this . updateQuestion . bind ( this ) ) ;
76
- this . router . get ( '/quiz/categories' , this . getQuizCategories . bind ( this ) ) ;
77
- this . router . get ( '/quiz/answercategories' , this . getQuizAnswerCategories . bind ( this ) ) ;
78
- this . router . get ( '/quiz/test/user/:username' , this . getUserTests . bind ( this ) ) ;
79
- this . router . post ( '/quiz/test/:testId/score' , this . secureApiHandler , this . scoreTest . bind ( this ) ) ;
80
- this . router . post ( '/quiz/test/:testId/answer/:questionNumber' , this . secureApiHandler , this . recordTestAnswer . bind ( this ) ) ;
81
- this . router . get ( '/quiz/test/:testId' , this . getTest . bind ( this ) ) ;
82
- this . router . post ( '/quiz/test' , this . secureApiHandler , this . createTest . bind ( this ) ) ;
83
- this . router . post ( '/quiz' , this . secureApiHandler , this . createQuiz . bind ( this ) ) ;
84
- this . router . get ( '/quiz/:quizId' , this . getQuiz . bind ( this ) ) ;
51
+ this . router . get ( '/users' , this . addResponseHeaders , this . getUsers . bind ( this ) ) ;
52
+ this . router . post ( '/roles/:roleName/members' , this . addResponseHeaders ,
53
+ this . secureApiHandler , this . addResponseHeaders , this . addRoleMembers . bind ( this ) ) ;
54
+ this . router . get ( '/roles/:roleName/members' , this . addResponseHeaders , this . getRoleMembers . bind ( this ) ) ;
55
+ this . router . get ( '/roles' , this . addResponseHeaders , this . getRoles . bind ( this ) ) ;
56
+ this . router . post ( '/roles' , this . addResponseHeaders , this . secureApiHandler ,
57
+ this . addResponseHeaders , this . addRole . bind ( this ) ) ;
58
+ this . router . post ( '/users/register' , this . addResponseHeaders , this . registerUser . bind ( this ) ) ;
59
+ this . router . post ( '/login/token' , this . addResponseHeaders , this . tokenLogin . bind ( this ) ) ;
60
+ this . router . post ( '/login' , this . addResponseHeaders , this . login . bind ( this ) ) ;
61
+ this . router . get ( '/animals/questions/root' , this . addResponseHeaders , this . getRootQuestion . bind ( this ) ) ;
62
+ this . router . get ( '/animals/questions/:questionId' , this . addResponseHeaders , this . getQuestion . bind ( this ) ) ;
63
+ this . router . get ( '/animals/questions' , this . addResponseHeaders , this . getAllQuestions . bind ( this ) ) ;
64
+ this . router . post ( '/animals' , this . addResponseHeaders , this . saveNewAnimal . bind ( this ) ) ;
65
+ this . router . delete ( '/animals/:animalId' , this . addResponseHeaders , this . secureApiHandler ,
66
+ this . addResponseHeaders , this . deleteAnimal . bind ( this ) ) ;
67
+ this . router . get ( '/celldata/people' , this . addResponseHeaders , this . getPeople . bind ( this ) ) ;
68
+ this . router . post ( '/celldata/people' , this . addResponseHeaders , this . secureApiHandler ,
69
+ this . addResponseHeaders , this . addPerson . bind ( this ) ) ;
70
+ this . router . get ( '/celldata/cycles' , this . addResponseHeaders , this . getCycles . bind ( this ) ) ;
71
+ this . router . post ( '/celldata/cycles' , this . addResponseHeaders , this . addCycle . bind ( this ) ) ;
72
+ this . router . get ( '/celldata/usage/:personId' , this . addResponseHeaders , this . getUsageForPerson . bind ( this ) ) ;
73
+ this . router . get ( '/celldata/usage' , this . addResponseHeaders , this . getUsage . bind ( this ) ) ;
74
+ this . router . get ( '/celldata/periodusage' , this . addResponseHeaders , this . getPeriodUsage . bind ( this ) ) ;
75
+
76
+ this . router . get ( '/quiz/questions' , this . addResponseHeaders , this . getQuizQuestions . bind ( this ) ) ;
77
+ this . router . post ( '/quiz/questions' , this . addResponseHeaders , this . secureApiHandler ,
78
+ this . addResponseHeaders , this . saveNewQuizQuestion . bind ( this ) ) ;
79
+ this . router . get ( '/quiz/questions/:questionId' , this . addResponseHeaders , this . getQuizQuestion . bind ( this ) ) ;
80
+ this . router . put ( '/quiz/questions/:questionId' , this . addResponseHeaders , this . secureApiHandler ,
81
+ this . addResponseHeaders , this . updateQuestion . bind ( this ) ) ;
82
+ this . router . get ( '/quiz/categories' , this . addResponseHeaders , this . getQuizCategories . bind ( this ) ) ;
83
+ this . router . get ( '/quiz/answercategories' , this . addResponseHeaders , this . getQuizAnswerCategories . bind ( this ) ) ;
84
+ this . router . get ( '/quiz/test/user/:username' , this . addResponseHeaders , this . getUserTests . bind ( this ) ) ;
85
+ this . router . post ( '/quiz/test/:testId/score' , this . addResponseHeaders , this . secureApiHandler ,
86
+ this . addResponseHeaders , this . scoreTest . bind ( this ) ) ;
87
+ this . router . post ( '/quiz/test/:testId/answer/:questionNumber' , this . addResponseHeaders ,
88
+ this . secureApiHandler , this . addResponseHeaders , this . recordTestAnswer . bind ( this ) ) ;
89
+ this . router . get ( '/quiz/test/:testId' , this . addResponseHeaders , this . getTest . bind ( this ) ) ;
90
+ this . router . post ( '/quiz/test' , this . addResponseHeaders , this . secureApiHandler ,
91
+ this . addResponseHeaders , this . createTest . bind ( this ) ) ;
92
+ this . router . post ( '/quiz' , this . addResponseHeaders , this . secureApiHandler ,
93
+ this . addResponseHeaders , this . createQuiz . bind ( this ) ) ;
94
+ this . router . get ( '/quiz/:quizId' , this . addResponseHeaders , this . getQuiz . bind ( this ) ) ;
85
95
86
96
var uploads = multer ( { dest : this . uploadFolder } ) ;
87
97
@@ -92,7 +102,10 @@ export class ApiRouting {
92
102
this . uploadUsage . bind ( this ) ] ) ;
93
103
}
94
104
95
-
105
+ addResponseHeaders ( req :express . Request , res :express . Response , next :express . NextFunction ) {
106
+ res . set ( 'Access-Control-Allow-Origin' , '*' ) ;
107
+ next ( ) ;
108
+ }
96
109
getUsers ( req , res , next ) {
97
110
this . securityService . getUsers ( )
98
111
. then ( users => res . send ( users ) )
0 commit comments