backend-plus 2.5.2-betha.17 → 2.5.2-betha.19

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.
Files changed (2) hide show
  1. package/lib/backend-plus.js +19 -16
  2. package/package.json +1 -1
@@ -913,18 +913,21 @@ AppBackend.prototype.start = function start(opts){
913
913
  }).then(async function(){
914
914
  mainApp = express();
915
915
  //mainApp.use(cookieParser());
916
- const whitelist = ['localhost'].concat(be.config.server.allowedHosts||[]); // Agrega aquí los orígenes de tus aplicaciones
917
- const corsOptions = {
918
- origin: function (origin, callback) {
919
- if (whitelist.some((element)=>origin?.includes(element)) || !origin){
920
- callback(null, true);
921
- }else{
922
- callback(new Error('Not allowed by CORS'));
923
- }
924
- },
925
- credentials: true
926
- };
927
- if(be.config.server.useCors){
916
+ if(be.config.server.allowedHosts){
917
+ if(!Array.isArray(be.config.server.allowedHosts)){
918
+ throw Error('allowedHosts must be an Array')
919
+ }
920
+ const whitelist = ['localhost'].concat(be.config.server.allowedHosts);
921
+ const corsOptions = {
922
+ origin: function (origin, callback) {
923
+ if (whitelist.some((element)=>origin?.includes(element)) || !origin){
924
+ callback(null, true);
925
+ }else{
926
+ callback(new Error('Not allowed by CORS'));
927
+ }
928
+ },
929
+ credentials: true
930
+ };
928
931
  mainApp.use(cors(corsOptions));
929
932
  }
930
933
  mainApp.use(bodyParser.urlencoded({extended:true, limit: '50mb'}));
@@ -2985,7 +2988,7 @@ AppBackend.prototype.dumpDbSchemaPartial = async function dumpDbSchemaPartial(pa
2985
2988
  }
2986
2989
  }
2987
2990
  lines.push(`
2988
- create or replace procedure set_app_user(p_user text)
2991
+ create or replace procedure set_app_user(p_username text)
2989
2992
  security definer language plpgsql
2990
2993
  as
2991
2994
  $body$
@@ -2994,7 +2997,7 @@ declare
2994
2997
  ${db.quoteIdent('v_'+fieldName)} text;`
2995
2998
  ).join('')}
2996
2999
  begin
2997
- if p_user = '!login' then
3000
+ if p_username = '!login' then
2998
3001
  ${be.config.login.infoFieldList.map(fieldName => `
2999
3002
  set backend_plus._${fieldName} = '!';`).join('')}
3000
3003
 
@@ -3006,13 +3009,13 @@ begin
3006
3009
  from ${(be.config.login.from ?? (
3007
3010
  (be.config.login.schema?be.db.quoteIdent(be.config.login.schema)+'.':'')+
3008
3011
  be.db.quoteIdent(be.config.login.table)))}
3009
- where ${db.quoteIdent(be.config.login.userFieldName)} = p_user;
3012
+ where ${db.quoteIdent(be.config.login.userFieldName)} = p_username;
3010
3013
  ${be.config.login.infoFieldList.map(fieldName => `
3011
3014
  perform set_config('backend_plus._${fieldName}', v_${fieldName}, false);`).join('')}
3012
3015
 
3013
3016
  set backend_plus._mode = normal;
3014
3017
  end if;
3015
- perform set_config('backend_plus._user', p_user, false);
3018
+ perform set_config('backend_plus._user', p_username, false);
3016
3019
  end;
3017
3020
  $body$;
3018
3021
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "backend-plus",
3
3
  "description": "Backend for the anti Pareto rule",
4
- "version": "2.5.2-betha.17",
4
+ "version": "2.5.2-betha.19",
5
5
  "author": "Codenautas <codenautas@googlegroups.com>",
6
6
  "license": "MIT",
7
7
  "repository": "codenautas/backend-plus",