@ozdao/prometheus-framework 0.1.35 → 0.1.36

Sign up to get free protection for your applications and to get access to all the features.
@@ -410,16 +410,16 @@ var invites_routes = function(app, db) {
410
410
  const controllerFactory$1 = auth_controller;
411
411
  const controllerFactoryTwofa = twofa_controller;
412
412
  const middlewareFactory$1 = index.server;
413
- var auth_routes = function(app, db) {
413
+ var auth_routes = function(app, db, origins) {
414
414
  const controller = controllerFactory$1(db);
415
415
  const controllerTwofa = controllerFactoryTwofa();
416
416
  const { verifySignUp, verifyUser } = middlewareFactory$1(db);
417
417
  app.use(function(req, res, next) {
418
- res.header(
419
- "Access-Control-Allow-Headers",
420
- "Access-Control-Allow-Origin",
421
- "x-access-token, Origin, Content-Type, Accept"
422
- );
418
+ const origin = req.headers.origin;
419
+ if (origins.includes(origin)) {
420
+ res.setHeader("Access-Control-Allow-Origin", origin);
421
+ }
422
+ res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
423
423
  next();
424
424
  });
425
425
  app.post(
@@ -409,16 +409,16 @@ var invites_routes = function(app, db) {
409
409
  const controllerFactory$1 = auth_controller;
410
410
  const controllerFactoryTwofa = twofa_controller;
411
411
  const middlewareFactory$1 = server;
412
- var auth_routes = function(app, db) {
412
+ var auth_routes = function(app, db, origins) {
413
413
  const controller = controllerFactory$1(db);
414
414
  const controllerTwofa = controllerFactoryTwofa();
415
415
  const { verifySignUp, verifyUser } = middlewareFactory$1(db);
416
416
  app.use(function(req, res, next) {
417
- res.header(
418
- "Access-Control-Allow-Headers",
419
- "Access-Control-Allow-Origin",
420
- "x-access-token, Origin, Content-Type, Accept"
421
- );
417
+ const origin = req.headers.origin;
418
+ if (origins.includes(origin)) {
419
+ res.setHeader("Access-Control-Allow-Origin", origin);
420
+ }
421
+ res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
422
422
  next();
423
423
  });
424
424
  app.post(
@@ -487,16 +487,16 @@ var server = middlewareIndexFactory;
487
487
  const controllerFactory$2 = blog_controller;
488
488
  const middlewareFactoryGlobal = index.server;
489
489
  const middlewareFactoryCommunity = server;
490
- var blog_routes = function(app, db) {
490
+ var blog_routes = function(app, db, origins) {
491
491
  const controller = controllerFactory$2(db);
492
492
  middlewareFactoryGlobal(db);
493
493
  const { verifyBlogpost: verifyBlogpost2 } = middlewareFactoryCommunity(db);
494
494
  app.use(function(req, res, next) {
495
- res.header(
496
- "Access-Control-Allow-Headers",
497
- "Access-Control-Allow-Origin",
498
- "x-access-token, Origin, Content-Type, Accept"
499
- );
495
+ const origin = req.headers.origin;
496
+ if (origins.includes(origin)) {
497
+ res.setHeader("Access-Control-Allow-Origin", origin);
498
+ }
499
+ res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
500
500
  next();
501
501
  });
502
502
  app.get(
@@ -486,16 +486,16 @@ var server = middlewareIndexFactory;
486
486
  const controllerFactory$2 = blog_controller;
487
487
  const middlewareFactoryGlobal = server$1;
488
488
  const middlewareFactoryCommunity = server;
489
- var blog_routes = function(app, db) {
489
+ var blog_routes = function(app, db, origins) {
490
490
  const controller = controllerFactory$2(db);
491
491
  middlewareFactoryGlobal(db);
492
492
  const { verifyBlogpost: verifyBlogpost2 } = middlewareFactoryCommunity(db);
493
493
  app.use(function(req, res, next) {
494
- res.header(
495
- "Access-Control-Allow-Headers",
496
- "Access-Control-Allow-Origin",
497
- "x-access-token, Origin, Content-Type, Accept"
498
- );
494
+ const origin = req.headers.origin;
495
+ if (origins.includes(origin)) {
496
+ res.setHeader("Access-Control-Allow-Origin", origin);
497
+ }
498
+ res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
499
499
  next();
500
500
  });
501
501
  app.get(
@@ -493,16 +493,16 @@ var server = middlewareIndexFactory;
493
493
  const controllerFactory$2 = events_controller;
494
494
  const middlewareFactoryGlobal = index.server;
495
495
  const middlewareFactoryEvents = server;
496
- var events_routes = function(app, db) {
496
+ var events_routes = function(app, db, origins) {
497
497
  const controller = controllerFactory$2(db);
498
498
  middlewareFactoryGlobal(db);
499
499
  const { verifyEvent: verifyEvent2 } = middlewareFactoryEvents(db);
500
500
  app.use(function(req, res, next) {
501
- res.header(
502
- "Access-Control-Allow-Headers",
503
- "Access-Control-Allow-Origin",
504
- "x-access-token, Origin, Content-Type, Accept"
505
- );
501
+ const origin = req.headers.origin;
502
+ if (origins.includes(origin)) {
503
+ res.setHeader("Access-Control-Allow-Origin", origin);
504
+ }
505
+ res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
506
506
  next();
507
507
  });
508
508
  app.get(
@@ -491,16 +491,16 @@ var server = middlewareIndexFactory;
491
491
  const controllerFactory$2 = events_controller;
492
492
  const middlewareFactoryGlobal = server$1;
493
493
  const middlewareFactoryEvents = server;
494
- var events_routes = function(app, db) {
494
+ var events_routes = function(app, db, origins) {
495
495
  const controller = controllerFactory$2(db);
496
496
  middlewareFactoryGlobal(db);
497
497
  const { verifyEvent: verifyEvent2 } = middlewareFactoryEvents(db);
498
498
  app.use(function(req, res, next) {
499
- res.header(
500
- "Access-Control-Allow-Headers",
501
- "Access-Control-Allow-Origin",
502
- "x-access-token, Origin, Content-Type, Accept"
503
- );
499
+ const origin = req.headers.origin;
500
+ if (origins.includes(origin)) {
501
+ res.setHeader("Access-Control-Allow-Origin", origin);
502
+ }
503
+ res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
504
504
  next();
505
505
  });
506
506
  app.get(
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ozdao/prometheus-framework",
3
- "version": "0.1.35",
3
+ "version": "0.1.36",
4
4
  "description": "Web3 Framework focused on user experience and ease of development.",
5
5
  "author": "OZ DAO <hello@ozdao.dev>",
6
6
  "license": "GPL-3.0-or-later",
@@ -4,7 +4,7 @@ const controllerFactoryTwofa = require("../controllers/twofa.controller");
4
4
  // Middlewares
5
5
  const middlewareFactory = require('@pf/src/modules/middlewares/server');
6
6
  // Routes
7
- module.exports = function(app, db) {
7
+ module.exports = function(app, db, origins) {
8
8
  const controller = controllerFactory(db);
9
9
  const controllerTwofa = controllerFactoryTwofa(db);
10
10
 
@@ -12,11 +12,14 @@ module.exports = function(app, db) {
12
12
 
13
13
  app.use(function(req, res, next) {
14
14
 
15
- res.header(
16
- "Access-Control-Allow-Headers",
17
- "Access-Control-Allow-Origin",
18
- "x-access-token, Origin, Content-Type, Accept"
19
- );
15
+ const origin = req.headers.origin;
16
+
17
+ if (origins.includes(origin)) {
18
+ res.setHeader('Access-Control-Allow-Origin', origin);
19
+ }
20
+
21
+ res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
22
+
20
23
  next();
21
24
  });
22
25
 
@@ -3,18 +3,22 @@ const controllerFactory = require("../controllers/blog.controller");
3
3
  const middlewareFactoryGlobal = require('@pf/src/modules/middlewares/server');
4
4
  const middlewareFactoryCommunity = require('../middlewares/server');
5
5
 
6
- module.exports = function(app, db) {
6
+ module.exports = function(app, db, origins) {
7
7
  const controller = controllerFactory(db);
8
8
 
9
9
  const { authJwt } = middlewareFactoryGlobal(db);
10
10
  const { verifyBlogpost } = middlewareFactoryCommunity(db);
11
11
 
12
12
  app.use(function(req, res, next) {
13
- res.header(
14
- "Access-Control-Allow-Headers",
15
- "Access-Control-Allow-Origin",
16
- "x-access-token, Origin, Content-Type, Accept"
17
- );
13
+
14
+ const origin = req.headers.origin;
15
+
16
+ if (origins.includes(origin)) {
17
+ res.setHeader('Access-Control-Allow-Origin', origin);
18
+ }
19
+
20
+ res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
21
+
18
22
  next();
19
23
  });
20
24
 
@@ -4,7 +4,7 @@ const controllerFactory = require("../controllers/events.controller");
4
4
  const middlewareFactoryGlobal = require('@pf/src/modules/middlewares/server');
5
5
  const middlewareFactoryEvents = require('../middlewares/server');
6
6
  // Routes
7
- module.exports = function(app, db) {
7
+ module.exports = function(app, db, origins) {
8
8
  const controller = controllerFactory(db);
9
9
 
10
10
  const { authJwt } = middlewareFactoryGlobal(db);
@@ -12,11 +12,14 @@ module.exports = function(app, db) {
12
12
 
13
13
  app.use(function(req, res, next) {
14
14
 
15
- res.header(
16
- "Access-Control-Allow-Headers",
17
- "Access-Control-Allow-Origin",
18
- "x-access-token, Origin, Content-Type, Accept"
19
- );
15
+ const origin = req.headers.origin;
16
+
17
+ if (origins.includes(origin)) {
18
+ res.setHeader('Access-Control-Allow-Origin', origin);
19
+ }
20
+
21
+ res.header("Access-Control-Allow-Headers", "x-access-token, Origin, Content-Type, Accept");
22
+
20
23
  next();
21
24
  });
22
25