backend-plus 2.5.2-betha.15 → 2.5.2-betha.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/backend-plus.d.ts +3 -2
- package/lib/backend-plus.js +39 -34
- package/package.json +1 -1
package/lib/backend-plus.d.ts
CHANGED
|
@@ -396,7 +396,8 @@ export interface AppConfigServer
|
|
|
396
396
|
"kill-9": string // a way to kill from URL with a token
|
|
397
397
|
bitacoraSchema: string
|
|
398
398
|
bitacoraTableName: string
|
|
399
|
-
|
|
399
|
+
useCors: boolean //habilita Cross-Origin Resource Sharing
|
|
400
|
+
allowedHosts:string[] //determina API allowed hosts (necesita habilitar useCors)
|
|
400
401
|
}
|
|
401
402
|
export interface AppConfigDb
|
|
402
403
|
{
|
|
@@ -587,7 +588,7 @@ export class AppBackend{
|
|
|
587
588
|
messages:Record<LangId,Record<string, string>>
|
|
588
589
|
}
|
|
589
590
|
shutdownCallbackListAdd(param:{message:string, fun:()=>Promise<void>}):void
|
|
590
|
-
shutdownBackend():Promise<void>
|
|
591
|
+
shutdownBackend(opts?:{skipTurnOff?:boolean, onlyTurnOff?:boolean}):Promise<void>
|
|
591
592
|
setLog(opts:{until:string, results?:boolean}):void
|
|
592
593
|
getDataDumpTransformations(rawData:string):Promise<{rawData:string, prepareTransformationSql:string[], endTransformationSql:string[]}>
|
|
593
594
|
}
|
package/lib/backend-plus.js
CHANGED
|
@@ -643,33 +643,42 @@ AppBackend.prototype.start = function start(opts){
|
|
|
643
643
|
// @ts-ignore : only for testing */
|
|
644
644
|
this.getMainApp = function getMainApp(){ return mainApp; };
|
|
645
645
|
}
|
|
646
|
-
this.shutdownBackend = async function shutdownBackend(){
|
|
647
|
-
|
|
648
|
-
var
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
646
|
+
this.shutdownBackend = async function shutdownBackend(opts){
|
|
647
|
+
var shootingDown = opts == null || !opts.onlyTurnOff;
|
|
648
|
+
var turningOff = opts == null || !opts.skipTurnOff;
|
|
649
|
+
if(!shootingDown){
|
|
650
|
+
console.log('shooting down:');
|
|
651
|
+
var waitFor = [
|
|
652
|
+
new Promise(function(resolve,reject){
|
|
653
|
+
console.log('*','express server');
|
|
654
|
+
be.server.close(/** @param {Error} err */function(err){
|
|
655
|
+
if(err){
|
|
656
|
+
console.log('*', err)
|
|
657
|
+
reject(err);
|
|
658
|
+
}else{
|
|
659
|
+
console.log('*','express server done!')
|
|
660
|
+
resolve();
|
|
661
|
+
}
|
|
662
|
+
});
|
|
663
|
+
}),
|
|
664
|
+
...(be.shutdownCallbackList.map(x => (async function(){
|
|
665
|
+
console.log('shut:', x.message)
|
|
666
|
+
await x.fun()
|
|
667
|
+
console.log('done:', x.message)
|
|
668
|
+
})())),
|
|
669
|
+
];
|
|
670
|
+
console.log('*', 'waiting for all')
|
|
671
|
+
await Promise.all(waitFor);
|
|
672
|
+
console.log('*', 'all done')
|
|
673
|
+
mainApp = null;
|
|
674
|
+
}
|
|
675
|
+
if(turningOff){
|
|
676
|
+
console.log('turning off:');
|
|
677
|
+
await pg.shutdown();
|
|
678
|
+
console.log('pg shutdown done!');
|
|
679
|
+
console.log('* logWhy',logWhy)
|
|
680
|
+
logWhy && logWhy();
|
|
681
|
+
}
|
|
673
682
|
};
|
|
674
683
|
return Promise.resolve().then(function(){
|
|
675
684
|
var configList=be.configList();
|
|
@@ -915,7 +924,9 @@ AppBackend.prototype.start = function start(opts){
|
|
|
915
924
|
},
|
|
916
925
|
credentials: true
|
|
917
926
|
};
|
|
918
|
-
|
|
927
|
+
if(be.config.server.useCors){
|
|
928
|
+
mainApp.use(cors(corsOptions));
|
|
929
|
+
}
|
|
919
930
|
mainApp.use(bodyParser.urlencoded({extended:true, limit: '50mb'}));
|
|
920
931
|
mainApp.use(function(req,res,next){
|
|
921
932
|
if((req.headers['content-type']||'').match(/^multipart\/form-data/)){
|
|
@@ -1008,12 +1019,6 @@ AppBackend.prototype.start = function start(opts){
|
|
|
1008
1019
|
mainApp.loginPlusManager.closeManager();
|
|
1009
1020
|
}
|
|
1010
1021
|
});
|
|
1011
|
-
be.shutdownCallbackListAdd({
|
|
1012
|
-
message:'pg',
|
|
1013
|
-
fun:function(){
|
|
1014
|
-
pg.shutdown();
|
|
1015
|
-
}
|
|
1016
|
-
});
|
|
1017
1022
|
mainApp.loginPlusManager.setValidatorStrategy(
|
|
1018
1023
|
function(req, username, password, done) {
|
|
1019
1024
|
var client;
|
package/package.json
CHANGED