@@ -13,11 +13,11 @@ export class NginxController {
13
13
}
14
14
15
15
public registerRoutes ( ) : void {
16
- this . app . post ( '/nginx/reload' , ...this . requestHandlers , this . reloadNginx . bind ( this ) )
16
+ this . app . get ( '/nginx/reload' , ...this . requestHandlers , this . reloadNginx . bind ( this ) )
17
17
this . app . post ( '/nginx/config/update' , ...this . requestHandlers , this . updateConfig . bind ( this ) )
18
18
this . app . get ( '/nginx/config/get' , ...this . requestHandlers , this . getConfig . bind ( this ) )
19
19
this . app . get ( '/nginx/config/get-default' , ...this . requestHandlers , this . getDefaultConfig . bind ( this ) )
20
- this . app . get ( '/nginx/config/write-default' , ...this . requestHandlers , this . writeDefaultConfig . bind ( this ) )
20
+ this . app . post ( '/nginx/config/write-default' , ...this . requestHandlers , this . writeDefaultConfig . bind ( this ) )
21
21
this . app . post ( '/nginx/certificates/obtain' , ...this . requestHandlers , this . obtainCertificates . bind ( this ) )
22
22
this . app . get ( '/nginx/certificates/renew' , ...this . requestHandlers , this . renewCertificates . bind ( this ) )
23
23
log ( 'info' , 'NginxController initialized' )
@@ -60,13 +60,17 @@ export class NginxController {
60
60
}
61
61
62
62
private async writeDefaultConfig ( req : Request , res : Response ) : Promise < void > {
63
- if ( req . body != null && req . body . domain != null ) {
64
- const domain = req . body . domain
65
- const { success, message } = await this . nginxManager . writeDefaultTemplate ( domain )
66
- if ( success ) {
67
- res . json ( { success, message : 'Default config written successfully' } )
63
+ if ( req . body != null && req . body . domain != null && req . body . cidrGroups != null ) {
64
+ const { domain, cidrGroups } = req . body
65
+ if ( Array . isArray ( cidrGroups ) && typeof domain === 'string' ) {
66
+ const { success, message } = await this . nginxManager . writeDefaultTemplate ( domain , cidrGroups )
67
+ if ( success ) {
68
+ res . json ( { success, message : 'Default config written successfully' } )
69
+ } else {
70
+ res . status ( 500 ) . json ( { success, message } )
71
+ }
68
72
} else {
69
- res . status ( 500 ) . json ( { success, message } )
73
+ res . status ( 400 ) . json ( { success : false , message : 'Invalid request body' } )
70
74
}
71
75
} else {
72
76
res . status ( 400 ) . json ( { success : false , message : 'Invalid request body' } )
0 commit comments