@jaypie/express 1.1.2 → 1.1.4
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/dist/module.cjs +25 -1
- package/dist/module.esm.js +25 -1
- package/package.json +2 -2
- package/src/cors.helper.js +18 -1
package/dist/module.cjs
CHANGED
|
@@ -95,6 +95,30 @@ const corsHelper = (config = {}) => {
|
|
|
95
95
|
return expressCors(options);
|
|
96
96
|
};
|
|
97
97
|
|
|
98
|
+
//
|
|
99
|
+
//
|
|
100
|
+
// Export
|
|
101
|
+
//
|
|
102
|
+
|
|
103
|
+
console.log("Export cors middleware");
|
|
104
|
+
var cors_helper = (config) => {
|
|
105
|
+
console.log("Create cors middleware");
|
|
106
|
+
const cors = corsHelper(config);
|
|
107
|
+
return (req, res, next) => {
|
|
108
|
+
console.log("Run cors middleware");
|
|
109
|
+
cors(req, res, (error) => {
|
|
110
|
+
if (error) {
|
|
111
|
+
res.status(error.status);
|
|
112
|
+
res.setHeader("Content-Type", "application/json");
|
|
113
|
+
console.log("Return cors error");
|
|
114
|
+
return res.json(error.toJSON());
|
|
115
|
+
}
|
|
116
|
+
console.log("Allow next");
|
|
117
|
+
next();
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
};
|
|
121
|
+
|
|
98
122
|
//
|
|
99
123
|
//
|
|
100
124
|
// Helper Functions
|
|
@@ -627,7 +651,7 @@ const {
|
|
|
627
651
|
|
|
628
652
|
exports.EXPRESS = EXPRESS;
|
|
629
653
|
exports.badRequestRoute = badRequestRoute;
|
|
630
|
-
exports.cors =
|
|
654
|
+
exports.cors = cors_helper;
|
|
631
655
|
exports.echoRoute = echoRoute;
|
|
632
656
|
exports.expressHandler = expressHandler;
|
|
633
657
|
exports.expressHttpCodeHandler = httpHandler;
|
package/dist/module.esm.js
CHANGED
|
@@ -93,6 +93,30 @@ const corsHelper = (config = {}) => {
|
|
|
93
93
|
return expressCors(options);
|
|
94
94
|
};
|
|
95
95
|
|
|
96
|
+
//
|
|
97
|
+
//
|
|
98
|
+
// Export
|
|
99
|
+
//
|
|
100
|
+
|
|
101
|
+
console.log("Export cors middleware");
|
|
102
|
+
var cors_helper = (config) => {
|
|
103
|
+
console.log("Create cors middleware");
|
|
104
|
+
const cors = corsHelper(config);
|
|
105
|
+
return (req, res, next) => {
|
|
106
|
+
console.log("Run cors middleware");
|
|
107
|
+
cors(req, res, (error) => {
|
|
108
|
+
if (error) {
|
|
109
|
+
res.status(error.status);
|
|
110
|
+
res.setHeader("Content-Type", "application/json");
|
|
111
|
+
console.log("Return cors error");
|
|
112
|
+
return res.json(error.toJSON());
|
|
113
|
+
}
|
|
114
|
+
console.log("Allow next");
|
|
115
|
+
next();
|
|
116
|
+
});
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
|
|
96
120
|
//
|
|
97
121
|
//
|
|
98
122
|
// Helper Functions
|
|
@@ -623,4 +647,4 @@ const {
|
|
|
623
647
|
notImplementedRoute,
|
|
624
648
|
} = routes;
|
|
625
649
|
|
|
626
|
-
export { EXPRESS, badRequestRoute,
|
|
650
|
+
export { EXPRESS, badRequestRoute, cors_helper as cors, echoRoute, expressHandler, httpHandler as expressHttpCodeHandler, forbiddenRoute, goneRoute, methodNotAllowedRoute, noContentRoute, notFoundRoute, notImplementedRoute };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaypie/express",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.4",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"author": "Finlayson Studio",
|
|
6
6
|
"type": "module",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "7f489ba1dd28a86aeb8cb3764797ba50c0626e9b"
|
|
47
47
|
}
|
package/src/cors.helper.js
CHANGED
|
@@ -83,4 +83,21 @@ const corsHelper = (config = {}) => {
|
|
|
83
83
|
// Export
|
|
84
84
|
//
|
|
85
85
|
|
|
86
|
-
|
|
86
|
+
console.log("Export cors middleware");
|
|
87
|
+
export default (config) => {
|
|
88
|
+
console.log("Create cors middleware");
|
|
89
|
+
const cors = corsHelper(config);
|
|
90
|
+
return (req, res, next) => {
|
|
91
|
+
console.log("Run cors middleware");
|
|
92
|
+
cors(req, res, (error) => {
|
|
93
|
+
if (error) {
|
|
94
|
+
res.status(error.status);
|
|
95
|
+
res.setHeader("Content-Type", "application/json");
|
|
96
|
+
console.log("Return cors error");
|
|
97
|
+
return res.json(error.toJSON());
|
|
98
|
+
}
|
|
99
|
+
console.log("Allow next");
|
|
100
|
+
next();
|
|
101
|
+
});
|
|
102
|
+
};
|
|
103
|
+
};
|