@@ -2,155 +2,201 @@ const express = require('express');
2
2
const passport = require ( 'passport' ) ;
3
3
const router = express . Router ( ) ;
4
4
const auth = require ( '../components/auth' ) ;
5
- const isValidBackendToken = auth . isValidBackendToken ( ) ;
6
- const { deleteRfiApplication, getRFIMedian, getRFIApplication, createRFIApplication, updateRFIApplication} = require ( '../components/rfiApplication' ) ;
5
+ const isValidBackendToken = auth . isValidBackendToken ( ) ;
6
+ const { deleteRfiApplication, getRFIMedian, getRFIApplication, createRFIApplication, updateRFIApplication } = require ( '../components/rfiApplication' ) ;
7
7
const { upsertParentFees, updateCCFRIApplication, deleteCCFRIApplication, renewCCOFApplication, getApplicationSummary, getChangeRequest, deletePcfApplication } = require ( '../components/application' ) ;
8
- const { patchCCFRIApplication, getECEWEApplication, updateECEWEApplication, updateECEWEFacilityApplication, getCCFRIApplication, getDeclaration, submitApplication, updateStatusForApplicationComponents} = require ( '../components/application' ) ;
8
+ const {
9
+ patchCCFRIApplication,
10
+ getECEWEApplication,
11
+ updateECEWEApplication,
12
+ updateECEWEFacilityApplication,
13
+ getApprovableFeeSchedules,
14
+ getCCFRIApplication,
15
+ getDeclaration,
16
+ submitApplication,
17
+ updateStatusForApplicationComponents,
18
+ } = require ( '../components/application' ) ;
9
19
const { getNMFApplication, updateNMFApplication, createNMFApplication } = require ( '../components/nmfApplication' ) ;
10
20
const { param, validationResult } = require ( 'express-validator' ) ;
11
21
12
- router . post ( '/renew-ccof' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ ] , ( req , res ) => {
22
+ router . post ( '/renew-ccof' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ ] , ( req , res ) => {
13
23
return renewCCOFApplication ( req , res ) ;
14
24
} ) ;
15
25
16
26
/* CREATE or UPDATE an existing CCFRI application for opt-in and out
17
27
CCOF application guid and facility guid are defined in the payload
18
28
*/
19
- router . get ( '/ccfri/:ccfriId' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken ,
20
- [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
21
- validationResult ( req ) . throw ( ) ;
22
- return getCCFRIApplication ( req , res ) ;
23
- } ) ;
29
+ router . get ( '/ccfri/:ccfriId' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . notEmpty ( ) . isUUID ( ) ] , ( req , res ) => {
30
+ validationResult ( req ) . throw ( ) ;
31
+ return getCCFRIApplication ( req , res ) ;
32
+ } ) ;
24
33
25
- router . get ( '/ccfri/:ccfriId/rfi' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken ,
26
- [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
27
- validationResult ( req ) . throw ( ) ;
28
- return getRFIApplication ( req , res ) ;
29
- } ) ;
34
+ router . get ( '/ccfri/:ccfriId/afs' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . notEmpty ( ) . isUUID ( ) ] , ( req , res ) => {
35
+ validationResult ( req ) . throw ( ) ;
36
+ return getApprovableFeeSchedules ( req , res ) ;
37
+ } ) ;
30
38
31
- router . post ( '/ccfri/:ccfriId/rfi' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken ,
32
- [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
33
- validationResult ( req ) . throw ( ) ;
34
- return createRFIApplication ( req , res ) ;
35
- } ) ;
39
+ router . get ( '/ccfri/:ccfriId/rfi' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . notEmpty ( ) . isUUID ( ) ] , ( req , res ) => {
40
+ validationResult ( req ) . throw ( ) ;
41
+ return getRFIApplication ( req , res ) ;
42
+ } ) ;
36
43
37
- router . put ( '/ccfri/rfi/:rfipfiid' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken ,
38
- [ param ( 'rfipfiid' , 'URL param: [rfipfiid] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
39
- validationResult ( req ) . throw ( ) ;
40
- return updateRFIApplication ( req , res ) ;
41
- } ) ;
44
+ router . post ( '/ccfri/:ccfriId/rfi' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . notEmpty ( ) . isUUID ( ) ] , ( req , res ) => {
45
+ validationResult ( req ) . throw ( ) ;
46
+ return createRFIApplication ( req , res ) ;
47
+ } ) ;
42
48
43
- router . get ( '/ccfri/:ccfriId/median' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken ,
44
- [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
45
- validationResult ( req ) . throw ( ) ;
46
- return getRFIMedian ( req , res ) ;
47
- } ) ;
49
+ router . put ( '/ccfri/rfi/:rfipfiid' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ param ( 'rfipfiid' , 'URL param: [rfipfiid] is required' ) . notEmpty ( ) . isUUID ( ) ] , ( req , res ) => {
50
+ validationResult ( req ) . throw ( ) ;
51
+ return updateRFIApplication ( req , res ) ;
52
+ } ) ;
48
53
49
- router . delete ( '/ccfri/:ccfriId/rfi' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken ,
50
- [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
51
- validationResult ( req ) . throw ( ) ;
52
- return deleteRfiApplication ( req , res ) ;
53
- } ) ;
54
+ router . get ( '/ccfri/:ccfriId/median' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . notEmpty ( ) . isUUID ( ) ] , ( req , res ) => {
55
+ validationResult ( req ) . throw ( ) ;
56
+ return getRFIMedian ( req , res ) ;
57
+ } ) ;
54
58
55
- router . patch ( '/ccfri' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ ] , ( req , res ) => {
59
+ router . delete ( '/ccfri/:ccfriId/rfi' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . notEmpty ( ) . isUUID ( ) ] , ( req , res ) => {
60
+ validationResult ( req ) . throw ( ) ;
61
+ return deleteRfiApplication ( req , res ) ;
62
+ } ) ;
63
+
64
+ router . patch ( '/ccfri' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ ] , ( req , res ) => {
56
65
//validationResult(req).throw();
57
- //console.log(req.bpdy);
58
66
return updateCCFRIApplication ( req , res ) ;
59
67
} ) ;
60
68
61
- router . patch ( '/ccfri/:ccfriId/' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ ] , ( req , res ) => {
69
+ router . patch ( '/ccfri/:ccfriId/' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . notEmpty ( ) . isUUID ( ) ] , ( req , res ) => {
62
70
//validationResult(req).throw();
63
71
return patchCCFRIApplication ( req , res ) ;
64
72
} ) ;
65
73
66
- router . delete ( '/ccfri/:ccfriId/' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken ,
67
- [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
68
- return deleteCCFRIApplication ( req , res ) ;
74
+ router . delete ( '/ccfri/:ccfriId/' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . notEmpty ( ) . isUUID ( ) ] , ( req , res ) => {
75
+ return deleteCCFRIApplication ( req , res ) ;
69
76
} ) ;
70
77
71
- router . get ( '/ccfri/:ccfriId/nmf' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken ,
72
- [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
73
- validationResult ( req ) . throw ( ) ;
74
- return getNMFApplication ( req , res ) ;
75
- } ) ;
78
+ router . get ( '/ccfri/:ccfriId/nmf' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . notEmpty ( ) . isUUID ( ) ] , ( req , res ) => {
79
+ validationResult ( req ) . throw ( ) ;
80
+ return getNMFApplication ( req , res ) ;
81
+ } ) ;
76
82
77
- router . post ( '/ccfri/:ccfriId/nmf' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken ,
78
- [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
79
- validationResult ( req ) . throw ( ) ;
80
- return createNMFApplication ( req , res ) ;
81
- } ) ;
83
+ router . post ( '/ccfri/:ccfriId/nmf' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ param ( 'ccfriId' , 'URL param: [ccfriId] is required' ) . notEmpty ( ) . isUUID ( ) ] , ( req , res ) => {
84
+ validationResult ( req ) . throw ( ) ;
85
+ return createNMFApplication ( req , res ) ;
86
+ } ) ;
82
87
83
- router . put ( '/ccfri/nmf/:nmfpfiid' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken ,
84
- [ param ( 'nmfpfiid' , 'URL param: [nmfpfiid] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
85
- validationResult ( req ) . throw ( ) ;
86
- return updateNMFApplication ( req , res ) ;
87
- } ) ;
88
+ router . put ( '/ccfri/nmf/:nmfpfiid' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ param ( 'nmfpfiid' , 'URL param: [nmfpfiid] is required' ) . notEmpty ( ) . isUUID ( ) ] , ( req , res ) => {
89
+ validationResult ( req ) . throw ( ) ;
90
+ return updateNMFApplication ( req , res ) ;
91
+ } ) ;
88
92
89
93
/* CREATE or UPDATE parent fees for a specified age group and year.
90
94
age group and year are defined in the payload
91
95
*/
92
- router . patch ( '/parentfee' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ ] , ( req , res ) => {
96
+ router . patch ( '/parentfee' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [ ] , ( req , res ) => {
93
97
//validationResult(req).throw();
94
- //console.log(req.bpdy);
95
98
return upsertParentFees ( req , res ) ;
96
99
} ) ;
97
100
98
-
99
101
/* Retrieve an ECEWE application for an application id. */
100
- router . get ( '/ecewe/:applicationId' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , ( req , res ) => {
101
- return getECEWEApplication ( req , res ) ;
102
- } ) ;
102
+ router . get (
103
+ '/ecewe/:applicationId' ,
104
+ passport . authenticate ( 'jwt' , { session : false } ) ,
105
+ isValidBackendToken ,
106
+ [ param ( 'applicationId' , 'URL param: [applicationId] is required' ) . notEmpty ( ) . isUUID ( ) ] ,
107
+ ( req , res ) => {
108
+ return getECEWEApplication ( req , res ) ;
109
+ } ,
110
+ ) ;
103
111
104
112
/* Update an ECEWE applciation for an application id. */
105
- router . patch ( '/ecewe/:applicationId' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [
106
- param ( 'applicationId' , 'URL param: [applicationId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
107
- return updateECEWEApplication ( req , res ) ;
108
- } ) ;
113
+ router . patch (
114
+ '/ecewe/:applicationId' ,
115
+ passport . authenticate ( 'jwt' , { session : false } ) ,
116
+ isValidBackendToken ,
117
+ [ param ( 'applicationId' , 'URL param: [applicationId] is required' ) . notEmpty ( ) . isUUID ( ) ] ,
118
+ ( req , res ) => {
119
+ return updateECEWEApplication ( req , res ) ;
120
+ } ,
121
+ ) ;
109
122
110
123
/* Update an ECEWE facility applciation for an ecewe application id. */
111
- router . post ( '/ecewe/facilities/:applicationId' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [
112
- param ( 'applicationId' , 'URL param: [applicationId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
113
- return updateECEWEFacilityApplication ( req , res ) ;
114
- } ) ;
124
+ router . post (
125
+ '/ecewe/facilities/:applicationId' ,
126
+ passport . authenticate ( 'jwt' , { session : false } ) ,
127
+ isValidBackendToken ,
128
+ [ param ( 'applicationId' , 'URL param: [applicationId] is required' ) . notEmpty ( ) . isUUID ( ) ] ,
129
+ ( req , res ) => {
130
+ return updateECEWEFacilityApplication ( req , res ) ;
131
+ } ,
132
+ ) ;
115
133
116
134
/* Get the user declaration for a given application id. */
117
- router . get ( '/declaration/:applicationId' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , ( req , res ) => {
118
- return getDeclaration ( req , res ) ;
119
- } ) ;
135
+ router . get (
136
+ '/declaration/:applicationId' ,
137
+ passport . authenticate ( 'jwt' , { session : false } ) ,
138
+ isValidBackendToken ,
139
+ [ param ( 'applicationId' , 'URL param: [applicationId] is required' ) . notEmpty ( ) . isUUID ( ) ] ,
140
+ ( req , res ) => {
141
+ return getDeclaration ( req , res ) ;
142
+ } ,
143
+ ) ;
120
144
121
145
/* Update Declaration for an CCOF/CCFRI/ECEWE application given an application id. */
122
- router . patch ( '/declaration/submit/:applicationId' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [
123
- param ( 'applicationId' , 'URL param: [applicationId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
124
- return submitApplication ( req , res ) ;
125
- } ) ;
146
+ router . patch (
147
+ '/declaration/submit/:applicationId' ,
148
+ passport . authenticate ( 'jwt' , { session : false } ) ,
149
+ isValidBackendToken ,
150
+ [ param ( 'applicationId' , 'URL param: [applicationId] is required' ) . notEmpty ( ) . isUUID ( ) ] ,
151
+ ( req , res ) => {
152
+ return submitApplication ( req , res ) ;
153
+ } ,
154
+ ) ;
126
155
127
156
/* Get the full summary of the application */
128
- router . get ( '/summary/:applicationId' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [
129
- param ( 'applicationId' , 'URL param: [applicationId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
130
- return getApplicationSummary ( req , res ) ;
131
- } ) ;
132
-
133
- router . put ( '/status/:applicationId' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken ,
134
- [ param ( 'applicationId' , 'URL param: [applicationId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
157
+ router . get (
158
+ '/summary/:applicationId' ,
159
+ passport . authenticate ( 'jwt' , { session : false } ) ,
160
+ isValidBackendToken ,
161
+ [ param ( 'applicationId' , 'URL param: [applicationId] is required' ) . notEmpty ( ) . isUUID ( ) ] ,
162
+ ( req , res ) => {
163
+ return getApplicationSummary ( req , res ) ;
164
+ } ,
165
+ ) ;
166
+
167
+ router . put (
168
+ '/status/:applicationId' ,
169
+ passport . authenticate ( 'jwt' , { session : false } ) ,
170
+ isValidBackendToken ,
171
+ [ param ( 'applicationId' , 'URL param: [applicationId] is required' ) . notEmpty ( ) . isUUID ( ) ] ,
172
+ ( req , res ) => {
135
173
validationResult ( req ) . throw ( ) ;
136
174
return updateStatusForApplicationComponents ( req , res ) ;
137
- } ) ;
175
+ } ,
176
+ ) ;
138
177
139
178
/* Get existing change requests for an application */
140
179
141
- router . get ( '/changeRequest/:applicationId' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken , [
142
- param ( 'applicationId' , 'URL param: [applicationId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
143
- return getChangeRequest ( req , res ) ;
144
- } ) ;
145
-
180
+ router . get (
181
+ '/changeRequest/:applicationId' ,
182
+ passport . authenticate ( 'jwt' , { session : false } ) ,
183
+ isValidBackendToken ,
184
+ [ param ( 'applicationId' , 'URL param: [applicationId] is required' ) . notEmpty ( ) . isUUID ( ) ] ,
185
+ ( req , res ) => {
186
+ return getChangeRequest ( req , res ) ;
187
+ } ,
188
+ ) ;
146
189
147
190
/* DELETE an existing PCF -- new PCF ONLY */
148
191
149
- router . delete ( '/:applicationId/' , passport . authenticate ( 'jwt' , { session : false } ) , isValidBackendToken ,
150
- [ param ( 'applicationId' , 'URL param: [applicationId] is required' ) . not ( ) . isEmpty ( ) ] , ( req , res ) => {
192
+ router . delete (
193
+ '/:applicationId/' ,
194
+ passport . authenticate ( 'jwt' , { session : false } ) ,
195
+ isValidBackendToken ,
196
+ [ param ( 'applicationId' , 'URL param: [applicationId] is required' ) . notEmpty ( ) . isUUID ( ) ] ,
197
+ ( req , res ) => {
151
198
return deletePcfApplication ( req , res ) ;
152
- } ) ;
153
-
199
+ } ,
200
+ ) ;
154
201
155
202
module . exports = router ;
156
-
0 commit comments